Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 3 章 /etc 配置文件

目录

3.1. /etc/rc.local
3.2. getent 用来察看系统的数据库中的相关记录
3.2.1. 主机名
3.2.2. 用户组
3.2.3. 查看端口
3.2.4. shadow 密码
3.3. /etc/inputrc
3.4. /etc/shells
3.5. shutdown
3.6. Profile
3.6.1. shell
3.7. 环境默认值
3.7.1. 显示所有配置项
3.7.2. 切换版本
3.7.3. 使用 alternatives 管理自己的软件版本
3.7.4. 配置系统默认编辑器

3.1. /etc/rc.local

/etc/rc.local 是一个开机启动脚本

		
[root@testing ~]# cat /etc/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local		
		
		
[提示]提示

很多系统已经弃用了该运行方案

CentOS 8 Stream 如果你想使用 rc.local 需要做如下配置

		
cat >> /usr/lib/systemd/system/rc-local.service <<EOF

[Install]
WantedBy=multi-user.target
EOF		
		
		

		
[root@testing ~]# chmod +x /etc/rc.d/rc.local		

[root@testing ~]# systemctl enable rc-local
Created symlink /etc/systemd/system/multi-user.target.wants/rc-local.service → /usr/lib/systemd/system/rc-local.service.

[root@testing ~]# systemctl start rc-local	

[root@testing ~]# systemctl status rc-local
● rc-local.service - /etc/rc.d/rc.local Compatibility
   Loaded: loaded (/usr/lib/systemd/system/rc-local.service; enabled; vendor preset: disabled)
   Active: active (exited) since Mon 2021-08-16 12:57:16 CST; 2s ago
     Docs: man:systemd-rc-local-generator(8)
  Process: 532000 ExecStart=/etc/rc.d/rc.local start (code=exited, status=0/SUCCESS)

Aug 16 12:57:16 testing systemd[1]: Starting /etc/rc.d/rc.local Compatibility...
Aug 16 12:57:16 testing systemd[1]: Started /etc/rc.d/rc.local Compatibility.