What are the different runlevels in Linux and their purposes?

Beginner

Answer

Runlevels define different system states and determine which services are running:

  • 0: Halt/Shutdown - System shutdown
  • 1: Single-user mode - Minimal system for maintenance
  • 2: Multi-user mode without networking
  • 3: Multi-user mode with networking (text mode)
  • 4: Unused/User-defined
  • 5: Multi-user mode with GUI
  • 6: Reboot - System restart
# Check current runlevel
runlevel
who -r

# Change runlevel
init 3          # Switch to text mode
systemctl isolate multi-user.target  # SystemD equivalent

Modern systems use SystemD targets instead of traditional runlevels, but the concept remains similar.