systemctl 命令详解及使用教程( 三 )

使用Systemctl控制和管理挂载点17.列出所有系统安装点
# systemctl list-unit-files --type=mountUNIT FILESTATEdev-hugepages.mountstaticdev-mqueue.mountstaticproc-sys-fs-binfmt_misc.mount staticsys-fs-fuse-connections.mount staticsys-kernel-config.mountstaticsys-kernel-debug.mountstatictmp.mountdisabled18.如何装载 , 卸载 , 重新装载 , 重新装载系统装载点 , 以及检查系统上装载点的状态
# systemctl start tmp.mount# systemctl stop tmp.mount# systemctl restart tmp.mount# systemctl reload tmp.mount# systemctl status tmp.mounttmp.mount - Temporary DirectoryLoaded: loaded (/usr/lib/systemd/system/tmp.mount; disabled)Active: active (mounted) since Tue 2018-04-28 17:46:06 IST; 2min 48s agoWhere: /tmpWhat: tmpfsDocs: man:hier(7)http://www.freedesktop.org/wiki/Software/systemd/APIFileSystemsProcess: 3908 ExecMount=/bin/mount tmpfs /tmp -t tmpfs -o mode=1777,strictatime (code=exited, status=0/SUCCESS)Apr 28 17:46:06 tecmint systemd[1]: Mounting Temporary Directory...Apr 28 17:46:06 tecmint systemd[1]: tmp.mount: Directory /tmp to mount over is not empty, mounting anyway.Apr 28 17:46:06 tecmint systemd[1]: Mounted Temporary Directory.19.如何在引导时激活 , 启用或禁用装入点(在系统引导时自动装入)
# systemctl is-active tmp.mount# systemctl enable tmp.mount# systemctl disabletmp.mount20.如何在Linux中屏蔽(使其无法启动)或取消屏蔽挂载点
# systemctl mask tmp.mountln -s '/dev/null' '/etc/systemd/system/tmp.mount'# systemctl unmask tmp.mountrm '/etc/systemd/system/tmp.mount'使用Systemctl控制和管理套接字21.列出所有可用的系统套接字 。
# systemctl list-unit-files --type=socketUNIT FILESTATEdbus.socketstaticdm-event.socketenabled lvm2-lvmetad.socketenabled rsyncd.socketdisabledsshd.socketdisabledsyslog.socketstaticsystemd-initctl.socketstaticsystemd-journald.socketstaticsystemd-shutdownd.socketstaticsystemd-udevd-control.socket staticsystemd-udevd-kernel.socketstatic11 unit files listed.22.如何在Linux中启动 , 重新启动 , 停止 , 重新加载和检查套接字的状态(例如:cups.socket)
# systemctl start cups.socket# systemctl restart cups.socket# systemctl stop cups.socket# systemctl reload cups.socket# systemctl status cups.socketcups.socket - CUPS Printing Service SocketsLoaded: loaded (/usr/lib/systemd/system/cups.socket; enabled)Active: active (listening) since Tue 2015-04-28 18:10:59 IST; 8s agoListen: /var/run/cups/cups.sock (Stream)Apr 28 18:10:59 tecmint systemd[1]: Starting CUPS Printing Service Sockets.Apr 28 18:10:59 tecmint systemd[1]: Listening on CUPS Printing Service Sockets.23.如何激活套接字并在引导时启用或禁用(在系统引导时自动启动套接字)
# systemctl is-active cups.socket# systemctl enable cups.socket# systemctl disable cups.socket24.如何屏蔽(使其无法启动)或取消屏蔽插座(cups.socket)
# systemctl mask cups.socketln -s '/dev/null' '/etc/systemd/system/cups.socket'# systemctl unmask cups.socketrm '/etc/systemd/system/cups.socket'服务的CPU利用率(份额)25.获取服务的当前CPU份额(比如httpd)
# systemctl show -p CPUShares httpd.serviceCPUShares=1024

注意:每个服务的默认值都为CPUShare = 1024.您可以增加/减少进程的CPU份额 。
26.将服务的CPU份额(httpd.service)限制为2000 CPUShares /
# systemctl set-property httpd.service CPUShares=2000# systemctl show -p CPUShares httpd.serviceCPUShares=2000
注意:为服务设置CPUShare时 , 会创建一个名为service的目录(httpd.service.d) , 其中包含一个包含CPUShare Limit信息的文件90-CPUShares.conf 。您可以将文件视为:
# vi /etc/systemd/system/httpd.service.d/90-CPUShares.conf [Service]CPUShares=200027.检查服务的所有配置详细信息
# systemctl show httpdId=httpd.serviceNames=httpd.serviceRequires=basic.targetWants=system.sliceWantedBy=multi-user.targetConflicts=shutdown.targetBefore=shutdown.target multi-user.targetAfter=network.target remote-fs.target nss-lookup.target systemd-journald.socket basic.target system.sliceDescription=The Apache HTTP ServerLoadState=loadedActiveState=activeSubState=runningFragmentPath=/usr/lib/systemd/system/httpd.service....28.分析服务的关键链(httpd)
# systemd-analyze critical-chain httpd.serviceThe time after the unit is active or started is printed after the "@" character.The time the unit takes to start is printed after the "+" character.httpd.service +142ms└─network.target @11.168s└─network.service @9.456s +1.712s└─NetworkManager.service @8.858s +596ms└─firewalld.service @4.931s +3.926s└─basic.target @4.916s└─sockets.target @4.916s└─dbus.socket @4.916s└─sysinit.target @4.905s└─systemd-update-utmp.service @4.864s +39ms└─auditd.service @4.563s +301ms└─systemd-tmpfiles-setup.service @4.485s +69ms└─rhel-import-state.service @4.342s +142ms└─local-fs.target @4.324s└─boot.mount @4.286s +31ms└─systemd-fsck@dev-disk-byx2duuid-79f594adx2da332x2d4730x2dbb5fx2d85d196080964.service @4.092s +149ms└─dev-disk-byx2duuid-79f594adx2da332x2d4730x2dbb5fx2d85d196080964.device @4.092s


推荐阅读