LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 05-06-2015, 09:42 PM   #1
hyderali
LQ Newbie
 
Registered: May 2015
Distribution: CentOS,Mint,Ubuntu
Posts: 2

Rep: Reputation: Disabled
Unhappy System shutdown


how to shutdown linux system as regular user using command line?
 
Old 05-06-2015, 10:18 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,323
Blog Entries: 28

Rep: Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141
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.

Last edited by frankbell; 05-06-2015 at 10:20 PM.
 
Old 05-06-2015, 10:23 PM   #3
hyderali
LQ Newbie
 
Registered: May 2015
Distribution: CentOS,Mint,Ubuntu
Posts: 2

Original Poster
Rep: Reputation: Disabled
as a regular user,
using $su -c "shutdown now" can make system shutdown, using root credential
 
Old 05-07-2015, 05:53 AM   #4
Jeaye
LQ Newbie
 
Registered: Jun 2012
Location: Singapore
Distribution: Slackware, Arch
Posts: 4

Rep: Reputation: Disabled
Quote:
Originally Posted by hyderali View Post
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
 
Old 05-07-2015, 06:50 AM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
I prefer to use:
Code:
$ sudo poweroff
 
Old 05-07-2015, 07:29 AM   #6
Jeaye
LQ Newbie
 
Registered: Jun 2012
Location: Singapore
Distribution: Slackware, Arch
Posts: 4

Rep: Reputation: Disabled
Quote:
Originally Posted by rtmistler View Post
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).

Last edited by Jeaye; 05-07-2015 at 07:42 AM.
 
Old 05-07-2015, 07:34 AM   #7
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by Jeaye View Post
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?
 
Old 05-07-2015, 07:40 AM   #8
Jeaye
LQ Newbie
 
Registered: Jun 2012
Location: Singapore
Distribution: Slackware, Arch
Posts: 4

Rep: Reputation: Disabled
Quote:
Originally Posted by rtmistler View Post
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.
 
Old 05-07-2015, 08:04 AM   #9
cepheus11
Member
 
Registered: Nov 2010
Location: Germany
Distribution: Gentoo
Posts: 286

Rep: Reputation: 91
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] shutdown works, but /lib/systemd/system/shutdown.target does not. kaz2100 Debian 3 08-06-2014 03:28 AM
[SOLVED] Telnet System B from A so System C would shutdown slipstreamed Red Hat 12 06-11-2012 04:16 AM
System shutdown on its own.........? M$ISBS Linux - Security 3 05-14-2006 09:56 PM
Why can't my system shutdown? naihe2010 Linux - Software 1 11-27-2005 04:50 PM
System Halting while shutdown system. LiloAma Linux - Software 15 01-02-2005 08:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration