So Linux has this concept of run levels. Basically, a run level represents the state of the machine. Here’s a quick list of the run levels available.
Run Level |
Name |
Description |
0 |
Halt | Immediately shuts down the system |
1 |
Single User Context | Brings system into single user mode for maintenance |
2 |
User Defined | N/A |
3 |
Multi-User Console only | System up and running normally in console mode |
4 |
User Defined | N/A |
5 |
Multi-User with GUI and console | System up and running normally in console or GUI mode |
6 |
Reboot | Immediately reboots the system |
So if you want to shutdown the system you can issue a ‘init 0’. Same goes for a reboot (init 6). To set what you want the machine to do on boot you can change the initdeafult command in /etc/inittab to reflect the run level you want on boot. Usually this only changes between 3 and 5 as far as I can tell.