Using systemd unit files to customize and optimize your system Red Hat Enterprise Linux 8 Optimize system performance and extend configuration with systemd Red Hat Customer Content Services

Commands:
<unit_name> . <type_extension>
DefaultTimeoutStartSec= required value
touch /etc/systemd/system/ <name> .service chmod 664 /etc/systemd/system/ <name> .service
[Unit] Description= <service_description> After=network.target [Service] ExecStart= <path_to_executable> Type=forking PIDFile= <path_to_pidfile> [Install] WantedBy=default.target
systemctl daemon-reload systemctl start <name> .service
cp /etc/ssh/sshd{,-second}_config
Port 22220 PidFile /var/run/sshd-second.pid
cp /usr/lib/systemd/system/sshd.service /etc/systemd/system/sshd-second.service
Description=OpenSSH server second instance daemon
After=syslog.target network.target auditd.service sshd.service
ExecStart=/usr/sbin/sshd -D -f /etc/ssh/sshd-second_config USDOPTIONS
[Unit] Description=OpenSSH server second instance daemon After=syslog.target network.target auditd.service sshd.service [Service] EnvironmentFile=/etc/sysconfig/sshd ExecStart=/usr/sbin/sshd -D -f /etc/ssh/sshd-second_config USDOPTIONS ExecReload=/bin/kill -HUP USDMAINPID KillMode=process Restart=on-failure RestartSec=42s [Install] WantedBy=multi-user.target
semanage port -a -t ssh_port_t -p tcp 22220
systemctl enable sshd-second.service
ssh -p 22220 user@server
conf_check() { [ -x /usr/sbin/postfix ] || exit 5 [ -d /etc/postfix ] || exit 6 [ -d /var/spool/postfix ] || exit 5 } make_aliasesdb() { if [ "USD(/usr/sbin/postconf -h alias_database)" == "hash:/etc/aliases" ] then # /etc/aliases.db might be used by other MTA, make sure nothing # has touched it since our last newaliases call [ /etc/aliases -nt /etc/aliases.db ] || [ "USDALIASESDB_STAMP" -nt /etc/aliases.db ] || [ "USDALIASESDB_STAMP" -ot /etc/aliases.db ] || return /usr/bin/newaliases touch -r /etc/aliases.db "USDALIASESDB_STAMP" else /usr/bin/newaliases fi } start() { [ "USDEUID" != "0" ] && exit 4 # Check that networking is up. [ USD{NETWORKING} = "no" ] && exit 1 conf_check # Start daemons. echo -n USD"Starting postfix: " make_aliasesdb >/dev/null 2>&1 [ -x USDCHROOT_UPDATE ] && USDCHROOT_UPDATE /usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure USD"USDprog start" RETVAL=USD? [ USDRETVAL -eq 0 ] && touch USDlockfile echo return USDRETVAL }
systemctl daemon-reload
init q
systemctl restart <name> .service
mkdir /etc/systemd/system/ <name> .service.d/
touch /etc/systemd/system/name.service.d/ <config_name> .conf
[Unit] Requires= <new_dependency> After= <new_dependency>
[Service] Restart=always RestartSec=30
systemctl daemon-reload systemctl restart <name> .service
mkdir /etc/systemd/system/httpd.service.d/
touch /etc/systemd/system/httpd.service.d/custom_script.conf
[Service] ExecStartPost=/usr/local/bin/custom.sh
systemctl daemon-reload
systemctl restart httpd.service
cp /usr/lib/systemd/system/ <name> .service /etc/systemd/system/ <name> .service
systemctl daemon-reload systemctl restart <name> .service
cp /usr/lib/systemd/system/httpd.service /etc/systemd/system/httpd.service
[Service] PrivateTmp=true TimeoutStartSec=10 [Install] WantedBy=multi-user.target
systemctl daemon-reload
systemctl show httpd -p TimeoutStartUSec
systemd-delta
[EQUIVALENT] /etc/systemd/system/default.target -> /usr/lib/systemd/system/default.target [OVERRIDDEN] /etc/systemd/system/autofs.service -> /usr/lib/systemd/system/autofs.service --- /usr/lib/systemd/system/autofs.service 2014-10-16 21:30:39.000000000 -0400 +++ /etc/systemd/system/autofs.service 2014-11-21 10:00:58.513568275 -0500 @@ -8,7 +8,8 @@ EnvironmentFile=-/etc/sysconfig/autofs ExecStart=/usr/sbin/automount USDOPTIONS --pid-file /run/autofs.pid ExecReload=/usr/bin/kill -HUP USDMAINPID -TimeoutSec=180 +TimeoutSec=240 +Restart=Always [Install] WantedBy=multi-user.target [MASKED] /etc/systemd/system/cups.service -> /usr/lib/systemd/system/cups.service [EXTENDED] /usr/lib/systemd/system/sssd.service -> /etc/systemd/system/sssd.service.d/journal.conf 4 overridden configuration files found.
<template_name> @ <instance_name> .service
<unit_name> @.service
Wants=getty@ttyA.service getty@ttyB.service
[Unit] Description=Getty on %I [Service] ExecStart=-/sbin/agetty --noclear %I USDTERM
systemctl list-unit-files --state=enabled
systemd-analyze
systemd-analyze blame
systemd-analyze critical-chain
systemctl list-unit-files --state=enabled
systemctl disable <service_name>
systemctl cat <service_name>
systemctl help <service_name>