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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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:
~# alias r='shutdown -r now'
~# alias s='shutdown -h now'
In this way, when you will press r system will reboot, and s will shutdown the machine.
I shutdown from console all the time. Terminal is the same.
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 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.
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 07:52 PM.
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
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
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
(as root) and adding the line
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...