一、运行级别:
# Default runlevel. The runlevels used are:
# 0 - halt (Do NOT set initdefault to this) =》
关闭(或停止)系统
# 1 - Single user mode =》单用户模式
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking) =》 没有联网的多用户模式
# 3 - Full multiuser mode =》联网的多用户模式
# 4 - unused =》
# 5 - X11 =》联网并且使用X Window系统的多用户模式
# 6 - reboot (Do NOT set initdefault to this) =》重启系统
参考资料:
0 | runlevel0.target, poweroff.target | 关闭系统。 |
1, s, single | runlevel1.target, rescue.target | 单用户模式。 |
2, 4 | runlevel2.target, runlevel4.target, multi-user.target | 用户定义/域特定运行级别。默认等同于 3。 |
3 | runlevel3.target, multi-user.target | 多用户,非图形化。用户可以通过多个控制台或网络登录。 |
5 | runlevel5.target, graphical.target | 多用户,图形化。通常为所有运行级别 3 的服务外加图形化登录。 |
6 | runlevel6.target, reboot.target | 重启 |
emergency | emergency.target | 紧急 Shell |
相关查看命令
runlevel ,
who -r
二、开机自动配置:
1、
/etc/init.d/nginx 服务脚本
2、添加服务chkconfig --add nginx
3、设置服务运行级别
备注:
可以直接设置服务,绕过添加 chkconfig <service> on
配置相关命令
①
chkconfig 配置服务
chkconfig [--list] [--type type][name]
chkconfig --add name
chkconfig --del name
chkconfig --override name
chkconfig [--level levels] [--type type] name <on|off|reset|resetpriorities>,默认level 2345
chkconfig [--level levels] [--type type] name
②
service - run a System V init script
service SCRIPT COMMAND [OPTIONS]
service --status-all
service --help | -h | --version
备注:
service runs a System V init script in as predictable environment as possible, removing most environment vari-
ables and with current working directory set to /.
service会尽可能使运行System V init脚本的环境可预测,从而消除大多数环境变量【只保留LANG和TERM两个环境变量】,并且设置
当前工作目录为根目录。
当启动脚本依赖环境变量时,想通过service命令重启时,需在启动脚本中增加source /etc/profile
案列:
php项目用到环境变量时,重启脚本不加入source /etc/profile会导致重启环境变量一直不生效,
即使执行命令的顺序如下:1、source /etc/profile 2、service php-fpm restart依旧不生效
反而1、source /etc/profile 2、/etc/init.d/php-fpm restart生效的原因就是在这里
③
查看命令的路径 : ls -al $(which java)
参考链接: