本文介绍linux开机配置文件目录、systemctl enable实际机制、chkconfig、rc.local
一、/etc/systemd/system和/usr/lib/systemd/system 的区别
/etc/systemd/system/ Systemd 默认从目录/etc/systemd/system/读取配置文件。 里面存放的大部分文件都是符号链接,指向目录/usr/lib/systemd/system/
/usr/lib/systemd/system 真正的配置文件存放
二、关于systemctl enable
[root@FPPTSVR10104123 system]# systemctl enable nginx.service Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
等价于:
ln -s /usr/lib/systemd/system/nginx.service /etc/systemd/system/multi-user.target.wants/nginx.service
然后重启systemd,
systemctl daemon-reload
查看服务是否启动
systemctl list-unit-files | grep nginx
配置文件的后缀名,就是该 Unit 的种类,比如sshd.socket。如果省略,Systemd 默认后缀名为.service,所以sshd会被理解成sshd.service
三、关于chkconfig
服务类型—使用chkconfig
[root@foodapp1 sbin]# chkconfig nfs off
[root@foodapp1 sbin]# chkconfig --list nfs
nfs 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
[root@foodapp1 sbin]# chkconfig nfs on
[root@foodapp1 sbin]# chkconfig --list nfs
nfs 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[root@foodapp1 sbin]# chkconfig --list iptables
iptables 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
四、关于rc.local
简单命令类型,添加到rc.local
vi /etc/rc.d/rc.local
/usr/local/nginx/sbin/nginx
/usr/local/memcached/bin/memcached -d -m 512 -u root -p 11211 -c 1024 -P /tmp/memcached.pid