Ubuntu20.10 系統簡單優化與配置阿里源
一 , 網卡配置
# 16.04版本的網卡配置
mpd@ubuntu:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto ens33
iface ens33 inet static
address 192.168.15.200
netmask 255.255.255.0
network 192.168.15.0
broadcast 192.168.15.255
gateway 192.168.15.2
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 223.5.5.5 114.114.114.114
# 20.10版本的網卡配置
mpd@ubuntu20:~$ cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens33:
addresses:
- 192.168.15.200/24
gateway4: 192.168.15.2
nameservers:
addresses:
- 114.114.114.114
version: 2
重啟網卡
/etc/init.d/networking restart
# ifdown enp0s3(關閉網卡ens33) && ifup enp0s3(啟動網卡ens33)
sudo service network-manager restart
# 如果重啟網卡不成功 可以重啟試試reboot
二,開啟遠程鏈接22端口和設置開啟支持root用戶登錄
1)開啟22端口
由於Ubuntu沒有默認開啟22端口需要手動打開 才能ssh遠程連接
sudo apt install net-tools
安裝后,想通過MobaXterm遠程工具連接的時候發現連接失敗。
此時,查看Ubuntu關於22的端口,執行命令如下
netstat -ntlp|grep 22
參數解釋:
-n 不以進程的服務名稱,以端口號(port number)顯示
-t 列出tcp網絡封包的信息
-l 列出目前正在網絡監聽(listen)服務
-p 列出該網絡服務的進程
此時若發現無任何關於22端口的進程內容,執行以下命令
sudo apt-get install openssh-server
sudo apt-get install ufw
sudo ufw enable
sudo ufw allow 22
然后再用xshell連接成功。
2)設置允許root用戶登錄
mpd@ubuntu20:~$ sudo vim /etc/ssh/sshd_config
[sudo] password for mpd:
# ssh登錄的時候用戶沒有輸入密碼時多少秒之后自動退出
LoginGraceTime 120
# 允許root用戶用密碼登錄
# PermitRootLogin prohibit-password 改成PermitRootLogin yes
# 設置ssh在接收登錄請求之前是否檢查用戶家目錄和rhosts文件的權限和所有權
StrictModes yes
# 設置root密碼
mpd@ubuntu:~$ sudo passwd root
Enter new UNIX password: 1
Retype new UNIX password: 1
passwd: password updated successfully
mpd@ubuntu:~$ su - root
Password: 1
root@ubuntu:~#
三,配置阿里雲源
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src 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-backports main restricted universe multiverse
四,apt包管理工具
sudo apt-cache search package #搜索包
sudo apt-cache show package #獲取包的相關信息,如說明、大小、版本等
sudo apt-get install package #安裝包
sudo apt-get install package --reinstall #重新安裝包
sudo apt-get -f install #修復安裝”-f = –fix-missing”
sudo apt-get remove package #刪除包
sudo apt-get remove package --purge #刪除包,包括刪除配置文件等
sudo apt-get update #更新源
sudo apt-get upgrade #更新已安裝的包
sudo apt-get dist-upgrade #升級系統
sudo` `apt-get dselect-upgrade #使用 dselect 升級
apt-cache depends package #了解使用依賴
apt-cache rdepends package #是查看該包被哪些包依賴
sudo apt-get build-dep package #安裝相關的編譯環境
apt-get source package #下載該包的源代碼
sudo apt-get clean && sudo apt-get autoclean #清理無用的包
sudo apt-get check #檢查是否有損壞的依賴
sudo apt-get clean #清理所有軟件緩存(即緩存在/var/cache/apt/archives目錄里的deb包)
dpkg -L 包名 #查看安裝包的相關所有配置文件
五,查看發行版本
mpd@ubuntu20:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.10
Release: 20.10
Codename: groovy