LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   System shutdown (https://www.linuxquestions.org/questions/linux-newbie-8/system-shutdown-4175541829/)

hyderali 05-06-2015 09:42 PM

System shutdown
 
how to shutdown linux system as regular user using command line?

frankbell 05-06-2015 10:18 PM

By default, regular users do not have rights to shut down a Linux system. When desktop environments shut down the system from a menu, they assume root's rights to do so.

As root, you can issue this command to shut down the system from the command line.

Code:

shutdown now -h
There are variants on this. See

Code:

man shutdown
for more.

hyderali 05-06-2015 10:23 PM

as a regular user,
using $su -c "shutdown now" can make system shutdown, using root credential

Jeaye 05-07-2015 05:53 AM

Quote:

Originally Posted by hyderali (Post 5358954)
as a regular user,
using $su -c "shutdown now" can make system shutdown, using root credential

Bringing the system down requires root privileges. For a detailed explanation of the multiple ways to properly shutdown your system (for halt or reboot), see the slackbook: http://www.slackbook.org/html/essent...-shutdown.html

rtmistler 05-07-2015 06:50 AM

I prefer to use:
Code:

$ sudo poweroff

Jeaye 05-07-2015 07:29 AM

Quote:

Originally Posted by rtmistler (Post 5359073)
I prefer to use:
Code:

$ sudo poweroff

I'll try to make an argument against powering down with sudo (though I also prefer using poweroff as opposed to telinit or shutdown).

A couple of Christmases ago, I went back home to see some family. I left my Arch work/development machine at home, into which I'd SSH every day. I also had the habit of using sudo shutdown -h now and, therefore, it was in my bash history. On Christmas day, due to a storm, we had crazy spotty internet and, when navigating my bash history, I accidentally hit enter when sudo shutdown -h now was to be shown (though it wasn't showing yet). Not having time to cancel it, due to the 'now' and the choppy connection, I spent the rest of the vacation having to put up with my family instead of back in Linux land. ;)

Don't make the same mistake I did: either use HISTIGNORE or, better yet, avoid scary sudo commands when you can; prefer a login shell with separate bash history (and maybe HISTIGNORE on top of that).

rtmistler 05-07-2015 07:34 AM

Quote:

Originally Posted by Jeaye (Post 5359094)
I'll try to make an argument against powering down with sudo (though I also prefer using poweroff as opposed to telinit or shutdown).

A couple of Christmases ago, I went back home to see some family. I left my Arch work/development machine at home, into which I'd SSH every day. I also had the habit of using sudo shutdown -h now and, therefore, it was in my bash history. On Christmas day, due to a storm, we had crazy spotty internet and, when navigating my bash history, I accidentally hit enter when sudo shutdown -h now was to be shown (though it wasn't showing yet). Not having time to cancel it, due to the 'now' and the choppy connection, I spent the rest of the vacation having to put up with my family instead of back in Linux land.

Don't make the same mistake I did: either use HISTIGNORE or, better yet, avoid scary sudo commands when you can; prefer a login shell with separate bash history (and maybe HISTIGNORE on top of that).

Doesn't matter WHAT command form you use if you have something like that occur.

No offense, but why'd you even go see them if you wanted to play with your computer the whole time?

Jeaye 05-07-2015 07:40 AM

Quote:

Originally Posted by rtmistler (Post 5359099)
Doesn't matter WHAT command form you use if you have something like that occur.

No offense, but why'd you even go see them if you wanted to play with your computer the whole time?

Of course I didn't waste a trip across the country; the jab at spending time with family during the holidays was in jest. Still, it hopefully conveys a lesson well-learned.

cepheus11 05-07-2015 08:04 AM

On most modern desktop distributions with default configuration, this should be possible as a user, from within a desktop session:

Code:

dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop


All times are GMT -5. The time now is 07:35 PM.