分享
Centos7 常用命令
输入“/”快速插入内容
Centos7 常用命令
Centos7常用命令
1.
修改网络地址
代码块
Bash
nmtui
cd /etc/sysconfig/network-scripts/
service network restart
2.
修改密码
代码块
Bash
passwd root
3.
替换源
配置清华源
清华源地址使用方法
配置阿里云源
1.
备份官方的原yum源的配置
代码块
Shell
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2.
下载Centos-7.repo文件
代码块
Shell
curl -o /etc/yum.repos.d/CentOS-Base.repo
http://mirrors.aliyun.com/repo/Centos-7.repo
3.
清除及生成缓存。
代码块
Shell
#
清除yum缓存
yum clean all
#
缓存阿里云源
yum makecache
#
测试阿里云源
yum list
#
升级
yum update
4.
时间同步
代码块
Plain Text
yum install -y ntpdate
ntpdate 192.168.107.12 # ntpdate time.nist.gov
date # 查看系统时间
timedatectl # 查看系统时间方面的各种状态
4.1
设置时区
代码块
C#
timedatectl set-timezone Asia/Shanghai # 设置系统时区为上海
4.2
定时同步
设置每分钟定时同步
代码块
Plain Text
crontab -e
* * * * * /usr/sbin/ntpdate 192.168.107.12 >/dev/null 2>&1
查看任务状态
代码块
Plain Text
crontab -l
* * * * * /usr/sbin/ntpdate 192.168.107.12 >/dev/null 2>&1
4.3
手动同步
代码块
Plain Text
date -s "2024-07-06 20:30:00"
ntpdate 192.168.107.12
5.
Tmux使用教程
代码块
Plain Text
新建会话:tmux new -s 001
退出会话:ctrl+b d
进入会话:tmux a -t 001
销毁会话:tmux kill-session -t 001
终端环境查看会话列表:tmux ls