Understanding and Changing Runlevels in Systemd

Understanding the Initialization Process

  • Unix System V also called SysV
  • Upstart
  • Systemd

What Is Systemd?

Runlevels Explained

The Different Runlevels

  • The S and s are synonymous with runlevel 1 as far as many utilities are concerned
  • Runlevels 0, 1, and 6 are reserved for special purposes
  • The remaining runlevels are available for whatever purposes you can decide
  • Runlevel 0 or Halt is used to shift the computer from one state to another. It shut down the system.
  • Runlevel 1, s, S or Single-User Mode is used for administrative and recovery functions. It has only enough daemons to allow one user (the root user) to log in and perform system maintenance tasks. All local file systems are mounted. Some essential services are started, but networking remains disabled.
  • Runlevel 2 or Multi-user Mode is used for most daemons running and allows multiple users the ability to log in and use system services but without networking. On Debian and its derivatives, a full multi-user mode with X running and a graphical login. Most other distributions leave this runlevel undefined.
  • Runlevel 3 or Extended Multi-user Mode is used for a full multi-user mode with a console (without GUI) login screen with network services available
  • Runlevel 4 is not normally used and undefined so it can be used for a personal customization
  • Runlevel 5 or Graphical Mode is same as Runlevel 3 with graphical login _(such as GDN)_.
  • Runlevel 6 or Reboot is a transitional runlevel to reboot the system.

Changing Runlevels

$ runlevel
N 5
$ sudo telinit 3
$ runlevel
5 3

Target in Systemd

The Different Targets

  • poweroff.target (runlevel 0): shutdown and power off the system
  • rescue.target (runlevel 1): launch the rescue shell session
  • multi-user.target (runlevel 2,3,4): set the system in non graphical (console) multi-user system
  • graphical.target (runlevel 5): use a graphical multi-user system with network services
  • reboot.target (runlevel 6): shutdown and reboot the system

Changing a Target

$ systemctl list-units --type target
UNIT LOAD ACTIVE SUB DESCRIPTION
basic.target loaded active active Basic System
cryptsetup.target loaded active active Local Encrypted Volumes
getty.target loaded active active Login Prompts
graphical.target loaded active active Graphical Interface
local-fs-pre.target loaded active active Local File Systems (Pre)
local-fs.target loaded active active Local File Systems
multi-user.target loaded active active Multi-User System
network-online.target loaded active active Network is Online
network.target loaded active active Network
nss-lookup.target loaded active active Host and Network Name Lookups
nss-user-lookup.target loaded active active User and Group Name Lookups
paths.target loaded active active Paths
remote-fs.target loaded active active Remote File Systems
slices.target loaded active active Slices
sockets.target loaded active active Sockets
sound.target loaded active active Sound Card
swap.target loaded active active Swap
sysinit.target loaded active active System Initialization
time-sync.target loaded active active System Time Synchronized
timers.target loaded active active Timers

LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.

20 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
$ sudo systemctl isolate multi-user.target
$ systemctl list-units --type target --all 
UNIT LOAD ACTIVE SUB DESCRIPTION
● all.target not-found inactive dead all.target
basic.target loaded active active Basic System
cryptsetup.target loaded active active Local Encrypted Volumes
emergency.target loaded inactive dead Emergency Mode
getty-pre.target loaded inactive dead Login Prompts (Pre)
getty.target loaded active active Login Prompts
graphical.target loaded inactive dead Graphical Interface
$ systemctl get-default
graphical.target
$ sudo systemctl set-default rescue.target
Created symlink /etc/systemd/system/default.target → /lib/systemd/system/rescue.target.

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to Perform P2V and V2V Migration with VMware Converter

Refactoring code: single class operating on too many abstraction layers

Create Your First Servlet Web App

Connecting to GitHub with SSH

3 ways to backup your DigitalOcean Droplets & Volumes more frequently

UX Case Study: Women In Web Dev

How to Install Suricata IDS on Ubuntu 16.04

Updated Mac Setup

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

#[Clymene] time series data collection platform for distributed systems — official release

Http PUT vs PATCH On high level, both PUT and PATCH are used to modify a resource denoted by the…

INTEGRATION OF LVM PARTITION WITH HADOOP CLUSTER

BYO Certs for TKG 1.4.1+ Auth