Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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 am currently running a linux fileserver, and I would like to make it possible so that once the machine is running, then by pressing the power button it will automatically shutdown and switch off. Currently, pressing the power button doesn't do anything.
How would I set it up (using APM or whatever) so that the machine will automatically shutdown?
It's never a good idea to shutdown just using the power button. Linux has a sequence it has to go through to unmount devices and filesystems safely. If you just turn the button off, it could corrupt your filesystem.
Originally posted by darthtux It's never a good idea to shutdown just using the power button. Linux has a sequence it has to go through to unmount devices and filesystems safely. If you just turn the button off, it could corrupt your filesystem.
I realise that.. what I am trying to achieve is for linux to go through the whole normal shutdown procedure when the button is pressed, not a hard power-off. Is this possible?
1.As darthtux already said, it would be a poor idea to just power off the machine. It would be equivalent to yanking the plug out of the socket, and the risks of damaging your system would be high.
2. AFAIK, No, there is no way to "attach" a shutdown procedure to the power button.
3. Regarding your comment that "pressing the power button doesn't do anything" -- some machines, like my Dell at work, require that you hold the power button down for several seconds before the power cuts off. The idea presumably is to minimize the chances of an accidental shutdown. -- J.W.
I used to have a keyboard with a "Power Off" button, that when pressed, under Windows, would go through proper shutdown and switch off the machine. This is effectively what I'm trying to get at, but using the power switch on the case rather than a key on the keyboard.
J.W.: In regard to your 3rd point, I know that holding the power button down does a hard power-off, but it is the one-touch press that does something else, that currently isn't set to do anything - hence my comment about it not doing anything.. Sorry if I was unclear.
Here's a short explanation of how the server currently acts: It is used by my entire family as a file/print server, and I'm not always here, so I'm trying to make it as easy as possible for the non-techie members of the family to use. To switch on, just press power.. easy. To switch off, I've made a user called "shutdown", and if you log on as that user then the machine automatically shuts down and switches off. That's a step in the right direction, but if possible I'd like to make it even easier. This is why I'm trying to map a software command to the power button being pressed, as I've described.
Caeda & contrasutra: I will read those links and try what I can, and I'll report my progress here for future reference.
Mr Smidge - I understand your point. The original intent of my post was really only to emphaize the dangers of doing a hard power down without allowing the system to do an orderly shutdown first. About a year ago we had a blackout in my neighborhood during a storm, and long story short, it killed my system, and I needed to do a reinstall as a result. If anything I can say can help someone else avoid the same predicament, I'll put in my 2 cents.
Caeda - I suppose that your, um, "scolding" might also be directed at my post. Not to be defensive, but considering that points #1 and #3 in my post are factually correct, and that I prefaced point #2 with "AFAIK", I fail to see how my post could possibly be considered misleading or incorrect. Since you seem to be so keen on doling out advice to others, I'll assume that you're equally receptive to being given advice yourself, and with that in mind, you might consider this (and again I'll second darthtux): Unless you're a moderator, please refrain from broadcasting your opinion on who should or should not submit a well-intentioned reply to a question. In my experience with this board, we're all just trying to lend a helping hand in whatever way we can. Regards. -- J.W.