服务管理
Posted 代码顽童
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了服务管理相关的知识,希望对你有一定的参考价值。
服务管理:
启动类型:手动,自动,禁用
#查看所有服务
[[email protected] yuq]# systemctl list-unit-files
#查看所有service服务
[[email protected] yuq]# systemctl list-unit-files --type service
#查看sshd服务
[[email protected] yuq]# systemctl is-active sshd
active
#查看ftp服务
[[email protected] yuq]# systemctl is-active vsftpd.service
active
#关闭ftp服务
[[email protected] yuq]# systemctl stop vsftpd.service
[[email protected] yuq]# systemctl is-active vsftpd
unknown
#开启ftp服务
[[email protected] yuq]# systemctl start vsftpd
#查看服务当前状态
[[email protected] yuq]# systemctl is-active vsftpd
active
#重启ftp服务
[[email protected] yuq]# systemctl restart vsftpd
#查看是否开机启动
[[email protected] yuq]# systemctl is-enabled vsftpd.service
disabled
#关闭开机自动启动(不会影响当前状态)
[[email protected] yuq]# systemctl disable vsftpd
#设置开机自动启动(不会影响当前状态)
[[email protected] yuq]# systemctl enable vsftpd.service
[[email protected] yuq]# systemctl is-active vsftpd
active
#禁用服务
[[email protected] yuq]# systemctl mask vsftpd.service
ln -s ‘/dev/null‘ ‘/etc/systemd/system/vsftpd.service‘
#查看服务状态
[[email protected] yuq]# systemctl status vsftpd
vsftpd.service
Loaded: masked (/dev/null)
Active: active (running) since 二 2017-06-13 13:12:19 CST; 11min ago
Main PID: 5615 (vsftpd)
CGroup: /system.slice/vsftpd.service
└─5615 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
#禁用后服务不能启动
[[email protected] yuq]# systemctl start vsftpd
Failed to issue method call: Unit vsftpd.service is masked.
#解禁服务
[[email protected] yuq]# systemctl unmask vsftpd.service
#查看服务状态
[email protected] yuq]# systemctl status vsftpd
vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled)
Active: active (running) since 二 2017-06-13 13:12:19 CST; 16min ago
Main PID: 5615 (vsftpd)
CGroup: /system.slice/vsftpd.service
└─5615 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
#启动服务
[[email protected] yuq]# systemctl start vsftpd
#服务定义的脚本
[[email protected] yuq]# ls /usr/lib/systemd/system
#搜索服务
[[email protected] yuq]# systemctl list-unit-files |grep vsftpd
#自定义服务脚本
#安装服务
[[email protected] yuq]# rpm -ivh copuloa*
#复制脚步
[[email protected] yuq]# cp cpuload1.service cpuload2.ervice /usr/lib/systemd/system
#查询服务
[[email protected] yuq]# systemctl list-unit-files | grep cpuload
#启动服务
[[email protected] yuq]# systemctl start cpuload1
以上是关于服务管理的主要内容,如果未能解决你的问题,请参考以下文章