[CONTENT] Linux common parameters of /etc/fstab file

/dev/vg/lv_var /var xfs nodev,nosuid,noexec 0 0
/dev/vg/lv_var_log /var/log xfs nodev,nosuid,noexec,x-systemd.requires-mounts-for=/var 0 0

(
Add:
1) nodev parameter here means this directory can not be interpreted by devices or blocks
2) nosuid parameter here means no setuid files can be created in this directory
3) noexec parameter here means no files can be executed in this directory
4) x-systemd.requires-mounts-for=/var here parameter means /var/log directory can not be mounted until /var directory has been mounted
)

[CONTENT] Linux recommended swap size

Content:

For RHEL 6, RHEL 7, RHEL 8, RHEL 9

RAM sizeRecommended swap sizeRecommended swap size if allowing for hibernation
From 0 to 2GB 2 times the RAM size3 times the RAM size
From 2GB to 8GBThe same size of the RAM2 times the RAM size
From 8GB to 64GBAt least 4GB1.5 times the RAM size
From 64GBAt least 4GBHibernation is not recommended
RHEL 6, RHEL 7, RHEL 8, RHEL 9 Recommended Swap Size Table

Note: A 100GB swap is recommended if system with over 140 logical processes or over 3TB RAM

Reference:

https://access.redhat.com/solutions/15244

[内容] rm 命令确认步骤的取消

内容一:给某个用户单独取消 rm 命令的确认步骤

1.1 修改 ~/.bashrc 文件

# vi ~/.bashrc

添加以下内容:

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

1.2 重新登录用户

(步骤略)

内容二:全局永久设置取消 rm 命令的确认步骤

2.1 修改 /etc/bashrc 文件

# vi /etc/bashrc

添加以下内容:

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

2.2 重新登录用户

(步骤略)

[内容] RHEL 8 不自动刷新 /etc/resolv.conf 文件的设置

正文:

内容一:简介

1.1 /etc/resolv.conf 会被刷新的原因

RHEL 8 的 NetworkManager 软件会自动刷新 /etc/resolv.conf 文件里的内容,将其和 NetworkManager 软件自身设置的一致

1.2 /etc/resolv.conf 被刷新后的记录

/etc/resolv.conf 文件被刷新后 /var/log/messages 文件里会有类似记录

Oct 19 16:20:52 hostname NET[22999]: /etc/sysconfig/network-scripts/ifdown-post : updated /etc/resolv.conf
Oct 19 16:20:57 hostname NET[23222]: /etc/sysconfig/network-scripts/ifup-post : updated /etc/resolv.conf

内容二:让 /etc/resolv.conf 不被刷新的原因

2.1 方法一:删除 /etc/sysconfig/network-scripts/ifcfg-ens192 网卡文件中和 DNS 相关的设置

# vim /etc/sysconfig/network-scripts/ifcfg-ens192

删除以下类似内容:

DNS1=1.1.1.1

(补充:这里以删除 /etc/sysconfig/network-scripts/ifcfg-ens192 网卡文件中 DNS 设置 DNS1=1.1.1.1 为例)

2.2 方法二:设置 DHCP 时不跟随 DNS

# vim /etc/sysconfig/network-scripts/ifcfg-ens192

在设置了以下内容以后:

......
BOOTPROTO=dhcp
......

添加以下内容:

......
PEERDNS=no
......

(补充:这里以删除 /etc/sysconfig/network-scripts/ifcfg-ens192 网卡文件中 DNS 设置 DNS1=1.1.1.1 为例)

2.3 方法三:设置 NetworkManager 软件的配置文件不让它刷新

# vim /etc/NetworkManager/NetworkManager.conf

在以下内容下面:

......
[main]
......

添加以下内容:

......
dns=none
......

2.4 方法四:锁住 /etc/resolv.conf 文件

# chattr +i /etc/resolv.conf

参考文献:

https://access.redhat.com/solutions/7412