FreeBSD or BSD reboot and shutdown system

last updated in Categories , ,

I am a new FreeBSD server user. How do I reboot or shutdown a FreeBSD based system? I tried shutdown -h 0 command. However, is not working for me on my BSD based system. How can I shutdown or reboot the server?

FreeBSD or other BSD families of operating systems use the shutdown or halt command to shutdown system. Use the reboot command to reboot the FreeBSD based system.

Shutdown FreeBSD command

Use the shutdown commandto close down the system at a given time. Type following command to shutdown system immediately. You must login as root user:
$ su -
or
$ sudo -i
Now shutdown the system at a given time:
# shutdown -h now
OR
# halt
The -h option passed to halt the system. The time is the time at which shutdown ill bring the BSD system down and may be the case-insensitive word now (indicating an immediate shutdown) or a future time in one of two formats:

  1. +number – The first form brings the system down in number minutes and the second at the absolute time specified. +number may be specified in units other than minutes by appending the corresponding suffix: s/sec, m/min, and h/hour.
  2. yymmddhhmm - Where the year, month,and day may be defaulted to the current system values.

Halt the FreeBSD system in 10 minutes and show a warning message:
# shutdown -h +10 "System will shutdown for motherboard replacement."

Reboot BSD system

Type the following command as superuser/root user:
# reboot
OR
# shutdown -r now
The -r option to reboot the system at the specified time. Again you can specify time using the +number or yymmddhhmm format.

FreeBSD reboot the system

Say you want to reboot in 60 minutes and also need to display a warning message for all users currently logged in via ssh or other terminals. Therefore, try the following syntax:
# shutdown -r +60 "System will reboot for system ram upgrades."

shutdown command options for FreeBSD

  1. -h - The BSD system is halted at the specified time.
  2. -p - The FreeBSD system is shutodwn and the power is turned off (hardware support required) at the specified time.
  3. -r - The system is rebooted at the specified time.
  4. -k - Kick everybody off. The -k option does not actually halt the system, but leaves the system multi-user with logins disabled (for all but super-user).
  5. -o - If one of the -h, -p or -r options are specified, shutdown will execute halt(8) or reboot(8) instead of sending a signal to init(8).
  6. -n - If the -o option is specified, prevent the file system cache from being flushed by passing -n to halt(8) or reboot(8). This option should probably not be used.

Getting help on shutdown command

Simply type the following man command
man shutdown
man halt
man reboot

A note about Permission denied and other error messages

You will get an error message that read as "permission denied" or "operation not permitted" on FreeBSD. To avoid these error messages always run shutdown and reboot command as the root user:
FreeBSD shutdown and reboot command

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at www.nixcraft.com

Historical Comment Archive

4 comment

  1. When I did it closes all the programs and just hangs and say press the space bar to restart?

    Is there a more powerfull command that can shutdown the system right away?

  2. Yes I am root in my case and the computer stays on and with the press enter to reboot, what if I (to conserve energy) just want to shut it off for good…

    Still, have a question? Get help on our forum!