redhat 文档: https://docs.redhat.com/zh-cn/documentation/red_hat_enterprise_linux/9/#Networking
# centos9环境 借助nmcli命令配置
# 高版本 使用 networkmanager的客户端工具操作 nmcli
# 查看帮助文档
nmcli connection modify help
# nmcli 修改连接信息
nmcli connection modify ens160 \
ipv4.addresses 192.168.88.140/24 \
ipv4.gateway 192.168.88.2 \
ipv4.dns 192.168.88.2 \
ipv4.method manual
# 禁用IPV6
nmcli connection modify ens33 ipv6.method ignore
# 重启网络服务
# 方案1: 关闭网卡重启网卡
nmcli connection down ens160
nmcli connection up ens160
# 方案2: 直接重启网络管理服务
systemctl restart NetWorkManager# 由于乱码文件无法选择, 需要我们借助文件的inode来删除
# ~/.ssh 有时候我们误操作导致里面可能出现一些乱码文件
ls -ali | grep -v -E '(known_hosts|id_rsa|id_rsa.pub)$' | awk '{print $1}' | grep -E '^[0-9]+$' | xargs -n1 -I{} find . -inum {} -delete;
说明:
ls -ali 查看所有的文件 并展示inode号
grep -v -E '(known_hosts|id_rsa|id_rsa.pub)$' 排除保留的核心文件
awk '{print $1}' 获取第一列inode号
grep -E '^[0-9]+$' 保留数字值
xargs -n1 -I{} find . -inum {} -delete 把过滤的inode值当做参数值 传递给find进行 查找并删除
# 注意: 查找inode方式还有 tree命令也可以 但是需要我们自己使用正则解析里面的inode值赶兴趣小伙伴也可以把下面的脚步封装成shell脚本直接运行
# 针对centos8或者9
# 统一设置时区
timedatectl set-timezone Asia/Shanghai
# 安装同步服务
dnf install -y chronyd
# 配置同步时区
# 替换原始日期服务地址,增加阿里云的日期服务地址 这个不要重复执行
sed -E -i '/^pool/ { s/^(pool.+)/# \1/; a\
pool ntp1.aliyun.com iburst\
pool ntp2.aliyun.com iburst\
pool ntp3.aliyun.com iburst\
pool ntp4.aliyun.com iburst\
pool ntp5.aliyun.com iburst
}' /etc/chrony.conf
# 启动chronyd
systemctl start chronyd
# 设置开机启动
systemctl enable chronyd
# 检查状态,处于running说明服务正常
systemctl status chronyd
# 查看配置的源是否可用
chronyc sources
# 查看同步状态 显示 System clock synchronized: yes 表示OK
timedatectl # 假设有2个节点要配置相互密登录
# 192.168.100.101节点执行如下命令
# 生成密钥
ssh-keygen
# 拷贝公钥到目标主机
ssh-copy-id root@192.168.100.102
# 192.168.100.102节点执行如下命令
# 生成密钥
ssh-keygen
# 拷贝公钥到目标主机
ssh-copy-id root@192.168.100.101# 安装bash-completion 工具 高版本linux默认已安装,主要针对centos7
# 这个组件使用tab键可以帮助我们很好的提示, 尤其是可以提示一些命令参数
# 1. 检查是否已安装
yum list installed | grep bash-completion
# 2. 安装工具
yum install bash-completion
# 3. 激活生效
source /etc/profile.d/bash_completion.sh# file 命令查看文件的编码格式
file -i blog.log # crb(Code Ready Builder) 包含供开发人员使用的附加软件包
# https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository
dnf config-manager --set-enabled crb # 主要针对centos9
dnf install epel-release epel-next-release0