Shutdown from terminal without entering password?

Clash Royale CLAN TAG#URR8PPP up vote
47
down vote
favorite
I have desktop edition of Ubuntu.
I like the Terminal so that that I prefer to shutdown my computer with the shutdown command.
However when I type shutdown now it prompts me to enter my password.Is there any way I can shutdown my computer using this command without entering my password?
command-line shutdown sudo
add a comment |Â
up vote
47
down vote
favorite
I have desktop edition of Ubuntu.
I like the Terminal so that that I prefer to shutdown my computer with the shutdown command.
However when I type shutdown now it prompts me to enter my password.Is there any way I can shutdown my computer using this command without entering my password?
command-line shutdown sudo
2
Does anyone know what command is executed when I click "shutdown" in Desktop Environment?
â kubahaha
Feb 20 '15 at 17:15
add a comment |Â
up vote
47
down vote
favorite
up vote
47
down vote
favorite
I have desktop edition of Ubuntu.
I like the Terminal so that that I prefer to shutdown my computer with the shutdown command.
However when I type shutdown now it prompts me to enter my password.Is there any way I can shutdown my computer using this command without entering my password?
command-line shutdown sudo
I have desktop edition of Ubuntu.
I like the Terminal so that that I prefer to shutdown my computer with the shutdown command.
However when I type shutdown now it prompts me to enter my password.Is there any way I can shutdown my computer using this command without entering my password?
command-line shutdown sudo
edited Jul 27 '12 at 15:28
dlin
2,13621530
2,13621530
asked Jul 27 '12 at 15:14
Santosh Kumar
69561437
69561437
2
Does anyone know what command is executed when I click "shutdown" in Desktop Environment?
â kubahaha
Feb 20 '15 at 17:15
add a comment |Â
2
Does anyone know what command is executed when I click "shutdown" in Desktop Environment?
â kubahaha
Feb 20 '15 at 17:15
2
2
Does anyone know what command is executed when I click "shutdown" in Desktop Environment?
â kubahaha
Feb 20 '15 at 17:15
Does anyone know what command is executed when I click "shutdown" in Desktop Environment?
â kubahaha
Feb 20 '15 at 17:15
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
45
down vote
Run visudo and add one of the following line:
%group_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown
or
user_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown
This allows the user/group to run the above three commands, using sudo, however with no password.
So, sudo poweroff will now result in a passwordless shutdown.
However, to make this even cleaner, we'll add an alias, so that running shutdown calls sudo shutdown now.
Open ~/.bash_aliases for editing.
nano ~/.bash_aliases
Insert the following line at the end of the file:
alias shutdown='sudo shutdown now'
Finally, load the changes to the .bash_aliases file...
source ~/.bash_aliases
Try it out!
shutdown
Thanks, Eric.
add a comment |Â
up vote
34
down vote
A safe way to do this without using sudo and without tinkering with the system, is by executing these one-liner commands:
For Ubuntu 14.10 or earlier:
Shutdown:
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
Restart:
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
consolekit should of course be installed your system.
Other commands you may like:
Suspend:
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
Hibernate: (if enabled on your system)
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
For Ubuntu 15.04 and later:
(This is due to Ubuntu's shift in using systemd instead of Upstart)
systemctl poweroff
systemctl reboot
systemctl suspend
systemctl hibernate
systemctl hybrid-sleep
Since hibernate is normally disabled by default in Ubuntu systems, you can enable this by checking this answer: https://askubuntu.com/a/617254/101985
Original source: https://bbs.archlinux.org/viewtopic.php?id=127962
add a comment |Â
up vote
2
down vote
unity uses many gnome services, and in that case too - you can shutdown gnome way.
gnome-session-quit --power-off --force --no-prompt
will do the job.
add a comment |Â
up vote
1
down vote
While you can use the method of allowing NOPASSWD on /usr/sbin/shutdown, although another, DE-independent solution is to just use init 0.
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
45
down vote
Run visudo and add one of the following line:
%group_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown
or
user_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown
This allows the user/group to run the above three commands, using sudo, however with no password.
So, sudo poweroff will now result in a passwordless shutdown.
However, to make this even cleaner, we'll add an alias, so that running shutdown calls sudo shutdown now.
Open ~/.bash_aliases for editing.
nano ~/.bash_aliases
Insert the following line at the end of the file:
alias shutdown='sudo shutdown now'
Finally, load the changes to the .bash_aliases file...
source ~/.bash_aliases
Try it out!
shutdown
Thanks, Eric.
add a comment |Â
up vote
45
down vote
Run visudo and add one of the following line:
%group_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown
or
user_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown
This allows the user/group to run the above three commands, using sudo, however with no password.
So, sudo poweroff will now result in a passwordless shutdown.
However, to make this even cleaner, we'll add an alias, so that running shutdown calls sudo shutdown now.
Open ~/.bash_aliases for editing.
nano ~/.bash_aliases
Insert the following line at the end of the file:
alias shutdown='sudo shutdown now'
Finally, load the changes to the .bash_aliases file...
source ~/.bash_aliases
Try it out!
shutdown
Thanks, Eric.
add a comment |Â
up vote
45
down vote
up vote
45
down vote
Run visudo and add one of the following line:
%group_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown
or
user_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown
This allows the user/group to run the above three commands, using sudo, however with no password.
So, sudo poweroff will now result in a passwordless shutdown.
However, to make this even cleaner, we'll add an alias, so that running shutdown calls sudo shutdown now.
Open ~/.bash_aliases for editing.
nano ~/.bash_aliases
Insert the following line at the end of the file:
alias shutdown='sudo shutdown now'
Finally, load the changes to the .bash_aliases file...
source ~/.bash_aliases
Try it out!
shutdown
Thanks, Eric.
Run visudo and add one of the following line:
%group_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown
or
user_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown
This allows the user/group to run the above three commands, using sudo, however with no password.
So, sudo poweroff will now result in a passwordless shutdown.
However, to make this even cleaner, we'll add an alias, so that running shutdown calls sudo shutdown now.
Open ~/.bash_aliases for editing.
nano ~/.bash_aliases
Insert the following line at the end of the file:
alias shutdown='sudo shutdown now'
Finally, load the changes to the .bash_aliases file...
source ~/.bash_aliases
Try it out!
shutdown
Thanks, Eric.
edited Apr 13 '17 at 12:23
Communityâ¦
1
1
answered Jul 27 '12 at 15:21
SirCharlo
28.2k75574
28.2k75574
add a comment |Â
add a comment |Â
up vote
34
down vote
A safe way to do this without using sudo and without tinkering with the system, is by executing these one-liner commands:
For Ubuntu 14.10 or earlier:
Shutdown:
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
Restart:
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
consolekit should of course be installed your system.
Other commands you may like:
Suspend:
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
Hibernate: (if enabled on your system)
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
For Ubuntu 15.04 and later:
(This is due to Ubuntu's shift in using systemd instead of Upstart)
systemctl poweroff
systemctl reboot
systemctl suspend
systemctl hibernate
systemctl hybrid-sleep
Since hibernate is normally disabled by default in Ubuntu systems, you can enable this by checking this answer: https://askubuntu.com/a/617254/101985
Original source: https://bbs.archlinux.org/viewtopic.php?id=127962
add a comment |Â
up vote
34
down vote
A safe way to do this without using sudo and without tinkering with the system, is by executing these one-liner commands:
For Ubuntu 14.10 or earlier:
Shutdown:
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
Restart:
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
consolekit should of course be installed your system.
Other commands you may like:
Suspend:
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
Hibernate: (if enabled on your system)
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
For Ubuntu 15.04 and later:
(This is due to Ubuntu's shift in using systemd instead of Upstart)
systemctl poweroff
systemctl reboot
systemctl suspend
systemctl hibernate
systemctl hybrid-sleep
Since hibernate is normally disabled by default in Ubuntu systems, you can enable this by checking this answer: https://askubuntu.com/a/617254/101985
Original source: https://bbs.archlinux.org/viewtopic.php?id=127962
add a comment |Â
up vote
34
down vote
up vote
34
down vote
A safe way to do this without using sudo and without tinkering with the system, is by executing these one-liner commands:
For Ubuntu 14.10 or earlier:
Shutdown:
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
Restart:
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
consolekit should of course be installed your system.
Other commands you may like:
Suspend:
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
Hibernate: (if enabled on your system)
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
For Ubuntu 15.04 and later:
(This is due to Ubuntu's shift in using systemd instead of Upstart)
systemctl poweroff
systemctl reboot
systemctl suspend
systemctl hibernate
systemctl hybrid-sleep
Since hibernate is normally disabled by default in Ubuntu systems, you can enable this by checking this answer: https://askubuntu.com/a/617254/101985
Original source: https://bbs.archlinux.org/viewtopic.php?id=127962
A safe way to do this without using sudo and without tinkering with the system, is by executing these one-liner commands:
For Ubuntu 14.10 or earlier:
Shutdown:
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
Restart:
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
consolekit should of course be installed your system.
Other commands you may like:
Suspend:
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
Hibernate: (if enabled on your system)
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
For Ubuntu 15.04 and later:
(This is due to Ubuntu's shift in using systemd instead of Upstart)
systemctl poweroff
systemctl reboot
systemctl suspend
systemctl hibernate
systemctl hybrid-sleep
Since hibernate is normally disabled by default in Ubuntu systems, you can enable this by checking this answer: https://askubuntu.com/a/617254/101985
Original source: https://bbs.archlinux.org/viewtopic.php?id=127962
edited Apr 13 '17 at 12:23
Communityâ¦
1
1
answered Dec 3 '13 at 8:10
Majal
4,23631832
4,23631832
add a comment |Â
add a comment |Â
up vote
2
down vote
unity uses many gnome services, and in that case too - you can shutdown gnome way.
gnome-session-quit --power-off --force --no-prompt
will do the job.
add a comment |Â
up vote
2
down vote
unity uses many gnome services, and in that case too - you can shutdown gnome way.
gnome-session-quit --power-off --force --no-prompt
will do the job.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
unity uses many gnome services, and in that case too - you can shutdown gnome way.
gnome-session-quit --power-off --force --no-prompt
will do the job.
unity uses many gnome services, and in that case too - you can shutdown gnome way.
gnome-session-quit --power-off --force --no-prompt
will do the job.
answered Dec 30 '15 at 9:33
Ohad Cohen
642412
642412
add a comment |Â
add a comment |Â
up vote
1
down vote
While you can use the method of allowing NOPASSWD on /usr/sbin/shutdown, although another, DE-independent solution is to just use init 0.
add a comment |Â
up vote
1
down vote
While you can use the method of allowing NOPASSWD on /usr/sbin/shutdown, although another, DE-independent solution is to just use init 0.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
While you can use the method of allowing NOPASSWD on /usr/sbin/shutdown, although another, DE-independent solution is to just use init 0.
While you can use the method of allowing NOPASSWD on /usr/sbin/shutdown, although another, DE-independent solution is to just use init 0.
answered Feb 12 '16 at 16:33
UniversallyUniqueID
3,37511641
3,37511641
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f168879%2fshutdown-from-terminal-without-entering-password%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
Does anyone know what command is executed when I click "shutdown" in Desktop Environment?
â kubahaha
Feb 20 '15 at 17:15