Linux Tutorials - Herong's Tutorial Examples - v5.45, by Herong Yang
"systemctl status/start/stop/enable/disable" Commands
This section provides a quick introduction of the 'systemctl' command, which allows you to start or stop a system service, check the status of a service, and enable or disable a service at the boot time.
What Is "systemctl" Command? "systemctl" is a command to interact with "systemd", the system and service manager.
The most common tasks you can perform with the "systemctl" command are:
1. "systemctl status service_name" - To check the status of a given service. By the way, the ".service" postfix of a service name can be omitted when specifying the service name.
herong$ sudo systemctl status cockpit
* cockpit.service - Cockpit Web Service
Loaded: loaded (/usr/lib/systemd/system/cockpit.service; static; ...
Active: active (running) since Tue ...
Docs: man:cockpit-ws(8)
Process: 7282 ExecStartPre=/usr/sbin/remotectl certificate --ensure ...
Main PID: 7285 (cockpit-ws)
Tasks: 2 (limit: 26213)
Memory: 1.5M
CGroup: /system.slice/cockpit.service
|-7285 /usr/libexec/cockpit-ws
localhost.localdomain systemd[1]: Starting Cockpit Web Service...
localhost.localdomain systemd[1]: Started Cockpit Web Service.
localhost.localdomain cockpit-ws[7285]: Using certificate: \
/etc/cockpit/ws-certs.d/0-self-signed.cert
systemctl status cockpit.service
(same output as above)
2. "systemctl start service_name" - To start a given service.
3. "systemctl stop service_name" - To stop a given service.
4. "systemctl enable service_name" - To enable a given service at system boot time.
herong$ sudo systemctl enable cockpit.socket Created symlink /etc/systemd/system/sockets.target.wants/cockpit.socket -> /usr/lib/systemd/system/cockpit.socket.
5. "systemctl disable service_name" - To disable a given service at system boot time. The "disabled" status of the service file will be displayed in the "systemctl status" command output.
herong$ sudo systemctl disable cockpit.socket
Removed /etc/systemd/system/sockets.target.wants/cockpit.socket.
herong$ systemctl status cockpit.socket
* cockpit.socket - Cockpit Web Service Socket
Loaded: loaded (/usr/lib/systemd/system/cockpit.socket; disabled; ...
Active: inactive (dead)
Docs: man:cockpit-ws(8)
Listen: [::]:9090 (Stream)
5. "systemctl --all list-units" - To list all services, including inactive ones. The output bellow shows 457 services with different statuses on my CentOS computer.
herong$ systemctl --all list-units | wc
457 3173 106109
herong$ systemctl --all list-units
UNIT LOAD ACTIVE SUB DESCRIPTION
dev-block-8:19.device loaded active plugged TOSHIBA_DT01ACA2 primary
dev-cl-home.device loaded active plugged /dev/cl/home
-.mount loaded active mounted Root Mount
boot.mount loaded active mounted /boot
firewalld.service loaded active running firewalld - dynamic ...
nfs-mountd.service loaded active running NFS Mount Daemon
nfs-server.service loaded active exited NFS server and services
nfs-utils.service loaded inactive dead NFS server and client ...
* ypserv.service not-found inactive dead ypserv.service
...
6. "systemctl --all list-unit-files" - To list all service definition file.
herong$ systemctl list-unit-files | wc
496 993 26206
herong$ systemctl list-unit-files *httpd*
NIT FILE STATE
boot.mount generated
dev-mqueue.mount static
home.mount generated
cockpit.service static
console-getty.service disabled
crond.service enabled
sssd-sudo.service indirect
...
Table of Contents
Cockpit - Web Portal for Administrator
SELinux - Security-Enhanced Linux
SSH Protocol and ssh/scp Commands
Software Package Manager on CentOS - DNF and YUM
vsftpd - Very Secure FTP Daemon
LDAP (Lightweight Directory Access Protocol)
►"systemctl status/start/stop/enable/disable" Commands
"shutdown" and "halt/poweroff/reboot" Commands
Move /home Directory to New Partition
Move All Users to a New System