服务管理
服务管理:
启动类型:手动,自动,禁用
#查看所有服务
[root@localhost yuq]# systemctl list-unit-files
#查看所有service服务
[root@localhost yuq]# systemctl list-unit-files --type service
#查看sshd服务
[root@localhost yuq]# systemctl is-active sshd
active
#查看ftp服务
[root@localhost yuq]# systemctl is-active vsftpd.service
active
#关闭ftp服务
[root@localhost yuq]# systemctl stop vsftpd.service
[root@localhost yuq]# systemctl is-active vsftpd
unknown
#开启ftp服务
[root@localhost yuq]# systemctl start vsftpd
#查看服务当前状态
[root@localhost yuq]# systemctl is-active vsftpd
active
#重启ftp服务
[root@localhost yuq]# systemctl restart vsftpd
#查看是否开机启动
[root@localhost yuq]# systemctl is-enabled vsftpd.service
disabled
#关闭开机自动启动(不会影响当前状态)
[root@localhost yuq]# systemctl disable vsftpd
#设置开机自动启动(不会影响当前状态)
[root@localhost yuq]# systemctl enable vsftpd.service
[root@localhost yuq]# systemctl is-active vsftpd
active
#禁用服务
[root@localhost yuq]# systemctl mask vsftpd.service
ln -s '/dev/null' '/etc/systemd/system/vsftpd.service'
#查看服务状态
[root@localhost 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
#禁用后服务不能启动
[root@localhost yuq]# systemctl start vsftpd
Failed to issue method call: Unit vsftpd.service is masked.
#解禁服务
[root@localhost yuq]# systemctl unmask vsftpd.service
#查看服务状态
root@localhost 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
#启动服务
[root@localhost yuq]# systemctl start vsftpd
#服务定义的脚本
[root@localhost yuq]# ls /usr/lib/systemd/system
#搜索服务
[root@localhost yuq]# systemctl list-unit-files |grep vsftpd
#自定义服务脚本
#安装服务
[root@localhost yuq]# rpm -ivh copuloa*
#复制脚步
[root@localhost yuq]# cp cpuload1.service cpuload2.ervice /usr/lib/systemd/system
#查询服务
[root@localhost yuq]# systemctl list-unit-files | grep cpuload
#启动服务
[root@localhost yuq]# systemctl start cpuload1