[Ubuntu] APT 指南 – apt-get & dpkg

設定檔

sources.list 的位置: /etc/apt/sources.list


APT

搜尋線上套件

apt search <package name>

安裝

apt install <package name>

查詢已安裝套件

apt list --installed
# Search by name
apt list --installed vi*

APT-GET

更新套件來源清單

apt-get update

套件升級更新

apt-get upgrade

安裝套件 (Vim為例)

apt-get install vim

移除套件, 保留設定檔

apt-get remove vim

完整移除套件

apt-get --purge remove vim

APT-CACHE

搜尋套件來源清單之套件名稱

 apt-cache search vim
 apt-cache search vim | grep vim

APT差異

apt command the command it replaces function of the command
apt install apt-get install Installs a package
apt remove apt-get remove Removes a package
apt purge apt-get purge Removes package with configuration
apt update apt-get update Refreshes repository index
apt upgrade apt-get upgrade Upgrades all upgradable packages
apt autoremove apt-get autoremove Removes unwanted packages
apt full-upgrade apt-get dist-upgrade Upgrades packages with auto-handling of dependencies
apt search apt-cache search Searches for the program
apt show apt-cache show Shows package details

APT獨有指令:

new apt command function of the command
apt list Lists packages with criteria (installed, upgradable etc)
apt edit-sources Edits sources list

DPKG

安裝 .deb 套件

dpkg -i bluefish_1.0.3-0.1_i386.deb

列出所有己安裝的主程式清單

dpkg -l
dpkg -l | grep vim

列出主程式所有的安裝目錄及檔案內容

dpkg -L vim

查目錄或檔案屬於那一個套件?

dpkg -S/etc/vim/vimrc

移除主程式, 保留設定檔

dpkg -r bluefish

完整移除主程式

dpkg -P bluefish

Leave a Reply

Your email address will not be published. Required fields are marked *