Showing posts with label systemd. Show all posts
Showing posts with label systemd. Show all posts

Jun 8, 2022

Switch Between CLI and GUI

How to change between the cmdline interface and the GUI by editing the boot target.

First, we no longer use the runlevel term. Instead, we refer to boot choices as targets. The 2 primary targets here: multi-user.target (the CLI or runlevel 3 in legacy) and the graphical.target (the GUI or runlevel 5 in legacy).


To identify the current target:

$ sudo systemctl get-defeault


To launch GUI from the multi-user.target:

$ sudo systemctl isolate graphical.target

And to switch back to CLI mode:

$ sudo systemctl usolate multi-user.target


To set a default target

$ sudo systemctl  set-default multi-user.target


To reboot and confirm the appropriate target:

$ sudo systemctl reboot


Target Files

Targets are managed by .target files that simply group units and dependencies into a convenient format. It;s really the .unit files that define exactly what services and other features start when the target is initiated.

$ sudo systemctl enable sshd

$ sudo systemctl disable sshd

 

Links:

Apr 29, 2022

Linux Run Levels

Linux changes the run-level:

  • (Old Linux distro) SysV init uses run-level number from 0 to 6.
    • cmdline: init, telinit, who
  • (New Linux distro) systemd init uses systemd targets.
    • cmdline: systemctl 

 

Linux runlevel defines the state of the OS. 

SysV Systemd targetsDescription
0
runlevel0.target
poweroff.target
Halt or shutdown the Linux system
1    
runlevel1.target
rescue.target
Single-user text mode (useful for maintenance mode)
2 runlevel2.target
multi-user.target
Not used
3 runlevel3.target
multi-user.target
Full multi-user text mode (used on Linux servers)
4 runlevel4.target
multi-user.target
Not used
5 runlevel5.target
graphical.target
Full multi-user GUI mode. You can use X-based login screen. Useful for Linux desktop
6 runlevel6.target
reboot.target
Reboot Linux system


Comparing the cmdline used.

SysV Systemd Description
runelvel
who -r
systemctl get-default
Show the current runlevel
init 1
systemctl rescue
systemctl emergency
Change the runlevel to single user mode for maintenance
init 3
systemctl multi-user-target Change to multi-user text mode
init 0
systemctl poweroff Poweroff
init 6
systemctl reboot
Reboot

systemctl default Back to default target
init 5
systemctl graphical.target
Change to GUI mode


Links:

  • https://www.cyberciti.biz/tips/linux-changing-run-levels.html