常用命令二:运行级别,开机服务【runlevel,chkconfig,service】

一、运行级别:
# 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)




参考链接:




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值