APT Basic Debian Package Management Goals of this lab: Learn how to install and remove binary packages on a Debian system. Prerequisites: LXB, UML REVISION: 2.0 [2015-08-28] ©2005-2015 DAVID BYERS Table of Contents PRELAB .................................................................................................................................................................... 1 Exercise 1: Review and preparation ............................................................................................................ 1 MAIN LAB ................................................................................................................................................................ 3 Part 1: Package management using APT ............................................................................................................ 3 Exercise 2: Configuring APT sources............................................................................................................ 3 Updating the package list ................................................................................................................................ 4 Installing packages .......................................................................................................................................... 4 Exercise 3: Installing a package ................................................................................................................... 4 Removing packages ......................................................................................................................................... 4 Exercise 4: Removing a package.................................................................................................................. 4 Part 2: Package management with aptitude ...................................................................................................... 4 Exercise 5: Exploring aptitude ..................................................................................................................... 4 Exercise 6: Review of aptitude .................................................................................................................... 6 IDA/ADIT APT: BASIC DEBIAN PACKAGE MANAGEMENT PRELAB You should do these before the main lab, using on-line documentation and man pages. Exercise 1: Review and preparation 1-1 1-2 Report: IDA/ADIT Read the documentation for apt - get and answer the following questions: (a) Which apt - get sub-command is used to install new packages? (b) Which apt - get sub-command is used to remove packages? (c) What does apt - get updat e do? (d) What does apt - get di s t - upgr ade do? Read the documentation for dpk g and answer the following questions: (a) What does dpk g - - get - s el ec t i ons do? (b) What does dpk g - - pur ge v i mdo? (c) What does dpk g –L bi nd9 do? Answers to the questions above. APT: BASIC DEBIAN PACKAGE MANAGEMENT 1 MAIN LAB All Linux distributions include some kind of package management. The system used in Debian (and derivatives of Debian, such as Ubuntu), dpkg, is one of the most powerful. As long as you don’t try to fight it (e.g. by installing incompatible versions of packages) and as long as you use it for everything, it can be of tremendous help. Running dpkg itself, however, can be a somewhat painful experience (akin to rpm in RedHat), since dpkg is the low-level tool, so most users use some other tool that handles the internals of dpkg. For the most part, these tools are based on APT, the Advanced Package Tool, which in itself is a wrapper around dpkg. APT helps the user with tasks such as dependency handling, which can be hard to do manually. The Debian package management system is very complex and very powerful. We will only scratch the surface, looking at the tools everyone needs. Time taken 2005: 0.5-1.5 hours, average 1 hour. Past problems: Some people think this lab is too easy. Unfortunately, we have to make the lab mandatory, because experience shows that those who need it the most are also the most likely to skip it. Part 1: Package management using APT The command-line tool you will use the most is apt-get. This tool is used for most common tasks related to package management. Before using apt-get you need to perform some basic configuration of APT. Central to APT is the list of sources. This is a list of locations where Debian packages (official or otherwise). Sources can be network sources (HTTP and FTP servers) and local directories. For the most part you will use network sources such as ftp.debian.org. These exercises require root access, so you will need to do them on a UML instance. When configuring an APT source, you need to specify several items: • Is it a source code source (deb-src) or a binaries source (deb)? • What is the location (e.g. http URI)? • What distribution of Debian is it (e.g. wheezy, Jessie or perhaps something else)? • What components of the distribution are of interest? In these labs, the distribution is “squeeze”. This is a very old distribution, but we still use it because it is very stable and reasonably fast with UML. All areas should be included: main, contrib, and non-free. The man page for sources.list contains more information. Exercise 2: Configuring APT sources 2-1 IDA/ADIT Configure APT to use the following binary APT sources: (a) http://ftp.se.debian.org/debian (distribution squeeze) (b) http://security.debian.org/ (distribution squeeze/updates) APT: BASIC DEBIAN PACKAGE MANAGEMENT 3 Report: No report required. Updating the package list Before using APT, you need to update its package list by issuing the command apt - get updat e. This is also when you find out if your configuration was good. You should run the update command daily, and whenever there appears to be a problem downloading a package for installation. Installing packages Use the apt - get i ns t al l command to install new packages. It will automatically add dependencies and remove packages that are incompatible with the one you are installing. Exercise 3: Installing a package 3-1 Install the aptitude package, if it isn’t already installed. 3-2 Install the hping package, if it isn’t already installed. Report: No report is required. Removing packages Use the apt - get r emov e command to remove packages. This will not remove configuration files, so if you re-install the package, you will (probably) have the same configuration. Exercise 4: Removing a package 4-1 Remove the hping package. Report: No report is required. Part 2: Package management with aptitude Although apt-get is sufficient to install packages, it is something of a back-end tool. It has no pretty user interface, and it won’t let you explore the available packages. For this reason, most people use frontends to APT (and dpk g) such as apt i t ude and ds el ec t . apt i t ude is a full-screen text-mode package management tool. It runs in a normal terminal window. apt i t ude has a number of nice features over apt besides the browsing: you can search for packages, It has better dependency handling, it can mark packages as “installed to satisfy dependency”, so they are automatically removed when no longer needed and so on. There is excellent documentation available for apt i t ude. Use it. Exercise 5: Exploring aptitude These exercises will take you through some of the useful features of aptitude. 5-1 Start apt i t ude on a UML instance. You should see two text panes. The top contains a list of package categories (“New Packages”, “Installed Packages”, “Not Installed Packages” and so forth) and the bottom contains a description of the item highlighted in the top pane. 5-2 Move the cursor up and down using the cursor keys and observe the description change. 5-3 Position the cursor over the line labeled “Installed Packages” and hit enter. The category should open. 5-4 Position the cursor key over the line labeled “utils” and hit enter. The next level of the hierarchy should open. Move to the line labeled “main” that was just displayed, and hit enter again. Now all packages in section main of utils should be visible. IDA/ADIT APT: BASIC DEBIAN PACKAGE MANAGEMENT 4 5-5 5-6 Move to the line labeled “file”. It should look something like this (the numbers are probably different): i A file 4. 12- 1 4. 12- 1 The “i" in the leftmost column indicates that the package is installed. The “A” indicates that it was installed automatically, so satisfy some dependency. The two columns at the end are the installed version and available version, respectively. 5-7 Locate the package “cups” (not installed, located in the net/main section). What does cups do? 5-8 With the cups package selected, hit enter again. This will display information about the package. You can see what it depends on and what depends on it. You can move the cursor and open sub-trees in this view just as in the previous one. This way you can explore relationships between packages. 5-9 Type Q to return to the package listing. Move the cursor up to the line labeled “Not Installed Packages” and hit enter to close the subtree. 5-10 Hit [ while still on the “Not Installed Packages” line. This will open all children and grandchildren of the line you are on. Hit enter to close the tree again. 5-11 You may notice that the description field at the bottom takes up space you’d rather use to list packages. Hit qD to toggle the visibility of the description window. You now know a bit about navigating in apt i t ude. The next step is searching. 5-12 Type L to bring up the tree limit dialog box. In the text field, type “passw”, then hit enter. This will cause apt i t ude to show only packages that contain “passw” in their names. Move to the bottom heading (“Not Installed Packages), and open the entire subtree. Move up and do the same for each of the other headings. The tree limit function is probably the most efficient way to search for packages in apt i t ude. 5-13 Type L again to bring up the tree limit dialog box. Clear the text field by typing vK and hit enter. apt i t ude now displays all packages again. You now know a little about searching in aptitude. Next step is installing stuff. 5-14 Update the package list by typing U.Hit “Ok” when the dialog box pops up. 5-15 Locate the j whoi s package by using the tree limit function. Type + to mark it for installation. The line should turn green, and in the leftmost column “p” should have changed to “pi”, indicating that the package is currently purged (not installed and no configuration installed), but will be installed. 5-16 Type G to start installing. apt i t ude first shows a listing of all actions that will be taken. In this case you should see j whoi s in one section, but also several other packages that are being installed to satisfy dependencies of j whoi s . Type G again to start the installation. Select “Continue” when a dialog box pops up, and hit enter when requested to do so. 5-17 Clear the package tree limit, then hit F. This will cause the packages listed under “New Packages” to be included in “Not Installed Packages”. 5-18 At this point you may see headings such as “Upgradable Packages” or even “Security Updates”. These are updates that are available. Open the headings using the [ key. 5-19 Now type qU. This will mark all updates for installation. You should see them turn blueish. Type G twice to start the installation and answer any dialogs that come up until you return to apt i t ude. IDA/ADIT APT: BASIC DEBIAN PACKAGE MANAGEMENT 5 You have now worked through the core functionality of aptitude. There is one final thing: 5-20 Type ? to display the on-line help. Use the cursor keys to scroll. You may want to refer to it in the future. Use the t key to highlight the Ok button at the bottom and hit enter to exit help. Report: No report is required. You will be expected to remember all commands you have tried. Exercise 6: Review of aptitude 6-1 What command in aptitude will cause the package list to contain only those packages whose names contain a specific word? 6-2 What command in aptitude lets you search the package list without hiding anything? 6-3 What command marks a package for installation? For deletion? 6-4 What command causes all selected actions (installation, deletion, and upgrades) to take place? 6-5 If there is a B in the leftmost column, what does that mean? Report: Answers to the questions above. IDA/ADIT APT: BASIC DEBIAN PACKAGE MANAGEMENT 6 FEEDBACK FORM APT Complete this feedback form individually at the end of the lab and hand it to the lab assistant when you finish. Your feedback is essential for improving the labs. Each student should hand in a feedback form. Do not cooperate on completing the form. You do not need to put your name on the feedback form. Your feedback will be evaluated the same way regardless of whether your name is on it or not. Your name is valuable to us in case you have made and comments in the last section that need clarifications or otherwise warrant a follow-up. For each section, please rate the following (range 1 to 5 in all cases). Difficulty: Rate the degree of difficulty (1=too easy, 5=too difficult) Learning: Rate your learning experience (1=learned nothing, 5=learned a lot). Interest: Rate your interest level after completing the part (1=no interest, 5=high interest). Time: How long did the part take to complete (in minutes)? Difficulty Learning Interest Time (minutes) Prelab Part 1: Package management using APT Part 2: Package management with aptitude Overall Please answer the following questions: What did you like about this lab? What did you dislike about this lab? Make a suggestion to improve this lab. IDA/ADIT APT: BASIC DEBIAN PACKAGE MANAGEMENT FEEDBACK FORM APT Complete this feedback form individually at the end of the lab and hand it to the lab assistant when you finish. Your feedback is essential for improving the labs. Each student should hand in a feedback form. Do not cooperate on completing the form. You do not need to put your name on the feedback form. Your feedback will be evaluated the same way regardless of whether your name is on it or not. Your name is valuable to us in case you have made and comments in the last section that need clarifications or otherwise warrant a follow-up. For each section, please rate the following (range 1 to 5 in all cases). Difficulty: Rate the degree of difficulty (1=too easy, 5=too difficult) Learning: Rate your learning experience (1=learned nothing, 5=learned a lot). Interest: Rate your interest level after completing the part (1=no interest, 5=high interest). Time: How long did the part take to complete (in minutes)? Difficulty Learning Interest Time (minutes) Prelab Part 1: Package management using APT Part 2: Package management with aptitude Overall Please answer the following questions: What did you like about this lab? What did you dislike about this lab? Make a suggestion to improve this lab. IDA/ADIT APT: BASIC DEBIAN PACKAGE MANAGEMENT