linux查看各服务状态以及开启和关闭

1..........................................

友好的显示所有服务的运行状态:

service --status-all

chkconfig --list

2................................

查看单个服务的运行状态

service sshd status

3................................

查看启动状态,是否开机自动启动

chkconfig --list servicename

0:开机

1:单用户模式

2:多用户模式,不具有网络档案系统(NFS)功能

3:多用户模式,具有网络档案系统(NFS)功能

4:某些发行版Linux用这个等级进入 X windows 系统

5:同4

6:重新启动

注意:切记无用1和6

关闭或开启服务状态:

chkconfig --level 345 nscd off/on

4.................................

增加服务:

chkconfig --add xxx   ( 注意:服务脚本必须存放在 /etc/init.d/目录下)

如mysqld

[root@www MySQL-5.1.59]#cp support-files/mysql.server   etc/init.d/mysqld

chkconfig mysqld on (各等级为ON,各等级为2345等级)

这样就会以系统服务的形式启动了

删除服务:

chkconfig --del XXX

runlevel 查看当前等级。

注意:运行级别就是操作系统正在运行的功能级别。

原文地址:https://www.cnblogs.com/jing1617/p/6442577.html