shutdown via command line

uhh…When I type shutdown -r now I get this

-bdmf:~> sudo shutdown -r now
root's password:
sudo: shutdown: command not found

do I need to download a library of commands for bash?

try su - should sort that

Andy

Try

sudo /sbin/shutdown -r now

When you run sudo you are still using your $PATH which usually doesn’t have /sbin in it. On some distros, like Ubuntu, it does, which is why it may work there without the /sbin for you.

In any case, if you intend to allow this in sudoers, you will need to specify the full path for shutdown.

If that doesn’t work, try:

su -c ‘shutdown -r now’

Simply enter the root password when prompted and that will reboot your system.

:slight_smile:

got it,thanks guys!

I never saw this way to shutdown. Could you say something more about it in detail, please? Thanks!

> I never saw this way to shutdown. Could you say something more about it
> in detail, please? Thanks!

he said:

Code:

su -c ‘shutdown -r now’

which shuts down your computer…the first part

Code:

su -c

is a command used at the user’s command line to Switch User (su)
the command’s “-c” specifies that after switching user, the shell
will THEN run the following command…

that following command in THIS case is

Code:

shutdown -r now

which is a command root can use to Reboot (-r) or Halt (-h) the
system now, or at some later time…

in a terminal, see man shutdown for MORE on that command…

see man su for more on that command

SUSE is a pretty OS when run like most folks run Windows[tm], but it
is AWESOME the way geeks use the CLI (command line interface)

join the fun.
:peace:

DenverD (Linux Counter 282315) via NNTP, Thunderbird 2.0.0.14, KDE
3.5.7, SUSE Linux 10.3, 2.6.22.18-0.2-default #1 SMP i686 athlon

shutdown -r now -> this is not a shutdown, this restarts the pc, no ?

To reboot, use the command reboot
To shutdown the pc, use the command halt

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

‘man reboot’

halt apparently sends ‘shutdown -h’
reboot apparently sends ‘shutdown -r’

Good luck.

LRE wrote:
> shutdown -r now → this is not a shutdown, this restarts the pc, no ?
>
> To reboot, use the command reboot
> To shutdown the pc, use the command halt
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIsG1O3s42bA80+9kRAlYhAJ4oEszwLKK6sGS8SfOnuJY6QzjRkACfR/HF
/PFIBLCDlnimt1mT3NM9nr0=
=Y1vj
-----END PGP SIGNATURE-----

I have always used

"init 0" or "sudo init 0"

which will shut the pc down. I have only had to use sudo on Ubuntu. but that command has worked for me for 4 different distros

i have a problem with shutting down the computer via command line, too (openSUSE 11.1 gnome):
‘sudo shutdown -P +m’ - does not work.
‘su shutdown -P +m’ - does not work either.

  • the command does not shut the system down, i see something like recovery mode prompting to enter root’s password. then i reboot with ctrl+alt+delete.
    i’ve found somewhere that one has to add ‘acpi-force’ in boot configuration or ‘acpi-power-off’ - i’ve tried both, but ‘su shutdown -P +m’ did not work anyway.
    how can i shut the system down after a period of time from command line?

-t sec Tell init(8) to wait sec seconds between sending processes the warning and the kill signal, before changing to another run-level.

su -c shutdown -P -t 120

thank you.
this worked for me - ‘su shutdown -h +m’. things proved to be simplier then i thought.