CentOS 7 Bird Private Cabbage/etc/init.d/* and service Command Alternative Method: System CTL

Keywords: Vmware Linux network CentOS

When I was learning Linux, I read from Uncle Bird's book, / etc/init.d/ there are many related services in the directory, but when I go to my init.d directory, there are only a few poor files...

# ll /etc/init.d/
total 92
-rw-r--r--. 1 root root 15131 Sep 12  2016 functions
-rwxr-xr-x. 1 root root  2989 Sep 12  2016 netconsole
-rwxr-xr-x. 1 root root  6643 Sep 12  2016 network
-rw-r--r--. 1 root root  1160 Nov  7  2016 README
-rwxr-xr-x. 1 root root 44903 Jul  8 14:50 vmware-tools
-rwxr-xr-x. 1 root root 15721 Jul  8 14:50 vmware-tools-thinprint

Ah It's not quite like the list in Uncle Bird's book. Well, maybe because of the version of CentOS, who knows?

Later, I introduced the use of / etc/init.d /* and service control services, and then I and Uncle Bird painting style is different...

This is Uncle Bird's:

[root@www ~]# /etc/init.d/syslog status
 syslogd (pid 4264) is in progress.
klogd (pid 4267) is in progress.
# manages two daemons on behalf of syslog, and these two daemons are in operation!

[root@www ~]# /etc/init.d/syslog restart
 Closing Core Recorder: [OK]
Closing System Recorder: [OK]
Booting System Recorder: [OK]
Starting Core Recorder: [OK]

[root@www ~]# service crond restart
[root@www ~]# /etc/init.d/crond restart
 # Either way you can handle it! Brother Bird prefers to use it.
/etc/init.d/*

This is my QAQ:

[root@localhost ~]# /etc/init.d/syslog status
-bash: /etc/init.d/syslog: No such file or directory
[root@localhost ~]# /etc/init.d/syslog restart
-bash: /etc/init.d/syslog: No such file or directory
[root@localhost ~]# service crond restart
Redirecting to /bin/systemctl restart  crond.service
[root@localhost ~]# /etc/init.d/crond restart
-bash: /etc/init.d/crond: No such file or directory
[root@localhost ~]# 

After a while, I found the command / bin / system CTL at the prompt of service, and decisively entered the man page to see:

NAME
   systemctl - Control the systemd system and service manager

SYNOPSIS
       systemctl [OPTIONS...] COMMAND [NAME...]

DESCRIPTION
       systemctl may be used to introspect and control the state of the "systemd" system and service manager. Please refer to systemd(1) for an introduction into the basic concepts and functionality this
       tool manages.

Then I went online and looked at it again. It seemed that this command was used to replace the / etc/init.d /* and service commands. I tried it according to the operation, and it felt good.

[root@localhost ~]# systemctl status rsyslog
● rsyslog.service - System Logging Service
   Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2017-07-14 12:41:22 CST; 52min ago
 Main PID: 8003 (rsyslogd)                        ==>Be careful PID
   CGroup: /system.slice/rsyslog.service
           └─8003 /usr/sbin/rsyslogd -n

Jul 14 12:41:22 localhost.localdomain systemd[1]: Starting System Logging Service...
Jul 14 12:41:22 localhost.localdomain systemd[1]: Started System Logging Service.
[root@localhost ~]# systemctl restart rsyslog
[root@localhost ~]# systemctl status rsyslog
● rsyslog.service - System Logging Service
   Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2017-07-14 13:34:15 CST; 1s ago
 Main PID: 9472 (rsyslogd)                        ==>After reboot PID Changed
   CGroup: /system.slice/rsyslog.service
           └─9472 /usr/sbin/rsyslogd -n

Jul 14 13:34:15 localhost.localdomain systemd[1]: Starting System Logging Service...
Jul 14 13:34:15 localhost.localdomain systemd[1]: Started System Logging Service.

If there are no parameters, enter system CTL directly, and the details of each service will be output. Of course, Service - status-all can also display service information, but there seems to be no details of the former.

Part of the code is quoted from "Basic Learning Chapter on Private Cabbage of Brother Bird (Third Edition)"

Posted by kansaschuck on Fri, 14 Dec 2018 08:36:03 -0800