# 進行第一次系統升級、調校及安裝基礎套件 ##### **1 基本升級**
在安裝完基礎系統後,需進行基本的升級工作,建議使用安裝過程式的**一般**用戶名稱登入,並使用 sudo 指令進行系統更新作業。 ```shell $ sudo apt update ``` 一樣第一次會請你輸入 sudo 的密碼: ```shell [sudo] password for ossii: ``` 輸入正確的密碼後,就會以 Root 身份執行 apt update 的工作了,接下來會出現類似於以下的訊息。 ```shell Hit:1 http://tw.archive.ubuntu.com/ubuntu focal InRelease Hit:2 http://tw.archive.ubuntu.com/ubuntu focal-updates InRelease Hit:3 http://tw.archive.ubuntu.com/ubuntu focal-backports InRelease Hit:4 http://tw.archive.ubuntu.com/ubuntu focal-security InRelease Reading package lists... Done Building dependency tree Reading state information... Done 41 packages can be upgraded. Run 'apt list --upgradable' to see them. ``` 接下來請執行以下指令: ```shell $ sudo apt upgrade ``` 然後接著會出現要升級的套件資訊,如下所示: ```shell Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following package was automatically installed and is no longer required: libfwupdplugin1 Use 'sudo apt autoremove' to remove it. The following NEW packages will be installed: libfwupdplugin5 libmbim-glib4 libmbim-proxy libmm-glib0 libqmi-glib5 libqmi-proxy modemmanager usb-modeswitch usb-modeswitch-data The following packages will be upgraded: alsa-ucm-conf apt apt-utils bolt command-not-found fwupd fwupd-signed isc-dhcp-client isc-dhcp-common kmod landscape-common libapt-pkg6.0 libc-bin libc6 libfwupd2 libjcat1 libkeyutils1 libkmod2 libnetplan0 libnss-systemd libpam-systemd libsystemd0 libudev1 locales login netplan.io open-vm-tools passwd python3-commandnotfound python3-distupgrade sbsigntool snapd sosreport systemd systemd-sysv systemd-timesyncd ubuntu-advantage-tools ubuntu-release-upgrader-core udev unattended-upgrades update-notifier-common 41 upgraded, 9 newly installed, 0 to remove and 0 not upgraded. Need to get 59.8 MB of archives. After this operation, 17.3 MB of additional disk space will be used. Do you want to continue? [Y/n] 按下 Y 鍵開始下載更新 ``` 第一次更新完請重新開機,指令如下: ```shell $ sudo reboot ``` ##### **2 安裝基礎套件**
基本上會建議安裝以下常用的基本套件,這樣在之後的管理工作上會比較簡單,這份清單會隨著時間更新,列表及說明如下:
項次套件名稱說明
1vim提供更多 vi 編輯器效果的延伸套件,讓你編輯純文字文件時不再只是單調的畫面。
2wget下載網路連結檔案的工具,常常會在安裝其它非 RPM Base 的工具中用到。
3net-tools基本網路查詢工具,在確認網路或是服務狀態時會常常用上。
4unzip解壓縮工具。
安裝指令如下: ```shell $ sudo apt install vim wget net-tools unzip ``` 一樣在輸入 Root 密碼後按下「Y」鍵,系統即會自動安裝完成。 ##### **3 基本調校工作**
- **變更密碼** 如果您想要變更 root 密碼,可以使用「passwd」指令,變更 root 密碼的操作方式如下: ```shell $ sudo passwd root New password: Retype new password: passwd: password updated successfully ``` - **變更系統網路 IP** 先查詢看看目前的 IP 及網卡資訊為何,我們可以使用 ifconfig 指令: ``` $ ifconfig ens18: flags=4163 mtu 1500 inet 192.168.3.78 netmask 255.255.255.0 broadcast 192.168.3.255 inet6 fe80::448a:95ff:fe70:da59 prefixlen 64 scopeid 0x20 ether 46:8a:95:70:da:59 txqueuelen 1000 (Ethernet) RX packets 16374 bytes 13711868 (13.7 MB) RX errors 0 dropped 3 overruns 0 frame 0 TX packets 4024 bytes 308208 (308.2 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ``` 所以會看到,網路卡是 ens18,IP 則是 192.168.3.78,如果我們要變更網路資訊的話,請用 vim 指令([**vim 指令教學**](https://blog.techbridge.cc/2020/04/06/how-to-use-vim-as-an-editor-tutorial/))編輯網路設定檔,本例如下: ```shell $ sudo vim /etc/netplan/00-installer-config.yaml ``` 內容如下: > \# This is the network config written by 'subiquity' > network: > ethernets: > ens18: > addresses: > **- 192.168.3.79/24** > ** gateway4: 192.168.3.1** > nameservers: > addresses: > ** - 8.8.8.8** > search: > - ossii.com.tw > version: 2 上面紅色的部份就請依照實際的網路環境變更即可,存檔之後執行以下的指令即可重新取得新的 IP 資訊。 ```shell $ sudo netplan apply ``` 這個時候若是透過 SSH 連線的話,應該會斷線,請重新以新的 IP(本例為:192.168.3.79) 連入,資訊如下: ```shell $ ifconfig ens18: flags=4163 mtu 1500 inet 192.168.3.79 netmask 255.255.255.0 broadcast 192.168.3.255 inet6 fe80::448a:95ff:fe70:da59 prefixlen 64 scopeid 0x20 ether 46:8a:95:70:da:59 txqueuelen 1000 (Ethernet) RX packets 126577 bytes 24996107 (24.9 MB) RX errors 0 dropped 11 overruns 0 frame 0 TX packets 4511 bytes 353668 (353.6 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ``` - 調整系統時間 Ubuntu 20.04 預設的時區資訊可能是錯誤的,請先使用 date 的指令來查詢,結果如下: ```shell $ date Tue 26 Jul 2022 06:22:34 AM UTC ``` 若要調整時區,請使用 timedatectl 指令來設定,若是 Asia/Taipei 時區,請使用下以下指令: ```shell $ sudo timedatectl set-timezone Asia/Taipei [sudo] password for ossii: ossii@ubuntu-test-server2:~$ date Tue 26 Jul 2022 02:25:02 PM CST ``` 這樣子就完成了時間的調校工作,如果想要列出所有時區的名稱,可以使用以下指令: ```shell $ timedatectl list-timezones Africa/Abidjan Africa/Accra Africa/Addis_Ababa Africa/Algiers Africa/Asmara Africa/Bamako Africa/Bangui ... ... ``` 如此就完成了 Ubuntu 20.04 基本的主機調整工作啦~