[Solved]How to make a script/shortcut for shutdown button

nuclear4future

New Member
Joined
Mar 31, 2022
Messages
4
Reaction score
3
Credits
35
Hello all.

Basically the tittle.
When I was on Windows 10 I could make a notepad file with a shutdown instruction and then save it as .bat and then I can execute the shortcut and shutdown my computer from an icon on the desktop.
If this helps:
I have Linux OpenSuse Leap 15.3 KDE and the kernel is that:
5.3.18-150300.59.60-default
I know what is Terminal, I can basically copy and paste a text in Python if this is any help.
Even after many months I still feel like a noob.


If you need additional info or I am missing something please tell me.

Thank you.
 
Last edited:


NORD

Gold Member
Gold Supporter
Joined
Jan 4, 2019
Messages
349
Reaction score
277
Credits
1,725
Ctrl+alt+T
no sudo:
type this in terminal ===== shutdown wait 5 sec and it will shut your pc down
or to cancel shutdown -c
for Debian/ubuntu/mint
Screenshot from 2022-03-31 01-21-53.png
 

NORD

Gold Member
Gold Supporter
Joined
Jan 4, 2019
Messages
349
Reaction score
277
Credits
1,725
you can do everything in terminal the best part about Linux.

If you download anything type in sudo apt update followed by sudo apt full-upgrade
Or you just want to make sure your up to date
 

lomszz

Member
Joined
Nov 8, 2021
Messages
45
Reaction score
36
Credits
305
Save it as example: shutdown.sh
after that use chmod on terminal to make it executable

edit: You can save it on desktop
 
Last edited:
OP
nuclear4future

nuclear4future

New Member
Joined
Mar 31, 2022
Messages
4
Reaction score
3
Credits
35
Save it as example: shutdown.sh
after that use chmod on terminal to make it executable

edit: You can save it on desktop
When I run this executable: shutdown.sh it doesn't run it
When I run it under terminal ./shutdown.sh and then asks me about my password
My questions are this:
How can I just click on the shutdown.sh executable and make it run without me running the terminal.
How can I make the executable so it has my password and I don't have to type it every time I would like to shutdown my PC?
That is what is under my .sh now:
sudo shutdown because only with shutdown it say "command not found".
 

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
6,474
Reaction score
5,730
Credits
52,084
You can actually (hopefully) go about that with this little number:


Basically, you're granting regular users the rights to access and shutdown without a password. (Method #1, number 4 should do the trick.)
 
OP
nuclear4future

nuclear4future

New Member
Joined
Mar 31, 2022
Messages
4
Reaction score
3
Credits
35
Thank you all for your comments and suggestions!
I got it working and I am happy!
Have a great day!
 

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
6,474
Reaction score
5,730
Credits
52,084
Glad it's sorted and thanks for marking it as solved. The great thing about that is people finding the thread via search will know there's a resolution in this thread.
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Staff online

Members online


Top