• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer

The Geek Diary

HowTos | Basics | Concepts

  • Solaris 11
  • Solaris
    • SVM
    • ZFS
    • Zones
    • LDOMs
    • Hardware
  • Linux
    • CentOS/RHEL 7
    • RHCSA notes
    • SuSE Linux Enterprise
    • Linux Services
  • VxVM
  • VCS
  • Interview Questions
  • oracle
    • ASM
    • mysql
    • RAC
    • oracle 12c
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting

CentOS / RHEL 7 : How to change runlevels (targets) with systemd

By admin

Systemd has replaced sysVinit as the default service manager in RHEL 7. Some of the sysVinit commands have been symlinked to their RHEL 7 counterparts, however this will eventually be deprecated in favor of the standard systemd commands in the future.

SysVinit V/s systemd runlevels

Here is a comparison between SysVinit runlevels V/s systemd targets.

Sysvinit Runlevel Systemd Target Function
0 runlevel0.target, poweroff.target System halt/shutdown
1, s, single runlevel1.target, rescue.target Single-user mode
2, 4 runlevel2.target, runlevel4.target, multi-user.target User-defined/Site-specific runlevels. By default, identical to 3.
3 runlevel3.target, multi-user.target Multi-user, non-graphical mode, text console only
5 runlevel5.target, graphical.target Multi-user, graphical mode
6 runlevel6.target, reboot.target Reboot
emergency emergency.target Emergency mode

Changing runlevels with systemd

The runlevel target can be changed by using the systemctl isolate command :

# systemctl isolate multi-user.target

To view what targets are available you can issue the list-units option with the type target

# systemctl list-units --type=target

Run level 3 is emulated by multi-user.target. This is done by symbolic link and can be used interchangeably

# systemctl isolate multi-user.target
# systemctl isolate runlevel3.target
# ls -l /usr/lib/systemd/system/runlevel3.target
lrwxrwxrwx 1 root root 17 Oct 18 11:41 /usr/lib/systemd/system/runlevel3.target -> multi-user.target

Run level 5 is emulated by graphical.target. This is also done by symbolic link and can be used interchangeably

# systemctl isolate graphical.target
# systemctl isolate runlevel5.target
# ls -l /usr/lib/systemd/system/runlevel5.target
lrwxrwxrwx 1 root root 16 Oct 18 11:41 /usr/lib/systemd/system/runlevel5.target -> graphical.target

Changing the default runlevel

The default runlevel can be changed by using the set-default option.

# systemctl set-default multi-user.target

To get the currently set default, you can use the get-default option.

# systemctl get-default

The default runlevel in systemd can also be set using the below method (not recommended though).

# ln -sf /lib/systemd/system/[desired].target /etc/systemd/system/default.target

The default target can also be set in the kernel line during boot by adding the following option :

systemd.unit=multi-user.target

Filed Under: CentOS/RHEL 7

Some more articles you might also be interested in …

  1. How to install and configure sosreport under CentOS / RHEL
  2. How to Enable X11 Forwarding on CentOS/RHEL 5,6,7
  3. Understanding SELinux Policies in Linux
  4. CentOS / RHEL 7 : How to add a kernel parameter only to a specific kernel
  5. CentOS / RHEL 7 : How to install and configure telnet
  6. CentOS / RHEL 7 : How to setup yum repository using locally mounted DVD
  7. How to configure iSCSI target using targetcli in CentOS / RHEL 7
  8. How to create partitions inside loopback device
  9. How to make ethtool settings persistent across reboots in CentOS / RHEL 6,7
  10. CentOS / RHEL 7 : How to open the Firewall port for Samba server using FirewallD

You May Also Like

Primary Sidebar

Recent Posts

  • Linux OS Service ‘smartd’
  • Oracle SQL script to Show current Users and SQL being Executed
  • How to use qperf to measure network bandwidth and latency performance in Linux
  • How to Password Protect GRUB2 in Oracle Enterprise Linux 7
  • How to move or rename a datafile in the same ASM diskgroup (Using ASM alias)

Footer

Cheat Sheets

  • LDOMs (OVM for SPARC) Command line reference
  • Solaris Volume Manager (SVM) command line reference
  • Solaris ZFS command line reference
  • RHEL 7 – RHCSA Notes (Cheat Sheets)
  • CentOS / RHEL 7 : firewalld Cheat Sheet
  • systemd command line reference (cheat sheet)

Solaris interview questions

  • The ultimate Solaris Volume Manager (SVM) interview questions
  • The ultimate Solaris zones (containers) interview questions
  • The ultimate Solaris networking interview questions
  • The ultimate ZFS interview questions
  • Archives
  • Contact Us
  • Copyright

© 2018 · The Geek Diary