---
# System prepended metadata

title: Ubuntu 常用命令

---

# Ubuntu 常用命令
## 改鏡像節點與更新
```bash=
sudo sed -i 's/archive.ubuntu.com/free.nchc.org.tw/g' \
/etc/apt/sources.list
sudo sed -i 's/free.nchc.org.tw/ftp.ubuntu-tw.net/g' \
/etc/apt/sources.list
sudo apt update
sudo apt upgrade

sudo sed -i 's/free.nchc.org.tw/tw.archive.ubuntu.com/g' \
/etc/apt/sources.list

sudo sed -i 's/us.archive.ubuntu.com/ftp.ubuntu-tw.net/g' \
/etc/apt/sources.list
```

## 設置語系
英文版Ubuntu無法自動抓到我們平常用的台灣語系，必須自己生成。生成後即可在語言格式中切換 Taiwan(Chinese)

```bash=
locale-gen zh_TW zh_TW.UTF-8
```

## 電源管理

```bash=
sudo add-apt-repository ppa:slimbook/slimbook
sudo apt install tlp slimbookbattery
```

## 中文輸入法
直接使用預設新酷音或安裝 Hime 輸入法
結束後要重開機

```bash=
sudo apt install hime
```



## 刪除多餘字型

```bash=
sudo apt-get --purge remove fonts-noto-cjk fonts-noto-cjk-extra fonts-noto-color-emoji fonts-noto-mono fonts-noto-unhinted fonts-arphic-ukai fonts-arphic-uming fonts-beng fonts-beng-extra fonts-freefont-ttf fonts-gubbi fonts-gujr fonts-gujr-extra fonts-guru fonts-guru-extra fonts-indic fonts-kacst fonts-kacst-one fonts-kalapi fonts-khmeros-core fonts-knda fonts-lao fonts-liberation2 fonts-lklug-sinhala fonts-lohit-beng-assamese fonts-lohit-beng-bengali fonts-lohit-deva fonts-lohit-gujr fonts-lohit-guru fonts-lohit-knda fonts-lohit-mlym fonts-lohit-orya fonts-lohit-taml fonts-lohit-taml-classical fonts-lohit-telu fonts-mlym fonts-nakula fonts-nanum fonts-navilu fonts-orya fonts-orya-extra fonts-pagul fonts-sahadeva fonts-samyak-deva fonts-samyak-gujr fonts-samyak-mlym fonts-samyak-taml fonts-sil-abyssinica fonts-sil-padauk fonts-smc fonts-smc-anjalioldlipi fonts-smc-chilanka fonts-smc-dyuthi fonts-smc-karumbi fonts-smc-keraleeyam fonts-smc-manjari fonts-smc-meera fonts-smc-rachana fonts-smc-raghumalayalamsans fonts-smc-suruma fonts-smc-uroob fonts-symbola fonts-takao-pgothic fonts-taml fonts-telu fonts-telu-extra fonts-thai-tlwg fonts-tibetan-machine fonts-tlwg-garuda fonts-tlwg-garuda-ttf fonts-tlwg-kinnari fonts-tlwg-kinnari-ttf fonts-tlwg-laksaman fonts-tlwg-laksaman-ttf fonts-tlwg-loma fonts-tlwg-loma-ttf fonts-tlwg-mono fonts-tlwg-mono-ttf fonts-tlwg-norasi fonts-tlwg-norasi-ttf fonts-tlwg-purisa fonts-tlwg-purisa-ttf fonts-tlwg-sawasdee fonts-tlwg-sawasdee-ttf fonts-tlwg-typewriter fonts-tlwg-typewriter-ttf fonts-tlwg-typist fonts-tlwg-typist-ttf fonts-tlwg-typo fonts-tlwg-typo-ttf fonts-tlwg-umpush fonts-tlwg-umpush-ttf fonts-tlwg-waree fonts-tlwg-waree-ttf fonts-ubuntu ttf-ancient-fonts-symbola ttf-ubuntu-font-family -y
```

## 安裝微軟字型

```bash=
sudo apt-get install cabextract fonts-linuxlibertine ttf-mscorefonts-installer
```

## Visual Studio Code Csharp For Unity
安裝 C# 擴充功能後，須另外安裝 mono 與 .Net Core 才可正常運作

```bash=
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-3.1

sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-devel
```

### 相關資料：
* https://www.mono-project.com/download/stable/#download-lin
* https://docs.microsoft.com/zh-tw/dotnet/core/install/linux-ubuntu

## 顯示系統 Logo、硬體資訊
```bash=
sudo apt install neofetch
neofetch
```


## 當機處理方式
### 進不去圖形介面，但可以操作TTY指令
還沒壞死，不用重灌
Gnome出錯當機，重新安裝後重開機即可解決
(設定值不會遺失)

```bash=
sudo apt-get install --reinstall ubuntu-desktop
sudo reboot
```

### 開機出現 /dev/nvme0n1p5: clean .... 訊息，無法進入系統
顯示卡驅動問題，請儘量不要更動驅動預設設定
嘗試按下Ctrl+Alt+F2或開機Grub選單進入Recovery模式，輸入指令
最後重開機後已解決

```bash=
sudo apt-get purge nvidia*
sudo ubuntu-drivers autoinstall
sudo reboot
```