LinuxSystemctl是一个系统管理守护进程、工具和库的集合,用于取代System V、service和chkconfig命令,初始进程主要负责控制systemd系统和服务管理器。通过Systemctl –help可以看到该命令主要分为:查询或发送控制命令给systemd服务,管理单元服务的命令,服务文件的相关命令,任务、环境、快照相关命令,systemd服务的配置重载,系统开机关机相关的命令。
#systemctl list-unit-files
# systemctl list-units
# systemctl –failed
# systemctl is-enabledcrond.service
systemctl list-unit-files –type=service
# systemctl start httpd.service # systemctl restart httpd.service # systemctl stop httpd.service # systemctl reload httpd.service # systemctl status httpd.service
注意:当我们使用systemctl的start,restart,stop和reload命令时,终端不会输出任何内容,只有status命令可以打印输出。
# systemctl is-active mysql.service # systemctl enable mysql.service # systemctl disable mysql.service
# systemctl mask ntpdate.service ln -s ‘/dev/null”/etc/systemd/system/ntpdate.service’ # systemctl unmask ntpdate.service rm ‘/etc/systemd/system/ntpdate.service’
# systemctl killcrond
# systemctl list-unit-files –type=mount
# systemctl start tmp.mount # systemctl stop tmp.mount # systemctl restart tmp.mount # systemctl reload tmp.mount # systemctl status tmp.mount
# systemctl is-active tmp.mount # systemctl enable tmp.mount # systemctl disable tmp.mount
# systemctl mask tmp.mount ln -s ‘/dev/null”/etc/systemd/system/tmp.mount’ # systemctl unmask tmp.mount rm ‘/etc/systemd/system/tmp.mount’
# systemctl list-unit-files –type=socket
# systemctl showmysql
# systemctl list-dependencies httpd.service
# systemctl rescue
# systemctl emergency
# systemctl get-default
# systemctl isolate runlevel5.target 或 # systemctl isolate graphical.target
# systemctl isolate runlevel3.target 或 # systemctl isolate multiuser.target
# systemctl set-default runlevel3.target # systemctl set-default runlevel5.target
# systemctl reboot # systemctl halt # systemctl suspend # systemctl hibernate # systemctl hybrid-sleep
对于不知运行等级为何物的人,说明如下。
Runlevel 0 : 关闭系统
Runlevel 1 : 救援,维护模式
Runlevel 3 : 多用户,无图形系统
Runlevel 4 : 多用户,无图形系统
Runlevel 5 : 多用户,图形化系统
Runlevel 6 : 关闭并重启机器
本文作者:Gustav
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!