服务开机自启

Centos7

 把服务添加到开机自启

方法1

systemctl enable nfs

 

方法2 把启动命令添加到rc.local中

vim /etc/rc.local

注:centos7中rc.local默认是没有可执行权限的,需要手动添加 chmod +x /etc/rc.d/rc.local

 

2 取消服务开机自启

systemctl disable nfs

 

查看某个服务是否开机启动

systemctl status nfs

disabled 表示开机不自动运行

systemctl enable nfs

修改后 变成 enabled 表示开机自动运行

 

查看系统所有开机自启的服务

方法1

ll /etc/systemd/system/multi-user.target.wants/

方法2

systemctl list-unit-files |grep enable

 

Centos6

把服务添加到开机自启

方法1

chkconfig nfs on

方法2 把启动命令添加到rc.local中

vim /etc/rc.local

 

2 取消服务开机自启

chkconfig nfs off

 

查看系统所有开机自启的服务

chkconfig --list |grep 3:on

 

新装系统优化启动服务

# 1 关闭所有开机自启服务
for i in `chkconfig --list|grep 3:on|awk '{print $1}'`;do chkconfig --level 3 $i off;done

# 2 只开启必须的服务
for i in crond network rsyslog sshd;do chkconfig --level 3 $i on;done

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值