LinuxCommandLibrary

systemctl-set-default

Set default system boot target

TLDR

Set systemd's default boot mode

$ systemctl set-default [target_name.target]
copy

Set systemd to boot to GUI mode by default
$ systemctl set-default graphical.target
copy

Set systemd to boot to CLI mode by default
$ systemctl set-default multi-user.target
copy

SYNOPSIS

systemctl set-default UNIT_NAME

PARAMETERS

UNIT_NAME
    The name of the target unit (e.g., graphical.target, multi-user.target) to set as the default system boot target. This unit dictates the system's state upon successful boot. The command creates or modifies a symbolic link at /etc/systemd/system/default.target pointing to this unit.

DESCRIPTION

The systemctl set-default command is used to configure systemd's default boot target for the system. This command creates or modifies a symbolic link at /etc/systemd/system/default.target, pointing it to the specified UNIT_NAME.

The chosen target unit determines the initial state of the system after a reboot, such as whether it boots into a graphical login interface (graphical.target), a multi-user command-line interface (multi-user.target), or a specific recovery mode. This change is persistent across reboots, ensuring the system consistently starts in the desired state.

While set-default configures the target for future boots, it does not immediately change the system's current state. To temporarily change the running target, one would use systemctl isolate. The current default target can be queried using systemctl get-default.

CAVEATS

  • This command requires root privileges to modify system configuration.
  • Using an incorrect or non-existent target can render the system unbootable or lead to unexpected behavior. Always verify target existence and functionality before setting it as default.
  • This command sets the default for subsequent boots; it does not change the current running target. Use systemctl isolate UNIT_NAME for an immediate, temporary change.
  • The change made by set-default is persistent across reboots.

COMMON TARGET UNITS

Systemd defines several standard target units that are frequently used with set-default:

  • graphical.target: Boots into a multi-user system with a graphical login interface enabled. This is often the desired default for desktop workstations.
  • multi-user.target: Boots into a multi-user system with a command-line login interface (text console), without starting a graphical environment. Common for servers or systems where a GUI is not needed.
  • rescue.target: Provides a rescue shell, mounts local filesystems, but typically doesn't start normal system services. It's useful for system repair and maintenance.
  • emergency.target: Provides a minimal shell environment, often with the root filesystem mounted read-only. Used for dire emergency repairs when rescue.target is insufficient.

VERIFICATION

After using systemctl set-default, you can immediately verify that your change has been registered by running systemctl get-default. This command will output the name of the target unit that is currently configured as the system's default boot target, confirming your change.

HISTORY

The systemctl set-default command is an integral part of the systemd init system, which has largely replaced older init systems like SysVinit and Upstart in many modern Linux distributions. Prior to systemd, managing default boot targets (often referred to as 'runlevels') involved modifying files like /etc/inittab or manually creating symbolic links. The introduction of systemctl with its `set-default` subcommand provided a standardized, declarative, and more robust method for managing these critical boot configurations within the systemd framework, improving consistency and reducing manual error potential.

SEE ALSO

systemctl(1), systemctl get-default(1), systemctl isolate(1), systemd.target(5), bootup(7)

Copied to clipboard