Why do we need to be root in terminal for shutdown and restart?


Ubuntu is a distribution of the GNU/Linux Operationg System which in turn belongs to the Unix system family - a common architecture for a number of modern Operating Systems.

Traditionally Unix used to run on mainframe computers. Central computing facilities which serve dozends or hundreds of users via remote terminals. Since all users relied on the availability of the mainframe, no single user was allowed to issue a shutdown command. An idea that is fundamental to the Unix architecture - the system kernel will never initialise a shutdown unless the according function is called by a superuser process.

In contemporary desktop systems developers have gone through certain pains to make the shutdown available to the mere desktop user. A common technique is, to let the login manager, which usually runs in the security context of the root user, handle shutdown and reboot. In this case the graphical shell issues a request to the login manager to shutdown the computer. This...

0 0

When we install/remove/update packages or make any changes which require administrative privileges we are prompted for the password of admin user who has the sudo privileges - this happens both via GUI and terminal.

However, if we try to shutdown and restart via terminal, it complains that we need to be root:

$ reboot reboot: Need to be root $ shutdown now shutdown: Need to be root

But we are never asked for a password when we perform these actions via the cog-wheel at top right.

Why is there this discrepancy?

The shutdown on the cog-wheel checks if you are allowed to shutdown the machine. This is done via PolicyKit. In case of shutdown this statement in the file /usr/share/polkit-1/actions/org.freedesktop.consolekit.policy is checked:

Stop the system System policy prevents stopping the system no yes

The PolicyKit triggers a dbus-send command. In case of shutdown it would be:

dbus-send --system --print-reply...
0 0

For the 1st question:

What security risk is posed by not requiring this to have root privileges? The GUI provides a way for any user to shut off or restart, so why do the terminal commands need to be run as root?

Yes, as said in this answer, Linux is inherently designed as multiuser system. Consider more than one user are working on a system, then it would be bad if any one normal user is allowed to turn-off the system while others are working. Imagine what happens if your web-server taken down by a user at a distance! So, Only system administrator aka root-user is allowed to poweroff or reboot the system.

You can also figure-out:

$ which poweroff reboot /sbin/poweroff /sbin/reboot

So, poweroff and reboot are located under /sbin directory which holds the utilities and root-only commands, essential binaries for booting, restoring, recovering, and/or repairing the system.

So, these commands are expected to be run by system-administrator/root user,...

0 0
SUMMARYMutahi Ngunyi has been trolled by Kenyans online after saying the government should shut down the three media houses foreverCS Fred Matiangi said that three media stations will remain closed until they have completed various preliminary investigations

Controversial Political Mutahi Ngunyi’s remarks over the media TV stations shut down by the government has landed him in trouble with Kenyans on social media.

Mutahi said that the government should shut down the three media houses, that is, KTN News, Citizen, and NTV forever.

“We have 43 TV stations or so in Kenya. If you shut down 3 stations, how is that media clampdown? The government should shut them down forever. Kenya is happier without their acidic pessimism,” he posted on his Twitter handle.

We have 43 TV Stations or so in Kenya. If you SHUT down 3 Stations, HOW is that MEDIA CLAMPDOWN? Government should SHUT them DOWN forever. Kenya is HAPPIER without their ACIDIC PESSIMISM.—...

0 0

Originally Posted by


can i run a command as normal user after a sudo within a bash script?

You can run stuff password-less with sudo if you put all the commands that would require root priviledges and which appear in your bash script into the sudoers file, with a complete path. What I mean is this: this is an example on my own system. This script establishes a VPN connection (using a closed-source product) to a customer of mine:


#! /bin/bash /usr/local/bin/barracudavpn --start -r MyPasswordHere sudo route add -net netmask gw sudo route add -net netmask gw sudo route add -net netmask gw sudo route add -net netmask gw sudo route add -net netmask gw many route commands up there are needed or else I would still be unable to reach anything. And those...
0 0

How do I shutdown Linux system from terminal or command line options?

The following programs allow a system administrator to shutdown the Linux server (system) from terminal (xterm or gnome-terminal or kde terminal):

[a] shutdown command – bring the system down with warning message.

