Linux systemd brief description and run level settings (Linux mint18)

background

       My computer is a small Shenzhou notebook (dual-core, four-threaded, 2G memory) more than 10 years ago. Windows can’t drive it, but Linux can’t help it. In order to make the system faster, I studied setting the run level to terminal mode (without graphics). interface).

       YOU

jwllinux@jwlLinux ~ $  lsb_release -a

LSB Version:    core-9.20160110ubuntu0.2-ia32:core-9.20160110ubuntu0.2-noarch:cxx-3.0-ia32:cxx-3.0-noarch:cxx-3.1-ia32:cxx-3.1-noarch:cxx-3.2-ia32:cxx-3.2-noarch:cxx-4.0-ia32:cxx-4.0-noarch:cxx-4.1-ia32:cxx-4.1-noarch:security-9.20160110ubuntu0.2-ia32:security-9.20160110ubuntu0.2-noarch

Distributor ID: LinuxMint

Description:    Linux Mint 18 Sarah

Release:        18

Codename:       sarah

CPU

jwllinux@jwlLinux /lib/systemd/system $ lscpu

Architecture:          i686

CPU op-mode(s):        32-bit, 64-bit

Byte Order:            Little Endian

CPU(s):                4

On-line CPU(s) list:   0-3

Thread(s) per core:    2

Core(s) per socket:    2

Socket(s):             1

RAM

jwllinux@jwlLinux /lib/systemd/system $ cat /proc/meminfo | grep -i memtotal | awk -F " " '{print $2/1024/1024 "GB"}'

1.89236GB

Systemd in brief

       I believe many people know that the initial Linux startup process No. 1 was initd, which later developed into systemd. Systemd provides a complete set of solutions for system startup and management. Its structure is as follows:

 

the term:

Uint: A resource unit managed by Systemd is Unit;

Target: A group of managed Units is Target; when a target is started, systemd will start a group of Uints related to each other according to the configuration file of the corresponding target (for example, runlevel6.target);

Related commands

       Systemd is a set of system startup and management solutions, so there are many related commands and many parameters. Fortunately, the project team provides the systemd.index help manual, you can check all the manpages of the systemd project, please refer to man systemd.index.

Common commands that are more relevant to this article are:

  • Get the default startup target

jwlLinux system # systemctl  get-default

multi-user.target

  • Get the current start level (prints the previous and current SysV runlevel if they are known.)

jwlLinux system # runlevel

N 3

Startup level description:

       The operating level of the Linux system is divided into seven levels, which are represented by 0~6;

Runlevel

Target

Brief description

0

poweroff.target

Shut down

1

rescue.target

Safe mode

2, 3, 4

multi-user.target

Multi-user terminal mode

5

graphical.target

Graphics mode

6

reboot.target

Restart mode

  • Set the default startup level

jwlLinux system # systemctl  set-default runlevel3.target

Removed symlink /etc/systemd/system/default.target.

Created symlink from /etc/systemd/system/default.target to /lib/systemd/system/multi-user.target.

说明:

       从上面的日志可以看出(实际也是),systemd的默认配置目录为/etc/systemd/system/(系统管理模块)。但此目录的文件大部分是符号链接,直接的文件内容在/lib/systemd/system/目录;

jwlLinux system # ls -rlht /etc/systemd/system/default.target

lrwxrwxrwx 1 root root 37 Nov 27 14:35 /etc/systemd/system/default.target -> /lib/systemd/system/multi-user.target

 

  • 命令行模式下如何实现本地登录?

在设置runlevel为终端模式并重启后,读者会发现系统起来后全为黑屏,那该如何登录到自己的系统呢?有如下两种方式:

  1. ssh远程登录
  2. ttyN控制台终端(通过快捷键ctrl + alt + F1~F5唤醒)

其他系统说明

  1. Redhat 7以前的一号进程是initd,其相关配置为:

/etc/inittab

  1. Redhat7开始到后面也是使用systemd作为1号进程;

参考文献:

Systemd 入门教程:命令篇

Guess you like

Origin blog.csdn.net/zhaogang1993/article/details/110245652