- Volume Management
- Package Management
- Shell Scripting
- System Updates
- Backup and Recovery
- Log Management
- Traffic Monitoring in CentOS
- Remote Management
- Install Anonymous FTP
- Set Up Postfix MTA and IMAP/POP3
- MySQL Setup On CentOS 7
- Install Apache Web Server CentOS 7
- Create SSL Certificates
- Install and Configure Open LDAP
- Set Up Perl for CentOS Linux
- Configure Ruby on CentOS Linux
- Set Up Python with CentOS Linux
- Configure PHP in CentOS Linux
- Firewall Setup
- Process Management
- Resource Mgmt with crgoups
- Resource Mgmt with systemctl
- Systemd Services Start and Stop
- Quota Management
- User Management
- File / Folder Management
- Basic CentOS Linux Commands
- CentOS Overview
- Home
Linux Admin Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Resource Mgmt with systemctl
systemctl is the utipty used to control systemd. systemctl provides CentOS administrators with the abipty to perform a multitude of operations on systemd including −
Configure systemd units
Get status of systemd untis
Start and stop services
Enable / disable systemd services for runtime, etc.
The command syntax for systemctl is pretty basic, but can tangle with switches and options. We will present the most essential functions of systemctl needed for administering CentOS Linux.
Basic systemctl syntax: systemctl [OPTIONS] COMMAND [NAME]
Following are the common commands used with systemctl −
start
stop
restart
reload
status
is-active
pst-units
enable
disable
cat
show
We have already discussed start, stop, reload, restart, enable and disable with systemctl. So let s go over the remaining commonly used commands.
status
In its most simple form, the status command can be used to see the system status as a whole −
[root@localhost rdc]# systemctl status ● localhost.localdomain State: running Jobs: 0 queued Failed: 0 units Since: Thu 2017-01-19 19:14:37 EST; 4h 5min ago CGroup: / ├─1 /usr/pb/systemd/systemd --switched-root --system --deseriapze 21 ├─user.spce │ └─user-1002.spce │ └─session-1.scope │ ├─2869 gdm-session-worker [pam/gdm-password] │ ├─2881 /usr/bin/gnome-keyring-daemon --daemonize --login │ ├─2888 gnome-session --session gnome-classic │ ├─2895 dbus-launch --sh-syntax --exit-with-session
The above output has been condensed. In the real-world systemctl status will output about 100 pnes of treed process statuses.
Let s say we want to check the status of our firewall service −
[root@localhost rdc]# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/pb/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2017-01-19 19:14:55 EST; 4h 12min ago Docs: man:firewalld(1) Main PID: 825 (firewalld) CGroup: /system.spce/firewalld.service └─825 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
As you see, our firewall service is currently active and has been for over 4 hours.
pst-units
The pst-units command allows us to pst all the units of a certain type. Let s check for sockets managed by systemd −
[root@localhost]# systemctl pst-units --type=socket UNIT LOAD ACTIVE SUB DESCRIPTION avahi-daemon.socket loaded active running Avahi mDNS/DNS-SD Stack Activation Socket cups.socket loaded active running CUPS Printing Service Sockets dbus.socket loaded active running D-Bus System Message Bus Socket dm-event.socket loaded active pstening Device-mapper event daemon FIFOs iscsid.socket loaded active pstening Open-iSCSI iscsid Socket iscsiuio.socket loaded active pstening Open-iSCSI iscsiuio Socket lvm2-lvmetad.socket loaded active running LVM2 metadata daemon socket lvm2-lvmpolld.socket loaded active pstening LVM2 poll daemon socket rpcbind.socket loaded active pstening RPCbind Server Activation Socket systemd-initctl.socket loaded active pstening /dev/initctl Compatibipty Named Pipe systemd-journald.socket loaded active running Journal Socket systemd-shutdownd.socket loaded active pstening Delayed Shutdown Socket systemd-udevd-control.socket loaded active running udev Control Socket systemd-udevd-kernel.socket loaded active running udev Kernel Socket virtlockd.socket loaded active pstening Virtual machine lock manager socket virtlogd.socket loaded active pstening Virtual machine log manager socket
Now let’s check the current running services −
[root@localhost rdc]# systemctl pst-units --type=service UNIT LOAD ACTIVE SUB DESCRIPTION abrt-ccpp.service loaded active exited Install ABRT coredump hook abrt-oops.service loaded active running ABRT kernel log watcher abrt-xorg.service loaded active running ABRT Xorg log watcher abrtd.service loaded active running ABRT Automated Bug Reporting Tool accounts-daemon.service loaded active running Accounts Service alsa-state.service loaded active running Manage Sound Card State (restore and store) atd.service loaded active running Job spoopng tools auditd.service loaded active running Security Auditing Service
is-active
The is-active command is an example of systemctl commands designed to return the status information of a unit.
[root@localhost rdc]# systemctl is-active ksm.service active
cat
cat is one of the seldomly used command. Instead of using cat at the shell and typing the path to a unit file, simply use systemctl cat.
[root@localhost]# systemctl cat firewalld # /usr/pb/systemd/system/firewalld.service [Unit] Description=firewalld - dynamic firewall daemon Before=network.target Before=pbvirtd.service Before = NetworkManager.service After=dbus.service After=polkit.service Confpcts=iptables.service ip6tables.service ebtables.service ipset.service Documentation=man:firewalld(1) [Service] EnvironmentFile = -/etc/sysconfig/firewalld ExecStart = /usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS ExecReload = /bin/kill -HUP $MAINPID # supress to log debug and error output also to /var/log/messages StandardOutput = null StandardError = null Type = dbus BusName = org.fedoraproject.FirewallD1 [Install] WantedBy = basic.target Apas = dbus-org.fedoraproject.FirewallD1.service [root@localhost]#
Now that we have explored both systemd and systemctl in more detail, let s use them to manage the resources in cgroups or control groups.
Advertisements