[b] poweroff command or halt command – Halt / stop the system (

First, login as root user. Open a terminal window (select Applications > Accessories > Terminal). Switch to the root user by typing su – and entering the root password, when prompted. Type the following command to bring the system down immediately:
# poweroff
# shutdown -h now
# shutdown -h +0

Safe shutdown option

The shutdown command arranges for the system to be brought down in a safe way. All logged-in users are notified that the system is going down and, within the last five minutes of TIME, new logins are prevented. TIME may have different formats, the most...

0 0

Ok I found this note and what he offers works!

02-20-2006, 06:14 PM #4

Join Date: May 2003
Posts: 4,254
You can modify these settings from the command line using 'pmset'. Using cron, you could make simple jobs that first use pmset to schedule the next startup, then execute a shutdown.

As hayne said, the 'shutdown' command will not give any GUI processes an opportunity to save files and whatnot. If you want a more graceful method, I believe you could use AppleScript from the command line to send an apple event instead. It would be like selecting "Shutdown" from the Apple menu:

osascript -e 'tell application "System Events"' -e 'shut down' -e 'end tell'

If any applications have unsaved work, the shutdown would halt.

So I've entered osascript -e 'tell application "System Events"' -e 'shut down' -e 'end tell' into a terminal window and pressed enter and it safely shutdown my system. Now for the next...

0 0

Linux shutdown / reboot command

On Linux, like all tasks, the shutdown and restart operations can also be done from the command line. The commands are shutdown, halt, poweroff, reboot and REISUB keystrokes.

In this post I am going to show you how to shutdown or restart a linux system using these commands. The commands are useful specially when you have to reboot a remote linux server, where only shell access is available and no gui. Servers often need a restart when upgrades are installed or need to shutdown for other maintainance tasks.

The commands are available on any linux system like centos, ubuntu, debian, fedora or suse and do not require the installation of any extra packages.

1. shutdown command

The first command is the shutdown command and it can be used to shutdown a system or restart it. It is commonly used to shutdown or reboot both local and remote machines.

shutdown arranges for the system to be brought down in a safe way. All...
0 0

There are a lot of questions about why shutdown and reboot require root privileges. There are many good answers available too.

But there is someting I don't understand : If being able to reboot or shutdown without root privileges in a multiuser system is a very bad idea ... then why is this possible in Ubuntu 16.04?

When I type poweroff or reboot in a terminal and hit Enter, it indeed shuts down/reboots!

It is okay for me when poweroff and reboot don't require root privileges ... but why does suspend need root privileges? When I type suspend in a terminal and hit Enter, it doesn't suspend, instead it gets stuck ... and when I run pm-suspend, It requires sudo.

For me, both poweroff nor reboot needs a password on Ubuntu 16.04 .

However, for this to occur, I had to create a user account called "foo", for example, and then ssh to localhost as either that user or as myself. When I do this, I do need to authenticate myself. It seems to recognize...

0 0

To shut down the system from a terminal session, sign in or "su" to the "root" account. Then type ``/sbin/shutdown -r now''. It may take several moments for all processes to be terminated, and then Linux will shut down. The computer will reboot itself. If you are in front of the console, a faster alternative to this is to press -- to shut down. Please be patient as it may take a couple of minutes for Linux to terminate.

You can also shut down the system to a halt (ie. it will shut down and not reboot the system). The system will be unavailable until power-cycled or rebooted with --. This can be useful if you need to power down the system and move it to a different location, for example. To do this, type ``/sbin/shutdown -h now'' when signed into or "su"ed to the "root" account. Linux will shut itself down then display a message, "System halted". At this point you can power down the computer.

It is probably a good idea to only shut down the system when you are at the...

0 0

sinister_nation wrote:the power management is when you push the power button, but going thru it deals with more about laptops to conserve the battery power.

In part yes there are settings in the Power Management preferences dialog that deals with laptops and power conservation, BUT, it doesn't necessarily mean exclusivity to just that particular purpose or to laptops for that matter. The other setting (the General tab in particular) also deals with default behavior should you choose to press the power button. And I think this is the closest that you're looking for, sans the countdown dialog popping up and at the same time without sacrificing the security in your Linux install. As a matter of fact, this is how I had set up my desktop system at work, so I don't have to click around the screen to power down my workstation. All I have to do is press the on/off switch and that's enough to trigger the shutdown sequence. The computer doesn't even have to pop-up that countdown...

0 0

Advanced Mac users may wish to shut down a computer from the command line. This can be helpful for remote administration with ssh, in situations where a Mac is booted into Single User Mode, or many other circumstances of troubleshooting and systems administration.

There are several ways to shut down a Mac from the command line, we’ll cover two of the most simple methods using easy syntax.

The Mac Terminal offers many commands for handling various tasks and system functions, and so naturally the command line also offers a method to shutdown a Mac computer from the Terminal as well.

An important word of warning: shutting down a Mac through the command line happens instantaneously. There is no confirmation, no warning dialog, no stopping to save documents, no asking to close apps or save anything. Instead, the Mac will instantly terminate any and all activity going on and immediately shut down the computer. This could lead to data loss, so be sure you are...

0 0