命令概况

CentOS < 7.x

1
2
service command     # 使用service命令做start|stop|restart sshd
chkconfig command # turn on or off 机器自启sshd

CentOS >= 7.x

1
systemctl command # 管理 start|stop|start 自启sshd

CentOS < 7.x

chkconfig

1
2
3
$ chkconfig sshd on     # 开机自启sshd
$ chkconfig sshd off # 开机关闭自启sshd
$ chkconfig --list sshd # 查看每个运行级别类型中服务的当前状态

service

1
2
3
$ service sshd start | stop | restart
or
$ /etc/init.d/sshd start | stop | restart

CentOS >= 7.x

1
2
3
4
5
6
7
$ systemctl enable sshd.service     # 开机自启sshd
$ systemctl disable sshd.service # 开机关闭自启sshd
$ systemctl start sshd.service # 启动sshd
$ systemctl restart sshd.service # 重启
$ systemctl stop sshd.service # 停止
$ systemctl reload sshd.service # 重新加载
$ systemctl status sshd.service # 查看启动状态
03-16 12:41