一、安裝注意事項
- 安裝時選擇英文版(否則后面會報錯無法安裝busybox等。
- 安裝時軟件包openssh一定要選上!?。?/li>
- 安裝的時候不要選安裝時更新系統(tǒng)和軟件和為系統(tǒng)安裝圖形和音頻軟件,等安裝好更新了軟件源之后再安裝需要的,這樣節(jié)約時間。
二、系統(tǒng)基礎配置
1. 網(wǎng)絡基礎配置
-
靜態(tài)ip地址配置
配置文件路徑:/etc/network/interfaces
配置如下:source /etc/network/interfaces.d/* # 環(huán)回口地址,保持默認即可 auto lo iface lo inet loopback # 網(wǎng)卡配置 auto enp0s3 # iface enp0s3 inet static //默認dhcp iface enp0s3 inet static //使用靜態(tài)ip address 192.168.31.160 //配置IP地址 netmask 255.255.255.0 //配置子網(wǎng)掩碼 gateway 192.168.31.1 //配置網(wǎng)關 dns-nameservers 119.29.29.29 114.114.114.114 //配置DNS修改完之后重啟網(wǎng)絡:
sudo /etc/init.d/networking restart -
DNS配置
配置文件路徑:/etc/resolvconf/resolv.conf.d/base
配置如下:search localdomain //若本機為DNS服務器可加上這句,若不是可不加 nameserver 8.8.8.8 #配置DNS1 nameserver 114.114.114.114 #配置DNS2,以此類推保存退出并重啟網(wǎng)絡:
sudo /etc/init.d/networking restart
查看當前DNS:cat /etc/resolv.conf -
添加網(wǎng)卡配置
首先查看網(wǎng)卡名稱:sudo lshw -class network
輸出信息中logical name即為要添加的網(wǎng)卡名。
如輸出為:logical name: enp0s8則配置如下:
# 環(huán)回口,默認即可 auto lo iface lo inet loopback #網(wǎng)卡enp0s8配置(上面查詢到的網(wǎng)卡名) auto enp0s8 //上面查詢到的網(wǎng)卡名 iface eth0 inet dhcp //這里配置為dhcp這里為dhcp,具體ip配置參見上文靜態(tài)ip配置
-
修改網(wǎng)卡名稱
有時候多網(wǎng)卡環(huán)境名稱不好識別,我們可以修改網(wǎng)卡名稱便于識別。
切換到root用戶:su
編輯grub文件:vi /etc/default/grub
在GRUB_CMDLINE_LINUX位置處,不改變原有信息并在其基礎上追加net.ifnames=0 biosdevname=0,如下(其余配置略):GRUB_DEFAULT=0 #GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_TIMEOUT=2 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="" GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0" //修改此行更新配置:
update-grub
注:net.ifnames=0 biosdevname=0作用是關閉網(wǎng)卡統(tǒng)一命名。編輯網(wǎng)卡配置文件:
# 環(huán)回口,默認即可 auto lo iface lo inet loopback auto enp0s8 //修改原網(wǎng)卡名為自定義的 iface eth0 inet dhcp重啟系統(tǒng):
reboot
重啟后可通過ifconfig命令查看已修改的網(wǎng)卡名。
2. 系統(tǒng)基礎配置
-
ROOT用戶配置
設置root密碼:sudo passwd
示例(以下為輸出信息):# fcwys為當前系統(tǒng)登陸用戶 fcwys@ubuntu:~$ sudo passwd [sudo] password for fcwys: //輸入當前用戶密碼 Enter new UNIX password: //輸入root用戶密碼 Retype new UNIX password: //再次輸入密碼 passwd: password updated successfully //密碼設置成功允許root用戶登陸(可選):
切換到root用戶:su
編輯sshd配置文件:vi /etc/ssh/sshd_config
修改如下行:# PermitRootLogin prohibit-password //注釋掉原來這行 PermitRootLogin yes //添加如下行重啟ssh:
/etc/init.d/ssh restart
現(xiàn)在就可以使用root登陸了。
3. apt軟件源配置
-
更換apt源為國內源
由于國外軟件源速度很慢,我們可以替換軟件源為國內源,如阿里云、網(wǎng)易等等。
進入源配置文件目錄:cd /etc/apt/
備份原來的源配置文件:cp sources.list sources.list.bak
編輯source.list如下(這里使用阿里源):# deb cdrom:[Ubuntu 16.04 LTS Aliyun] deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse ##測試版源 deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse # 源碼 deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse ##測試版源 deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse退出保存
更新源緩存:sudo apt-get update
這里使用的是阿里云的源,其他源配置方法相同。 -
配置本地源
切換到root用戶:su
首先掛載光盤:mount /dev/cdrom /mnt/apt/ # 這里掛載到/mnt/apt/目錄配置源配置文件:
vi /etc/apt/source.list
可以先備份原來的配置文件再新建(推薦),也可以直接追加。
添加內容如下:deb file:///mnt/apt/ xenial main restricted參數(shù)注釋:
deb: 指定要下載安裝deb包。 deb-src : 指定要下載安裝deb的源碼包,這里不需要 支持的協(xié)議: file:// ftp:// http:// /mnt/apt/: 源路徑URL xenial : ubuntu版本號名稱 main : 安裝ubuntu的主要包 restricted: 驅動相關的包注:查看版本信息:
lsb_release -a
最后更新源緩存:sudo apt-get update
到這里apt本地源就配置完成了。
?