用 apt-get 安裝或移除軟體

安裝軟體

如何在你新的 ubuntu 伺服器中安裝軟體, 請輸入下面指令(請將<軟體名稱>換成你要安裝的軟體名稱):

apt-get install <軟體名稱>

您可以使用 man apt-get 來查詢更多關於 apt-get 指令的細節

軟體來源清單(sources.list)

如果你輸入 apt-get install <軟體名稱> 後看到下列訊息:

Reading package lists... Done
Building dependency tree
Reading state information... Done
**E: Couldn't find package** <軟體名稱>

這表示您可能打錯了軟體名稱, 或是無法在軟體來源清單中找到它. 您可以自動產生軟體來源清單(使用在您的 ubuntu server 上面), 工具在這裡: http://www.ubuntu-nl.org/source-o-matic/

這工具會產生如下訊息:

# Automatically generated sources.list
# http://www.ubuntu-nl.org/source-o-matic/
#
# If you get GPG errors with this sources.list, locate the GPG key in this file
# and run these commands (where KEY is replaced with that key) 
#
# gpg --keyserver hkp://subkeys.pgp.net --recv-keys KEY
# gpg --export --armor KEY | sudo apt-key add -
#
# If you don't know what to do with this file, read
# https://help.ubuntu.com/community/Repositories/CommandLine

# Ubuntu supported packages
# GPG key: 437D05B5
deb http://us.archive.ubuntu.com/ubuntu gutsy main restricted 
deb http://us.archive.ubuntu.com/ubuntu gutsy-updates main restricted
deb http://security.ubuntu.com/ubuntu gutsy-security main restricted

# Ubuntu community supported packages
# GPG key: 437D05B5
deb http://us.archive.ubuntu.com/ubuntu gutsy universe multiverse 
deb http://us.archive.ubuntu.com/ubuntu gutsy-updates universe multiverse
deb http://security.ubuntu.com/ubuntu gutsy-security universe multiverse

直接把 /etc/apt/sources.list 的內容覆蓋掉(或是用 sftp、其他檔案傳輸軟體來覆蓋), 然後在終端機輸入指令:

apt-get update

一旦你完成後,你可以重試指令 apt-get install <軟體名稱>, 在軟體來源清單內的軟體,你都可以使用它.

上一次變更: 2016/05/31 10:23 (外部編輯)