外观
Centos
约 331 字大约 1 分钟
2025-02-20
Centos7.9常用命令
查看当前操作系统版本信息
cat /proc/version
uname -a
Watch
使用watch实时观察命令执行输出内容
watch -n1 "kubectl get pod"
注
-n:指定每几秒刷新一次
Awk
以空格为间隔输出指定字符串
awk -F " " '{print $1,$2}'
注
-F:指定分隔符
Centos7.9不是那么常用的命令
查看系统安装了那些字体
fc-list
更改服务器时间
date --set="+10 month"
date --set="+10 day"
date --set="+10 year"
date -d "10 days ago"
注
上述命令只是临时生效,如果要改为永久生效就需要使用hwclock --systohc
来实现
升级Centos内核版本
查看版本信息
uname -r
cat /etc/os-release
更新yum源仓库
yum -y update
导入ELRepo仓库的公共密钥
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
安装ELRepo仓库的yum源
rpm -Uvh https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
查询可用内核版本
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
注
lt代表长期稳定版本,ml代表主线版本
安装最新的长期稳定版本内核
yum -y --enablerepo=elrepo-kernel install kernel-lt
查看系统上的所有可用内核并设置 grub2
awk -F\' '$1=="menuentry " '{print i++ " : " $2}' /etc/grub2.cfg
grub2-set-default 0
提示
内核更新需要重启才会生效