Ubuntu14.04 環境搭建——軟體包管理
阿新 • • 發佈:2019-01-27
1. 基本概念
Ubuntu、Kali Linux 等 Debian 系的 Linux 發行版使用 Advanced Package Tools (APT) 進行軟體包管理,軟體包格式為 .deb 檔案。
.deb 檔案是 Debian 軟體包的標準發行方式,是 Ubuntu 軟體包管理的儲存基礎。
最基本的 Debian 軟體包管理工具是 dpkg
,它直接操作 .deb 檔案,執行安裝、升級、解除安裝等操作,缺點是它無法自動處理依賴。
另一個可代替 dpkg
的工具是 apt-get
,它操作的物件是包名,而非包檔案本身。apt-get
會自動從預定的來源(光碟或網上軟體源)取得所指定的包並完成後續的安裝工作,同時處理依賴。
2. 新增軟體源
/etc/apt/sources.list
用於儲存軟體源伺服器地址。/etc/apt/sources.list.d
目錄下的 *.list 檔案具備相同的功能,為在單獨檔案中新增軟體源提供了一種方式,通常用來安裝第三方的軟體。
系統支援配置多個軟體源,進行軟體包管理時,系統會一併從所有可連線的軟體源獲取資源。另一方面,配置過多軟體源容易導致更新源列表速度較慢。推薦的做法是,保留系統原有軟體源 /etc/apt/sources.list
不進行修改,在 /etc/apt/sources.list.d
目錄下為新增的軟體源獨立建立檔案。這樣在使用過程中,可以根據情況隨時新增或刪除軟體源,而不必擔心影響系統原有配置。
國內軟體源,推薦清華源、網易源和阿里源。各大映象站提供有 Linux 各發行版及其版本的軟體源配置檔案,一般而言,這些配置不會輕易改變,貼在下面便於使用。
vim /etc/apt/sources.list.d/tsinghua.list # 新增軟體源
# tsinghua deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse
# 163
deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
#deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
#deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
# aliyun
deb https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
3. 安裝常用軟體
sudo apt-get update
sudo apt-get install -y aptitude build-essential clang vim screen python python3 python-dev python3-dev python-pip python3-pip gcc g++ git git-core make cmake libpcre3 libpcre3-dev openssl libssl-dev curl libcurl4-openssl-dev libtool openssh-server openssh-client unzip