Feb 9, 2014

Ubuntu Lesson 07 - Install Software Apps with apt-get

用Windows系統安裝常用軟體的習慣是:所有軟體複製到某一目錄或DVD,安裝好新系統時,就到此目錄一個個軟體安裝。自從iOS開始,大家應該已經習慣安裝軟體由雲端來裝吧!只要用同一帳號,不管是Apple Store, Google Play or Windows Market,就可以一次安裝全部。但是要如何安裝常用軟體到新的Ubuntu系統呢?

Linux玩家都習慣用指令安裝軟體套件,Debian系統首先以dpkg (Debian package) 來轉散播體套件,但dpkg是較底層的工具,安裝dpkg套件間的複雜關聯性,不是一般工程師可以熟悉得來的。
dpkg is the software at the base of the Debian package management systemdpkg is used to install, remove, and provide information about .deb packagesdpkg itself is a low level tool; higher level tools, such as APT, are used to fetch packages from remote locations or deal with complex package relations. Tools like aptitude or synaptic are more commonly used than dpkg on its own, as they have a more sophisticated way of dealing with package relationships and a friendlier interface. (From: Wikipedia/dpkg)
不同Linux系統常用安裝軟體套件的工具分別為:
  • Ubuntu / Debian: apt-get (Advanced Package Tool)。
  • Red Hat / Fedora / CentOS: yum (Yellow dog Updater, Modified)

distribution 代表軟體管理機制使用指令線上升級機制(指令)
Red Hat/FedoraRPMrpm, rpmbuildYUM (yum)
Debian/UbuntuDPKGdpkgAPT (apt-get)
From: 鳥哥的 Linux 私房菜

Ubuntu使用的apt指定,就可以把常用的軟體套件,寫在一個shell檔案,新系統隨時可以執行,一次安裝全部軟體。
The Advanced Packaging Tool, or APT, is a free user interface that works with core libraries to handle the installation and removal of software on the Debian GNU/Linux distribution and its variants.[3] APT simplifies the process of managing software on Unix-like computer systems by automating the retrieval, configuration and installation of software packages, either from precompiled files or by compiling source code. [3]  There is no single "apt" program; apt is a collection of tools. (From: Wikipedia/APT)
例如:常用的vlc和zip相關軟體,可以將以下字串存於.sh檔。
# VLC Player and plugins
sudo add-apt-repository ppa:videolan/stable-daily
sudo apt-get update
sudo apt-get install vlc vlc-plugin-pulse
# rar and zip
sudo apt-get install unrar-free
sudo apt-get install p7zip-full 


常用的apt指令如下:記得前面加上「sudo 」用ROOT權限才能安裝
  • apt-get update    # 安裝軟體前,可先執行更新 
  • apt-get upgrade  # 自動找出以安裝軟體的新版軟體套件,並一一升級
  • apt-get install 要安裝的套件名稱
  • apt-get remove 要移除的套件名稱
  • apt-cache search 套件相關的關鍵字  # e.g. apt-cache search zip | grep 7zip
grep is useful to filter off long strings and identify desired patterns

  • apt-get clean  #清除暫存套件 .deb 檔案 (/var/cache/apt/archives)
.deb source files佔了快1 Gb space!
apt-get clean執行後,一秒清空!



  • apt-get check  #安裝有問題時,用來診斷問題所在
參考:http://b9532026.wordpress.com/2010/03/30/apt-get-%E6%8C%87%E4%BB%A4%E4%B8%80%E8%A6%BD-2/

補充:若要更新軟體,可用terminal以下列指令完成,這樣比用滑鼠更新快多了 (但少部分更新還是要用系統的更新功能)。
sudo su -  # 以root帳號登入,隨時在console保持此root權限登入的terminal
apt-get update  # 更新套件
apt-get upgrade  # 更新軟體

No comments :

Post a Comment