Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I dont know which shortcuts you're looking for, but you can shutdown your macchine using above mentioned commands i.e. poweroff and shutdown. Additionally, you can create alias of these commands to make commands little short. For example, for reboot the machine (as root only) you can:
Code:
~# alias r='shutdown -r now'
To shutdown:
Code:
~# alias s='shutdown -h now'
In this way, when you will press r system will reboot, and s will shutdown the machine.
If you are regularly working in terminal, how hard is it to type 'poweroff' to switch-off the machine.
And if you are mostly working on GUI, then what's the point in opening the terminal and typing 'poweroff' to switch-off, when you can easily just hit poweroff button.
i am looking for an emergency - power off -or shut down.
why: i run a q 210 notebook from samsung
this is well known for a backlight issue. - all runs well . but suddenly all gets dark - the display does not display any more.
for more than 6 months i had no issues here. All went well - but in the last few days i had some issues again.
suddenly the display was dark
Well - if i swith off the notebook and switch on all goes well.
BUT - i need to have a emergence-switch-off version!!!!!
so - the hint on the command-line- way is good - but you have to know that - if all is dark - i cannot see what i am doing and where the commmmand-line is!?
now i look at the next version - the emergency version of power off-.- ie your link!
above alll
many many thanks for all your hints and for all you do!!
Here we use shutdown -g0 -h and it works great! We also run the sync command before emergency shutdowns to synchronize the data on the disk with the memory.
I shutdown from console all the time. Terminal is the same.
>> who
To see how many consoles I have running so I can close any open editors.
If not closed they create save files.
When logged in as Root, then
>> halt
Halt will invoke shutdown now in most situations.
When logged in as a user then do not have privilege to run halt.
Could change privileges, but easier to use the three finger shutdown.
>> sync
Then (ctrl-alt-del)
CTRL-ALT-DEL will be intercepted and will invoke the halt program.
This key interception and the program it invokes is setup in someplace in /etc.
In the terminal console you can edit key definitions for the linux console keyboard and see (and change) the response for special combinations, like CTRL-ALT-DEL.
There is also keyboard driver special key setup that can intercept it earlier.
And X11 has its keyboard special key sequence intercepts too.
Any shorter key sequence might get invoked by accident.
This mouse repeater can also be setup to invoke halt for certain mouse button combinations.
This is explained in their docs.
If the button device interface is installed then detection of a power button press can invoke any program you want.
- a short press usually invokes "suspend"
- a long press usually invokes "shutdown"
This is setup in /etc again, but I cannot remember which files.
It was already setup in Slackware. Give them a try on your machine.
Last edited by selfprogrammed; 07-09-2013 at 06:52 PM.
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
Rep:
There is usually a setting you can change under Power Settings (or similar) to choose what happens when you press the power button. On my netbook I have it set to "choose" but it is just as easy to set it to "shutdown" so that the power button can be used to shut the machine down cleanly. I'm using XFCE but I am sure I have seen the same choices under Gnome and KDE.
I think what you are looking for is a keyboard shortcut, right?
You can assign custom commands (in your case the "shutdown -h now" command) to keyboard shortcuts, but how to do it depends on your desktop environment.
In in the larger desktop environments (like KDE, Gnome, XFCE etc...) you can assign them through graphical tools in the system settings. In the lighter ones (like openbox, fluxbox etc...) you have to edit text configuration files.
Since shutdown requires root privileges the script you are linking the shortcut to should actually say
Code:
sudo shutdown -h now
You will then have to allow yourself to call shutdown via sudo without requiring a password. This can be done by editig the sudoers file using the command
Code:
visudo
(as root) and adding the line
Code:
ALL ALL = NOPASSWD: /sbin/shutdown
Note that this line will allow all users on your machine to shut it down, but on a home computer this should not be a problem...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.