Bài giảng Quản trị Linux - Chủ đề 7: Package Management-Ubuntu
Bạn đang xem 20 trang mẫu của tài liệu "Bài giảng Quản trị Linux - Chủ đề 7: Package Management-Ubuntu", để tải tài liệu gốc về máy bạn click vào nút DOWNLOAD ở trên
Tài liệu đính kèm:
- bai_giang_quan_tri_linux_chu_de_7_package_management_ubuntu.pdf
Nội dung text: Bài giảng Quản trị Linux - Chủ đề 7: Package Management-Ubuntu
- Đặng Thanh Bình Package Management - Ubuntu
- Contents • Introduction • dpkg • apt-get • aptitude • Automatic Updates • Repository config
- INTRODUCTION
- Intro • 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.
- Intro • Debian package files typically have the extension '.deb' • Packages are normally in a pre-compiled binary format; thus installation is quick, and requires no compiling of software.
- Intro • Many complex packages use the concept of dependencies. • Dependencies are additional packages required by the principal package in order to function properly.
- dpkg • dpkg is a package manager for Debian-based systems • It can install, remove, and build packages, but unlike other package management systems, it cannot automatically download and install packages or their dependencies.
- dpkg • To list all packages installed on the system, type: dpkg -l • Pipe the output through grep to see if a specific package is installed: dpkg -l | grep apache2 • To list the files installed by a package, in this case the ufw package, enter: dpkg -L ufw
- dpkg • If you are not sure which package installed a file, dpkg -S may be able to tell you dpkg -S /etc/host.conf base-files: /etc/host.conf – The output shows that the /etc/host.conf belongs to the base-files package. • 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.
- dpkg • Install a local .deb file: sudo dpkg -i zip_3.0-4_i386.deb – Change zip_3.0-4_i386.deb to the actual file name of the local .deb file you wish to install. • Uninstalling a package can be accomplished by: sudo dpkg -r zip
- dpkg • Uninstalling packages using dpkg, in most cases, is NOT recommended • It is better to use a package manager that handles dependencies to ensure that the system is in a consistent state • 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.
- APT-GET
- apt-get • 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
- apt-get • ease of use over simple terminal connections (SSH) • ability to be used in system administration scripts, which can in turn be automated by the cron scheduling utility
- apt-get • 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
- apt-get • 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 /etc/apt/sources.list.d directory – To update the local package index with the latest changes made in the repositories, type the following: sudo apt-get update
- apt-get • Upgrade Packages – To upgrade your system, first update your package index as outlined above, and then type: sudo apt-get upgrade
- apt-get • 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
- APTITUDE
- Aptitude • 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
- Aptitude • Aptitude is best suited for use in a non- graphical terminal environment to ensure proper functioning of the command keys • Start the menu-driven interface of Aptitude as a normal user by typing the following command at a terminal prompt: sudo aptitude
- Command 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
- AUTOMATIC UPDATES
- unattended-upgrades • 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
- unattended-upgrades • To configure unattended-upgrades, edit /etc/apt/apt.conf.d/50unattended- upgrades and adjust the following to fit your needs: Unattended-Upgrade::Allowed-Origins { "Ubuntu precise-security"; // "Ubuntu precise-updates"; };
- unattended-upgrades • Certain packages can also be blacklisted and therefore will not be automatically updated. To blacklist a package, add it to the list: Unattended-Upgrade::Package-Blacklist { // "vim"; // "libc6"; // "libc6-dev"; // "libc6-i686"; };
- Automatic Updates • To enable automatic updates, edit /etc/apt/apt.conf.d/10periodic and set the appropriate apt configuration options: APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Download-Upgradeable-Packages "1"; APT::Periodic::AutocleanInterval "7"; APT::Periodic::Unattended-Upgrade "1"; • The above configuration updates the package list, downloads, and installs available upgrades every day. The local download archive is cleaned every week.
- Notifications • Configuring Unattended-Upgrade::Mail in /etc/apt/apt.conf.d/50unattended- upgrades will enable unattended-upgrades to email an administrator detailing any packages that need upgrading or have problems
- apticron • apticron will configure a cron job to email an administrator information about any packages on the system that have updates available, as well as a summary of changes in each package. • 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"
- REPO MANAGEMENT
- What is a repository? ● A software repository is a storage location from which software packages are retrieved for installation. – Used by package managers: ● Arch: pacman ● Ubuntu: apt ● CentOS: yum ● Packages in the official repositories are constantly upgraded – When a package is upgraded, its old version is removed from the repository. ● More here:
- Components 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
- Where are they stored? ● Apt stores a list of repositories or software channels in the file /etc/apt/sources.list ● and in any file with the suffix .list under the directory /etc/apt/sources.list.d/ ● See man sources.list for more about this storage mechanism.
- /etc/apt/sources.list # sources.list #deb cdrom:[Ubuntu 13.10 _Saucy Salamander_ Release i386 (20131016.1)]/ saucy main restricted # See for how to upgrade to # newer versions of the distribution. deb saucy main restricted debsrc saucy main restricted #
- Add Universe & Multiverse Repos ● Two ways 1) Uncomment related lines ● deb saucy universe ● debsrc saucy universe ● deb saucyupdates universe ● debsrc saucyupdates universe
- Add Universe & Multiverse Repos ● Two ways 2) Use the add-apt-repository command. If your release is 'saucy': ● sudo addaptrepository "deb saucy universe multiverse" ● sudo addaptrepository "deb saucy updates universe multiverse" – Replace 'us.' by your country code. Check sources.list to see what is used! – 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
- Adding Partner Repositories ● Uncommenting the following lines in /etc/apt/sources.list file: deb saucy partner debsrc saucy partner ● Then update as before: sudo aptget update ● Note: this repository is NOT open source
- Adding Launchpad PPA Repos ● Non-Ubuntu repositories ● Adding the apt repository line of your software source to the end of the sources.list file. ● It should look something like this: – deb hardy seveas freenx ● Don't forget to make apt aware of your changes: – sudo aptget update
- Adding Launchpad PPA Repos ● Use add-apt-repository. Similar to "addrepo" on Debian. ● sudo add-apt-repository ppa: ● 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
- Adding 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 ● man apt-cdrom for more updated info
- Graphical UI ● Ubuntu