一些可修改的系统设置
# 支持Root登录
# 编辑文件
sudo /etc/ssh/sshd_config
# 修改
#PermitRootLogin prohibit-password
PermitRootLogin yes
# 重启ssh
sudo service ssh restart
# 换源
# centos8
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
yum clean all && yum makecache
# centos7
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all && yum makecache
# ubuntu20.4
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo vi /etc/apt/sources.list
focal 是 Ubuntu 20.04 的代号
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
sudo apt-get update
# 如果需要将系统中的软件包升级到最新版本,可以运行:
sudo apt-get upgrade
# 同步时间
CentOS
首先保证机器的网络正常
安装ntp工具
yum -y install ntp
同步时间
/usr/sbin/ntpdate -u cn.pool.ntp.org
写入硬件时间:
hwclock -w
Ubuntu
查看当前时间状态
timedatectl status
设置时区
sudo timedatectl set-timezone Asia/Shanghai
手动设置时间
sudo timedatectl set-time '2024-04-27 14:30:00'
启用网络时间同步(确保自动校准时间)
sudo timedatectl set-ntp true
上次更新: 2025/04/25, 10:46:05