Bài giảng Quản trị Linux cung cấp kiến thức cơ bản về package management và Ubuntu. Nội dung chính trong chương này gồm có: Introduction, dpkg, apt-get, aptitude, automatic updates, repository config. Mời các bạn cùng tham khảo.
Trang 1Đặng Thanh Bình
Package Management - Ubuntu
Trang 3
INTRODUCTION
Trang 4• Ubuntu's package management system is derived from the same system used by the Debian GNU/Linux distribution
• The package files contain all of the necessary files, meta-data, and instructions to implement a particular functionality or software application on your Ubuntu computer
Trang 7
DPKG
Trang 10• Many files are automatically generated during the package install process, and even though they are on the filesystem, dpkg -S may not know which package they belong to.
Trang 12• For example using dpkg -r zip will remove the zip package, but any packages that depend on it will still be installed and may
no longer function correctly
Trang 13
APT-GET
Trang 14• The apt-get command is a powerful command-line tool, which works with Ubuntu's Advanced Packaging Tool (APT) performing such functions as
– Installation of new software packages
– Upgrade of existing software packages
– Updating of the package list index
– Upgrading the entire ubuntu system
Trang 16• Install a Package
sudo apt-get install nmap
• Remove a Package
sudo apt-get remove nmap
• Multiple Packages: You may specify multiple packages to be installed or removed, separated
by spaces
• Adding the purge option to apt-get remove
will remove the package configuration files as well
Trang 17• Update the Package Index
– The APT package index is essentially a database
of available packages from the repositories defined in the /etc/apt/sources.list file and in the
– To update the local package index with the latest changes made in the repositories, type the following:
sudo apt-get update
Trang 19• Actions of the apt-get command, such as installation and removal of packages, are logged in the /var/log/dpkg.log log file
• For further information about the use of APT, read the comprehensive Debian APT User Manual or type:
apt-get help
Trang 20
APTITUDE
Trang 21• Launching Aptitude with no command-line options, will give you a menu-driven, text-based front-end to the Advanced Packaging Tool (APT) system
• Many of the common package management functions, such as installation, removal, and upgrade, can be performed in Aptitude with single-key commands, which are typically lowercase letters
Trang 22• Aptitude is best suited for use in a graphical terminal environment to ensure proper functioning of the command keys
non-• Start the menu-driven interface of Aptitude
as a normal user by typing the following command at a terminal prompt:
sudo aptitude
Trang 23Command Line Aptitude
• To install the nmap package with all necessary dependencies, as in the apt-get example, you would use the following command:
sudo aptitude install nmap
• To remove the same package, you would use the command:
sudo aptitude remove nmap
Trang 24
AUTOMATIC UPDATES
Trang 25• The unattended-upgrades package can be used to automatically install updated packages, and can be configured to update all packages or just install security updates
• First, install the package by entering the following in a terminal:
sudo apt-get install unattended-upgrades
Trang 28Automatic Updates
• To enable automatic updates, edit
/etc/apt/apt.conf.d/10periodic and set the appropriate apt configuration options:
Trang 29• Configuring Unattended-Upgrade::Mail
in upgrades will enable unattended-upgrades
/etc/apt/apt.conf.d/50unattended-to email an administra/etc/apt/apt.conf.d/50unattended-tor detailing any packages that need upgrading or have problems
Trang 30• To install the apticron package
sudo apt-get install apticron
• Edit /etc/apticron/apticron.conf, to set the email address and other options:
EMAIL="root@example.com"
Trang 31
REPO MANAGEMENT
Trang 32What is a repository?
● A software repository is a storage location from
which software packages are retrieved for
Trang 33Components of repositories?
● Four separate areas or "components", according to – The level of support offered by Ubuntu and whether or not the program in question complies with Ubuntu's Free Software
Philosophy.
● Including
– Main - Officially supported software.
– Restricted - Supported software that is not available under a
completely free license.
– Universe - Community maintained software, i.e not officially
supported softs.
– Multiverse - Software that is not free
● The Ubuntu Install CDs contain software from the
"Main" and "Restricted" components
Trang 34Where are they stored?
● Apt stores a list of repositories or software channels in the file
Trang 35deb http://ch.archive.ubuntu.com/ubuntu/ saucy main restricted
debsrc http://ch.archive.ubuntu.com/ubuntu/ saucy main restricted
#
Trang 36Add Universe & Multiverse Repos
● Two ways
1) Uncomment related lines
● deb http://us.archive.ubuntu.com/ubuntu/ saucy universe
● debsrc http://us.archive.ubuntu.com/ubuntu/
saucy universe
● deb http://us.archive.ubuntu.com/ubuntu/ saucyupdates universe
● debsrc http://us.archive.ubuntu.com/ubuntu/
saucyupdates universe
Trang 37Add Universe & Multiverse Repos
● Two ways
2) Use the add-apt-repository command If your release is 'saucy':
● sudo addaptrepository "deb
http://us.archive.ubuntu.com/ubuntu/ saucy universe multiverse"
– Type lsb_release -sc to find out your release Repeat the
commands with "deb-src" instead of "deb" in order to install the source files.
– Don't forget to retrieve the updated package lists:
● sudo aptget update
Trang 38Adding Partner Repositories
● Uncommenting the following lines in
/etc/apt/sources.list file:
deb http://archive.canonical.com/ubuntu saucy partner
debsrc http://archive.canonical.com/ubuntu saucy partner
● Then update as before:
sudo aptget update
● Note: this repository is NOT open source
Trang 39Adding Launchpad PPA Repos
Trang 40Adding Launchpad PPA Repos
● Use add-apt-repository Similar to "addrepo" on Debian.
● sudo add-apt-repository ppa:<repository-name>
● Example: sudo add-apt-repository ppa:nhandler/ppa
● The command updates your sources.list file or adds/edits files under sources.list.d/
● If a public key is required and available it is automatically downloaded and registered.
● Should be installed by default On older or minimal
Ubuntu releases, you may have to install
software-properties-common and/or python-software-properties
first
– sudo apt-get install python-software-properties
Trang 41Adding ISO image to be Repos
● Check apt-cdrom command
sudo mkdir /aptoncdmountpoint
sudo mount /media/USB/aptoncd.iso ~/aptoncd mountpoint oloop
sudo aptcdrom d=/aptoncdmountpoint add
Trang 42Graphical UI
● https://help.ubuntu.com/community/Repositories/ Ubuntu