常用的 apt 指令 (安裝、更新、移除)

Kiwi lee
3 min readMay 24, 2018
Copyright: wikipedia

Useful Basic commands of apt-get and apt-cache for package management

因某些 Linux 指令很容易忘記,故想要將一些常用的指令做個分類記載。
此篇參考許多上面網址所提到的指令,若有興趣加深閱讀可點進上面的網站中學習

安裝

  • 安裝插件
# Install/Upgrade the newest package
sudo apt-get install vsftpd
  • 查看某個插件有哪些版本
sudo apt-cache policy vsftpd
  • 安裝指定版本的插件
# Install specific package version
sudo apt-get install vsftpd=2.3.5-ubuntu1

Reference:

更新

  • 更新軟體的最新資訊及列表
sudo apt-get update
  • 更新目前已安裝的軟體到最新版本
sudo apt-get upgrade

上述的兩個指令一併使用時,即是取得最新版本的軟體資訊,並且將它們升級到最新。

Reference:

移除

  • 移除插件
# Keep configuration file 
sudo apt-get remove vsftpd
  • 移除插件,並同時移除設定檔
# Remove configuration file
sudo apt-get purge vsftpd
  • 因安裝插件時,會同時安裝一些相依的套件 (dependencies),上面兩個指令不會清乾淨,所以還需要執行
# Remove dependencies
sudo apt autoremove
  • 清除之前下載的安裝檔 (*.deb)
# Remove all package files
sudo apt clean
  • sudo apt clean,但不刪除仍安裝在電腦中軟體的安裝檔
# Remove package files which is not installed in PC
sudo apt autoclean

reference:

進階的指令

  • 取得插件的原始檔
# Only source code
sudo apt-get --download-only source vsftpd
# Download and unpack source code of a package
sudo apt-get source vsftpd
# Downaload, unpack and compile source code
sudo apt-get --compile soruce goaccess
# Download package without installing
sudo apt-get download nethogs
  • 查看插件的更新資訊
sudo apt-get changelog vsftpd

--

--