Ubuntu 20.04常见配置
- 1. yum源配置
- 2. 安装桌面及图形化
- 2.1 安装图形化桌面
- 2.1.1 选择安装gnome桌面
- 2.1.2 选择安装xface桌面
- 2.2 安装VNC-Server
- 3. ufw防火墙策略
- 4. 时区设置及NTP时间同步
- 4.1 时区设置
- 4.2 NTP安装及时间同步
- 4.2.1 服务端(例:172.16.32.11)
- 4.1.2 客户端(例:172.16.32.12)
服务器信息
1. yum源配置
配置文件位于:/etc/apt/目录下的sources.list,截图版本的sources.list需将内容替换为:
deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse# deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
更多Ubuntu版本yum源配置参考地址:https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.3e221b1109vChv
其他OS可访问地址:https://developer.aliyun.com/mirror/?spm=a2c6h.13651104.mirror-detail.d1002.2879320cEEIkdg
2. 安装桌面及图形化
2.1 安装图形化桌面
Ubuntu20.04主流的图形桌面有gnome和xface两种
2.1.1 选择安装gnome桌面
#更新软件源
sudo apt update#安装gnome
sudo apt install ubuntu-gnome-desktop#刚安装Gnome,需要启动GDM服务以初识化桌面
sudo systemctl start gdm
2.1.2 选择安装xface桌面
#更新软件源
sudo apt update#安装xface
sudo apt install xfce4 xfce4-goodies
2.2 安装VNC-Server
#在ubuntu上安装tigervnc-server
sudo apt install tigervnc-standalone-serve#启动vnc-server
sudo vncserver
# 初次启动时需要输入6~8位的密码# 关闭vncserver
sudo vncserver -kill :*# 修改VNC连接密码
sudo vncpasswd
3. ufw防火墙策略
# 查看防火墙状态
sudo ufw status
# Status显示为active表示开启状态,显示为inactive表示未开启# 启动防火墙
sudo ufw enable# 添加防火墙规则
sudo ufw allow 80 # 允许访问80
sudo ufw allow 80 from 192.168.1.100 # 允许该IP访问80# 重启防火墙
sudo ufw reload# 禁用防火墙
sudo ufw disable
ufw命令详解:
root@oa:/etc/apt# ufw --help
Usage: ufw COMMAND
Commands:enable enables the firewalldisable disables the firewalldefault ARG set default policylogging LEVEL set logging to LEVELallow ARGS add allow ruledeny ARGS add deny rulereject ARGS add reject rulelimit ARGS add limit ruledelete RULE|NUM delete RULEinsert NUM RULE insert RULE at NUMroute RULE add route RULEroute delete RULE|NUM delete route RULEroute insert NUM RULE insert route RULE at NUMreload reload firewallreset reset firewallstatus show firewall statusstatus numbered show firewall status as numbered list of RULESstatus verbose show verbose firewall statusshow ARG show firewall reportversion display version information
Application profile commands:app list list application profilesapp info PROFILE show information on PROFILEapp update PROFILE update PROFILEapp default ARG set default application policy
4. 时区设置及NTP时间同步
4.1 时区设置
# 查看时区
sudo timedatectl # 修改时区为东八区
sudo timedatectl set-timezone Asia/Shanghai# 查询修改后的状态
sudo timedatectl status
# 说明:Time zone是时区 System clock synchronized: yes 反映了和远程NTP服务器成功同步, NTP service: active 意味着timesyncd已经启动和运行。RTC in local TZ: no表示硬件时钟(RTC)设置为协调世界时(UTC),yes表示硬件时钟设置为本地时间.
4.2 NTP安装及时间同步
4.2.1 服务端(例:172.16.32.11)
# 更新系统包
sudo apt update
sudo apt upgrade# 安装NTP服务
sudo apt install ntp# 配置NTP服务
sudo vim /etc/ntp.conf
pool ntp1.cloud.aliyuncs.com iburst
pool ntp2.cloud.aliyuncs.com iburst
pool ntp3.cloud.aliyuncs.com iburst
pool ntp4.cloud.aliyuncs.com iburst
pool ntp5.cloud.aliyuncs.com iburst# 重启NTP服务
sudo systemctl restart ntp# 添加防火墙规则,允许ntp连接
sudo ufw allow ntp
sudo ufw reload
sudo ufw status
4.1.2 客户端(例:172.16.32.12)
# 安装时间同步命令
sudo apt install ntpdate# 手动从172.16.32.11同步时间
sudo ntpdate 172.16.32.11# 禁用systemd timesyncd服务
sudo timedatectl set-ntp off# 安装ntp服务
sudo apt install ntp# 配置ntp同步策略
sudo vim /etc/ntp.conf
pool 172.16.32.11 iburst# 查看NTP同步状态
ntpq -p