You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/systemd/030_systemd_theory.xml
+76-54Lines changed: 76 additions & 54 deletions
Original file line number
Diff line number
Diff line change
@@ -21,17 +21,15 @@ root@debian8:~#</screen>
21
21
<?hard-pagebreak?>
22
22
<section><title>systemd targets</title>
23
23
<para>The first command to learn is <command>systemctl list-units --type=target</command> (or the shorter version <command>systemctl -t target</command>). It will show you the different targets on the system.</para>
cryptsetup.target loaded active active Encrypted Volumes
28
28
getty.target loaded active active Login Prompts
29
-
graphical.target loaded active active Graphical Interface
30
29
local-fs-pre.target loaded active active Local File Systems (Pre)
31
30
local-fs.target loaded active active Local File Systems
32
31
multi-user.target loaded active active Multi-User System
33
32
network.target loaded active active Network
34
-
nfs.target loaded active active Network File System Server
35
33
paths.target loaded active active Paths
36
34
remote-fs.target loaded active active Remote File Systems
37
35
slices.target loaded active active Slices
@@ -44,19 +42,20 @@ LOAD = Reflects whether the unit definition was properly loaded.
44
42
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
45
43
SUB = The low-level unit activation state, values depend on unit type.
46
44
47
-
16 loaded units listed. Pass --all to see loaded but inactive units, too.
45
+
14 loaded units listed. Pass --all to see loaded but inactive units, too.
48
46
To show all installed unit files use 'systemctl list-unit-files'.
49
-
[root@rhel7 ~]#</screen>
47
+
[root@rhel71 ~]#</screen>
50
48
<para>Targets are the replacement of runlevels and define specific points to reach when booting the system. For example the <command>graphical.target</command> is reached when you get a graphical interface, and the <command>nfs.target</command> requires a running nfs server.</para>
51
49
<para>To switch to a target (for example <command>multi-user.target</command>), we now use <command>systemctl isolate</command> (instead of the equivalent <command>init 3</command> to change the runlevel).</para>
52
-
<screen>[root@rhel7 ~]# ps fax | wc -l
50
+
<para>This screenshot shows a <command>Red Hat Enterprise Linux 7</command> server switching from a graphical interface to command line (decreasing the number of running processes).</para>
<para>To change the default target, we again use this <command>systemctl</command> command (instead of editing the <command>/etc/inittab</command> file).</para>
<para>Dependencies are no longer defined by alfabetical order of running scripts, but by configuration in <command>/etc/systemd/system/</command>. For example here are the required services for the <command>multi-user.target</command> on Red Hat Enterprise 7.</para>
69
-
<screen>[root@rhel7 ~]# ls /etc/systemd/system/multi-user.target.wants/
<para>Dependencies are no longer defined by alfabetical order of running scripts, but by configuration in <command>/etc/systemd/system/</command>. For example here are the required services for the <command>multi-user.target</command> on Red Hat Enterprise 7.1.</para>
<para>Below a screenshot from Debian (stretch/sid is Debian 9). There is already a lot of <command>systemd</command> in Debian 8 and 9 (less than in RHEL7).</para>
<para>Typical <command>rc scripts</command> are replaced with services. Issue the <command>systemctl list-units -t service --all</command> (or <command>systemctl -at service</command>) to get a list of all services on your system.</para>
88
-
<screen>[root@rhel7 ~]# systemctl -at service | head -5 | column -t | cut -c1-78
86
+
<screen>[root@rhel7 ~]# <command>systemctl -at service | head -5 | column -t | cut -c1-78</command>
89
87
UNIT LOAD ACTIVE SUB DESCRIPTION
90
88
abrt-ccpp.service loaded active exited Install ABRT coredump
91
89
abrt-oops.service loaded active running ABRT kernel log
92
90
abrt-vmcore.service loaded inactive dead Harvest vmcores for
93
91
abrt-xorg.service loaded active running ABRT Xorg log
94
92
[root@rhel7 ~]#</screen>
95
-
<para>And here an example on how to see the status of the <command>sshd</command> service.</para>
96
-
<screen>[root@rhel7 ~]# systemctl status sshd.service
93
+
</section>
94
+
<?hard-pagebreak?>
95
+
<section><title>service status</title>
96
+
<para>Below is a (truncated) screenshot showing how to see the status of the <command>sshd</command> service. (This RHEL server was attacked using brute force ssh on 2 August 2015.)</para>
97
+
<screen>[root@rhel71 ~]# <command>systemctl status sshd.service</command>
Active: active (running) since Wed 2015-07-29 12:00:10 CEST; 1 weeks 0 days ago
102
+
Main PID: 1123 (sshd)
103
+
CGroup: /system.slice/sshd.service
104
+
└─1123 /usr/sbin/sshd -D
103
105
104
-
Sep 10 13:42:21 rhel7 systemd[1]: Started OpenSSH server daemon.
105
-
Sep 10 13:42:21 rhel7 sshd[1400]: Server listening on 0.0.0.0 port 22.
106
-
Sep 10 13:42:21 rhel7 sshd[1400]: Server listening on :: port 22.
107
-
[root@rhel7 ~]#</screen>
106
+
Aug 02 16:45:24 rhel71 sshd[12704]: Failed password for root from 43.229.53.79
107
+
Aug 02 18:15:28 rhel71 sshd[12872]: pam_unix(sshd:auth): authentication failur
108
+
Aug 02 18:15:28 rhel71 sshd[12872]: pam_succeed_if(sshd:auth): requirement "ui
109
+
Aug 02 18:15:30 rhel71 sshd[12872]: Failed password for root from 43.229.53.79
110
+
Aug 02 18:15:30 rhel71 sshd[12872]: pam_succeed_if(sshd:auth): requirement "ui
111
+
Aug 02 18:15:32 rhel71 sshd[12872]: Failed password for root from 43.229.53.79
112
+
Aug 02 18:15:32 rhel71 sshd[12872]: pam_succeed_if(sshd:auth): requirement "ui
113
+
Aug 02 18:15:34 rhel71 sshd[12872]: Failed password for root from 43.229.53.79
114
+
Aug 02 18:15:34 rhel71 sshd[12872]: Received disconnect from 43.229.53.79: 11:
115
+
Aug 03 10:21:11 rhel71 sshd[14616]: pam_unix(sshd:auth): authentication failur
116
+
Aug 03 10:21:11 rhel71 sshd[14616]: pam_succeed_if(sshd:auth): requirement "ui
117
+
Aug 03 10:21:13 rhel71 sshd[14616]: Failed password for root from 119.188.7.14
118
+
Aug 03 10:21:13 rhel71 sshd[14616]: Received disconnect from 119.188.7.143: 11
119
+
Aug 03 14:20:03 rhel71 sshd[15083]: Accepted password for root from 192.168.1.
120
+
Hint: Some lines were ellipsized, use -l to show in full.
121
+
[root@rhel71 ~]#</screen>
122
+
<para>This <command>systemd</command> feature does not work by default on <command>Debian 8/9</command> because <command>init</command> has pid 1. It only works when the system is booted with <command>systemd</command> as pid 1.</para>
123
+
<screen>root@debian8:~# <command>systemctl status sshd</command>
124
+
Failed to get D-Bus connection: Operation not permitted
125
+
root@debian8:~# <command>systemctl status ssh</command>
126
+
Failed to get D-Bus connection: Operation not permitted
<para>The <command>chkconfig</command> and <command>service</command> commands are considered 'legacy'. They are replaced with <command>systemctl</command>.</para>
112
134
<para>This screenshot shows the new way to start and stop a service.</para>
0 commit comments