A small APT-Guide Cookbook
What does APT mean?
APT is short for Advanced Packaging Tool and is a collection of programs and scripts that help both the sysadmin (in your case root) with the installation and management of deb-files but equally the system itself to know what is installed.
For that, the "APT" -system needs a config-file: /etc/apt/sources.list; it contains the information about the locations of the installable and upgradeable packages . An example of such a file from a typical sidux Installation is as follows:
NOTE: In this example ftp.de indicates its using german repositories.You may edit this file, as root, to use the repositories closest to you, simply by changing the country,ie change ftp.de to ftp.us, or ftp.uk. Most countries have local mirrors.Bandwidth is conserved; speeds improved.
# See sources.list(5) for more information, especialy # Remember that you can only use http, ftp or file URIs # CDROMs are managed through the apt-cdrom tool. deb http://ftp.debian.org/debian/ sid main #deb-src http://ftp.debian.org/debian/ sid main #deb http://ftp.debian.org/debian/ testing main #deb-src http://ftp.debian.org/debian/ testing main #deb http://ftp.debian.org/debian/ experimental main #deb-src http://ftp.debian.org/debian/ experimental main deb http://sidux.com/debian/ sid main fix.main #deb-src http://sidux.com/debian/ sid main fix.main
To be able to obtain updated information on the packages APT uses a database. This database contains the packages but also which other packages are needed for that package to work (called dependencies). The program apt-get uses this database when installing your chosen packages to resolve all the dependencies and thereby to guarantee that the chosen packages will work. The updating of this database is done by the command apt-get update.
# apt-get update Get:1 http://sidux.com sid Release.gpg [189B] Get:2 http://sidux.com sid Release.gpg [189B] Get:3 http://sidux.com sid Release.gpg [189B] Get:4 http://ftp.de.debian.org unstable Release.gpg [189B] Get:5 http://sidux.com sid Release [34.1kB] Get:6 http://ftp.de.debian.org unstable Release [79.6kB]
Installing a new package
Presuming the Apt-database is updated and the name of the package is known, then the following command will install a package called example and all its dependencies: (further on you will see how to search and find packages.)
# apt-get install qemu Reading package lists... Done Building dependency tree... Done The following extra packages will be installed: bochsbios openhackware proll vgabios Recommended packages: debootstrap vde The following NEW packages will be installed: bochsbios openhackware proll qemu vgabios 0 upgraded, 5 newly installed, 0 to remove and 20 not upgraded. Need to get 4152kB of archives. After unpacking 11.9MB of additional disk space will be used. Do you want to continue [Y/n]? n
Deleting a package
Similarly it should come as no surprise that the following will deinstall example, however it will not remove the dependencies installed above, this will be covered later in deb-orphan
# apt-get remove example apt-get remove gaim Reading package lists... Done Building dependency tree... Done The following packages will be REMOVED: gaim gaim-irchelper 0 upgraded, 0 newly installed, 2 to remove and 310 not upgraded. Need to get 0B of archives. After unpacking 4743kB disk space will be freed. Do you want to continue [Y/n]? (Reading database ... 174409 files and directories currently installed.) Removing gaim-irchelper ... Removing gaim ...
In this last case the configuration files of the package 'gaim' (basically how its setup) were not deleted from the system. You could use them when installing the same package again and it would work with these settings
If you want the config files deleted also, issue this command:
# apt-get remove --purge gaim Reading package lists... Done Building dependency tree... Done The following packages will be REMOVED: gaim* 0 upgraded, 0 newly installed, 1 to remove and 309 not upgraded. Need to get 0B of archives. After unpacking 4678kB disk space will be freed. Do you want to continue [Y/n]? Y (Reading database ... 174405 files and directories currently installed.) Removing gaim ... Purging configuration files for gaim ...
Here the file /etc/gaim was not only deleted all config files were also purged/deleted, IF however an application holds or files because they were not created during the installation of the package that we want to delete, they will remain.
After the database is updated, one can find out which packages have new/newer versions:
# apt-show-versions -u |grep upgrade libpam-runtime/unstable upgradeable from 0.79-1 to 0.79-3 passwd/unstable upgradeable from 1:4.0.12-5 to 1:4.0.12-6 teclasat/unstable upgradeable from 0.7m02-1 to 0.7n01-1 libpam-modules/unstable upgradeable from 0.79-1 to 0.79-3 fonts-ttf-west-european/unstable upgradeable from 1.3-9 to 1.3-1-1 fonts-ttf-decoratives/unstable upgradeable from 1.3-1 to 1.3-1-1 sysv-rc/unstable upgradeable from 2.86.ds1-3 to 2.86.ds1-4 libpam0g/unstable upgradeable from 0.79-1 to 0.79-3 unionfs-utils/unstable upgradeable from 1.0.14+cvs2005092318w-M1 to 1.0.14+cvs2005092908w-M1libpam-runtime/unstable upgradeable from 0.79-1 to 0.79-3 passwd/unstable upgradeable from 1:4.0.12-5 to 1:4.0.12-6 teclasat/unstable upgradeable from 0.7m02-1 to 0.7n01-1 libpam-modules/unstable upgradeable from 0.79-1 to 0.79-3 fonts-ttf-west-european/unstable upgradeable from 1.3-9 to 1.3-1-1 fonts-ttf-decoratives/unstable upgradeable from 1.3-1 to 1.3-1-1 sysv-rc/unstable upgradeable from 2.86.ds1-3 to 2.86.ds1-4 libpam0g/unstable upgradeable from 0.79-1 to 0.79-3 unionfs-utils/unstable upgradeable from 1.0.14+cvs2005092318w-M1 to 1.0.14+cvs2005092908w-M1
The update of a single package including its dependencies can for example (for gcc-4.0) be done with:
apt-get install gcc-4.0 Reading package lists... Done Building dependency tree... Done gcc-4.0 is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and xxx not upgraded
Upgrade of an Installed System
If the whole system is to be upgraded this is achieved through "dist-upgrade". It is extremely important to first check which packages will be upgraded:
The upgrade should take place without the GUI in a textconsole (in this case you can first download the packages and after that finish the dist-upgrade in the textconsole.) This small inconvenience can save you hours of work later.
Just downloading
One of the little known , however one of the best options is the -d flag:
apt-get dist-upgrade -d
The -d allows you to download the dist-upgrade without installing it, giving you the option to proceed or abort like this
apt-get dist-upgrade -d xxx upgraded, 30 newly installed, 25 to remove and 2 not upgraded. Need to get 342MB of archives. After unpacking 3916kB of additional disk space will be used. Do you want to continue [Y/n]? Y (Y will download the upgraded packages without touching the installed system)
After the 'dist-upgrade -d' has downloaded, and wish to complete the dist-upgrade please follow these instructions:
Download and install
# apt-get dist-upgrade Reading package lists... Done Building dependency tree... Done Calculating upgrade... Done The following packages will be REMOVED: checkmem-kanotix ddcxinfo-kanotix etcskel-kanotix gprsconnect-kanotix kanotix-dsl kanotix-graphics kanotix-kernelhacking kanotix-menu kanotix-ndiswrapper kanotix-screenres kanotix-scripts kanotix-setpassword kanotix-udev-config kdeservicemenus-kanotix modemlink-kanotix netcardconfig-kanotix networkconfig-kanotix pdf-printerconfig-kanotix rebuildfstab-kanotix rootshell-kanotix sambastart-kanotix scanpartitions-kanotix smbconf-kanotix sshstart-kanotix user-profile-kanotix The following NEW packages will be installed: busybox-sidux configure-dsl configure-freenx configure-gprs configure-modemlink configure-ndiswrapper configure-networkcard configure-screenres configure-xawtv ddcxinfo-sidux etcskel-sidux genisoimage kdeservicemenus-sidux libdns22 libenchant1c2a libsexy2 networkconfig-sidux ppp-scripts rebuildfstab rootshell scanpartitions sidux-kernelhacking
NEVER EVER do a dist-upgrade nor upgrade whilst in X. Always check Current Warnings on the sidux main web site. These warnings are there for a reason and because of the nature of Debian sid/unstable which is updated on a daily basis. Log out of KDE. Go to Textmode by doing Ctrl+Alt+F1 ; logon as root, and then type init 3 ; apt-get update ; apt-get dist-upgrade ;run fix-fonts ; run fglrx or nvidia script if xorg updated and you have such a graphics adapter otherwise do ; init 5 && exit [NEVER DIST-UPGRADE [or UPGRADE] with adept or synaptic]
If you do not go to init 3, well tough for you ,, you have been warned
Searching for a package with apt-cache
Another very useful command in the APT-system is apt-cache; it searches the APT-Database and shows information on packages; e.g. a list of all packages, that contain or address a "screensaver" is obtained by:
# apt-cache search screensaver brightside - Add reactivity to the corners and edges of your GNOME desktop chbg - tool for changing the desktop background image in X11 cmatrix - Console Matrix simulates the display from "The Matrix" electricsheep - screensaver showing collective dream of sleeping computers epplets - The Epplets for the Enlightenment Window Manager gkrellshoot - Plugin for gkrellm to lock the screen and make screenshots kscreensaver - additional screen savers released with KDE kscreensaver-xsavers - KDE hooks for standard xscreensavers ktux - Tux screensaver for KDE lg-issue24 - Issue 24 of the Linux Gazette. lockvc - screensaver to lock your Linux console(s) rss-glx - Really Slick Screensavers GLX Port shermans-aquarium - Sherman's aquarium applet for GNOME 2 wmmatrix - View The Matrix in a Window Maker dock application xscreensaver - Automatic screensaver for X xscreensaver-gl - GL(Mesa) screen hacks for xscreensaver ksetisaver - SETI screensaver for KDE
If you want more information on a particular package, you can use:
# apt-cache show xscreensaver Package: xscreensaver Priority: optional Section: x11 Installed-Size: 9728 Maintainer: Ralf Hildebrandt Architecture: i386 Version: 4.21-7 Depends: libatk1.0-0 (>= 1.9.0), libc6 (>= 2.3.5-1), libglade2-0 (>= 1:2.5.1), libglib2.0-0 (>= 2.8.0), libgtk2.0-0 (>= 2.6.0), libice6 | xlibs (>> 4.1.0), libjpeg62, libpam0g (>= 0.76), libpango1.0-0 (>= 1.8.2), libsm6 | xlibs (>> 4.1.0), libx11-6 | xlibs (>> 4.1.0), libxext6 | xlibs (>> 4.1.0), libxinerama1, libxml2 (>= 2.6.21), libxmu6 | xlibs (>> 4.1.0), libxpm4 | xlibs (>> 4.1.0), libxrandr2 | xlibs (>> 4.3.0), libxrender1 (>> 1:0.9.0-1), libxt6 | xlibs (>> 4.1.0), libxxf86misc1, libxxf86vm1, zlib1g (>= 1:1.2.1) Recommends: xli | xloadimage, libjpeg-progs, perl5, miscfiles | wordlist Suggests: netpbm, xdaliclock, xscreensaver-gl, fortune, www-browser, qcam | streamer Conflicts: funny-manpages (1.3-1), suidmanager (0.50), xscreensaver-gnome (4.09-2), xscreensaver-nognome (4.09-2), gnome-control-center (1:2) Filename: pool/main/x/xscreensaver/xscreensaver_4.21-7_i386.deb Size: 3747878 MD5sum: ae0650bafe4834f9c6459d75544d1ddb Description: Automatic screensaver for X The purpose of xscreensaver is to display pretty pictures on your screen when it is not in use, in keeping with the philosophy that unattended monitors should always be doing something interesting, just like they do in the movies.
The benefit that this program has over the combination of the xlock and xautolock programs is the ease with which new graphics hacks can be installed: you don't need to recompile this program to add a new display mode, you just change some resource settings. Any program which can be invoked in such a way that it draws on the root window of the screen can now be used as a screensaver without modification. The programs that are being run as screensavers don't need to have any special knowledge about what it means to be a screensaver.
Tag: interface::x11, uitoolkit::gtk, x11::screensaver Task: gnome-desktop Package: xscreensaver Priority: optional Section: x11 Installed-Size: 10032 Maintainer: Ralf Hildebrandt Architecture: i386 Version: 4.21-5 Depends: libatk1.0-0 (>= 1.9.0), libc6 (>= 2.3.2.ds1-21), libglade2-0 (>= 1:2.5.1), libglib2.0-0 (>= 2.6.0), libgtk2.0-0 (>= 2.6.0), libice6 | xlibs (>> 4.1.0), libjpeg62, libpam0g (>= 0.76), libpango1.0-0 (>= 1.8.1), libsm6 | xlibs (>> 4.1.0), libx11-6 | xlibs (>> 4.1.0), libxext6 | xlibs (>> 4.1.0), libxml2 (>= 2.6.16), libxmu6 | xlibs (>> 4.1.0), libxpm4 | xlibs (>> 4.1.0), libxrandr2 | xlibs (>> 4.3.0), libxrender1, libxt6 | xlibs (>> 4.1.0), zlib1g (>= 1:1.2.1) Recommends: xli | xloadimage, netpbm, libjpeg-progs, perl5, miscfiles | wordlist Suggests: xdaliclock, xscreensaver-gl, fortune, www-browser, qcam | streamer Conflicts: xscreensaver-gnome (4.09-2), xscreensaver-nognome (4.09-2), gnome-control-center (1:2) Filename: pool/main/x/xscreensaver/xscreensaver_4.21-5_i386.deb Size: 3850212 MD5sum: 4c4d20ef312359cf836f3164a6eac293
Description: Automatic screensaver for X The purpose of xscreensaver is to display pretty pictures on your screen when it is not in use, in keeping with the philosophy that unattended monitors should always be doing something interesting, just like they do in the movies.
The benefit that this program has over the combination of the xlock and xautolock programs is the ease with which new graphics hacks can be installed: you don't need to recompile this program to add a new display mode, you just change some resource settings. Any program which can be invoked in such a way that it draws on the root window of the screen can now be used as a screensaver without modification. The programs that are being run as screensavers don't need to have any special knowledge about what it means to be a screensaver.
Tag: interface::x11, uitoolkit::gtk, x11::screensaver Task: gnome-desktop
A complete description of the APT-System can be found at APT-HOWTO

