|
Apt notes |
sudo dpkg --get-selections > installed-applications.txt
Then save the "installed-applications.txt" file somewhere.sudo dpkg --set-selections < installed-applications.txt
sudo apt-get -y update
sudo apt-get dselect-upgrade
# sudo -s -H # apt-get clean # rm /var/lib/apt/lists/* # rm /var/lib/apt/lists/partial/* # apt-get clean # apt-get update
| dpkg --configure -a fixes many problems associated with pkg mgmt. |
| dpkg --configure -a --abort-after=99999 can be tried if you get the error "dpkg: too many errors, stopping". |
dpkg -r program
Remove (uninstall) the listed program package. This only removes the binaries (the program itself) and any startup scripts, but does not remove any configuration files for it. Reinstalling at a later date will then use your existing config files, so if you change your mind and decide to reinstall the program you won't have to reconfigure from scratch. Removing a package requires there be no other packages dependent on it: if it complains about dependencies, you need to remove those dependent packages first.
dpkg -P program
Purge (fully uninstall) the listed package. This removes everything related to that package: binaries, startup scripts, config files, everything. Purging a package requires there be no other packages dependent on it: if it complains about dependencies, you need to remove those dependent packages first. If you purge a package and then decide you want it back, you'll have to reconfigure it because the purge nukes all the configuration information as well.
dpkg -i program-1.0-1.deb
Install a package from a local Deb file on disk: if you download a .deb package directly from the Internet, it can be installed directly this way.
dpkg -l program
List version info and status of a currently installed package.
dpkg -L program
List all files related to this currently installed package: if you've just installed something, and you don't know where it went, use this to find it.
dpkg -S foo
Find the package that contains the file named 'foo'. Very useful if you've got a file on disk but don't know where it came from!
dpkg-reconfigure tzdata
Current default timezone: 'America/Los_Angeles' Local time is now: Mon Nov 16 11:57:22 PST 2009. Universal Time is now: Mon Nov 16 19:57:22 UTC 2009. Run 'dpkg-reconfigure tzdata' if you wish to change it.
Package is in a very bad inconsistent state - you should
reinstall it before attempting a removal.
> i need to know if there is a simple way to get apt-get to ignore pkgs with > unmet deps. I don't think there is. Your best bet is something like this: grep vsftpd /var/lib/apt/lists/*_Packages | grep Filename ftp.us.debian.org_debian_dists_sarge_main_binary-i386_Packages:Filename: pool/main/v/vsftpd/vsftpd_2.0.1-1_i386.deb wget ftp://ftp.us.debian.org/debian/pool/main/v/vsftpd/vsftpd_2.0.1-1_i386.deb dpkg --force-conflicts -i vsftpd_2.0.1-1_i386.deb I agree this sucks. It's dumb that apt-get won't even download the debs for you if they conflict with something.
how do I get the feature "whatprovides"?
sudo apt-get install apt-file To use: sudo apt-file update sudo apt-file search |
You can read a full how-to about Apt at www.debian.org/doc/manuals/apt-howto/.
apt-get update
This retrieves the current list of packages from all servers in your sources.list. If you don't do this from time to time your local list of available packages may become out of date. Do this occasionally before doing a dist-upgrade or searching for a new package. The package lists are large: doing an update may result in several MB of data being retrieved from the Internet.
apt-cache search program
This will do a keyword search through the list of available packages, including package names and descriptions. You can put in several keywords, for example 'apt-cache search text editor' to find a list of text editors.
apt-cache show program
Once you've found a package that looks interesting using 'apt-cache search', you can display more detailed information about it using 'apt-cache show program'. This will tell you things like the size of the package (important if you are installing it off the Internet) and an extended description, as well as what other packages it depends on in order to work and the name of the developer who maintains the package.
apt-get install program
This will get the latest version of the specified package and install it, along with any other packages that it depends on in order to work. If the requested package is already installed, this will upgrade it to the latest available version.
apt-get remove program
If you've previously installed a program and decide you don't want it anymore, you can remove it using this command. Because some software packages can depend on others, removing one program may break other programs. Running apt-get remove therefore checks first to see if any other software needs the program to work, and uninstalls them as well. This is just one example of the way the Debian package management tools have been designed to try to keep your computer in a sane state, without broken or half-installed software. It's certainly possible to break a Debian system, but generally you have to try to do it. It's unlikely you could do it by mistake.
apt-get upgrade
Over time, most of the software packages on your computer will become out of date as new versions are released to add features or fix bugs. You could manually do 'apt-get install foo' on each one, but that's not very convenient, so Apt provides a simple way to upgrade your entire system at once. Just type 'apt-get upgrade' to have Apt check every single package on your system for a new version, then download and install it. This command will never install new packages, it will only upgrade packages that are already installed.
apt-get dist-upgrade
Sometimes you'll have a software package installed, and a new version will come out that has a lot of new features and therefore it now depends on some other program to run. For example, you may have a movie player installed that supports a lot of different movie formats. When new formats come out, modules for those formats may be added in separate packages, so the latest version of the movie player software now depends on a new package that you don't yet have installed on your system. If you just do 'apt-get upgrade', you'll get the latest movie player, but you won't get all the new format packages. The 'apt-get dist-upgrade' command solves that problem for you: not only does it get the latest version of every package already installed just like 'apt-get upgrade', it also installs any new packages they need that may not be on your system yet. If you want to keep your system up to date with all the latest updates and security patches, running 'apt-get update; apt-get dist-upgrade' from time to time is the best way to do it.
apt-get clean
When you ask Apt to install a software package, it downloads the package and stores it in a cache on your disk before it does the actual installation. If you then remove the package, but later change your mind again and re-install it, Apt doesn't need to fetch it off the Internet again because the package is sitting in the local cache. That's great for saving bandwidth, but after a while it can use up space on your disk so it's a good idea to periodically delete old packages from the cache. Running 'apt-get clean' will totally flush the package cache, possibly freeing up some precious disk space. Running this command is quite safe, because the worst that can happen is Apt may need to download a package again if you remove it then re-install it.
apt-get autoclean
This is almost the same as 'apt-get clean', except it's just a little bit smarter: instead of cleaning out your entire package cache, it deletes only superseded packages. For example, your package cache may contain packages for the last 7 versions of a text editor that has been upgraded a number of times: running 'apt-cache autoclean' will delete the oldest 6 versions from the cache, leaving only the latest one. That makes sense because you're not likely to re-install anything except the latest version anyway. This is also a very safe command to run, so if you're a bit tight on disk space and don't want your package cache growing too much you could put it in a Cron job to do an automatic cleanup from time to time. There's really no reason to keep the older packages lying around on disk anyway.
Synaptic is a relatively recent addition to the Debian universe, and is intended to provide a user-friendly way to search or browse lists of available packages and install them. If you don't have it already installed on your system, open a terminal and switch to the root user, and type 'apt-get install synaptic'. Once it's installed, just type 'synaptic' as the root user to launch Synaptic, and you'll be presented with a list of package categories and buttons to manage them.
For example, to update the list of available software packages using Apt you would type 'apt-get update'. In Synaptic, there's a big fat button on the top that says 'Update List' that does exactly the same thing. Same goes for 'apt-get upgrade' (just click 'Upgrade all') and 'apt-get dist-upgrade' ('Dist Upgrade' in Synaptic).
Browsing through the available packages, you can select them and click the tabs at the bottom to see different information about them in much the same way you would use 'apt-cache show', and click the 'Install' button on the right to flag them for installation. Note that nothing much will happen when you do that: it just sets a flag, it doesn't do the actual installation at the time. That means you can happily browse through the packages and flag various items for installation as you go, without having to stop and wait for each one. Then when you're ready, click the big 'Proceed' button up the top to tell Synaptic to go ahead and grab all the packages you marked and install them.
Similarly if you select a package that's already installed on your system, you can select the 'Remove' button to queue it for deletion.
Use aptitude why packagename to find out what package requires or suggests the package.
If you want to install packages that have been "kept back," often people suggest you use dist-upgrade instead of upgrade. However, a better way to do this, without carrying a bunch of updates forward that you may not want, is to use aptitude instead of apt-get.
Occasionally, you must know what package a file belongs to, or what files are in a package. For a file that's installed, use
dpkg -S filenameFor example, if you don't have Sendmail installed and want to know what package owns the symlink for /usr/lib/sendmail, you can run
dpkg -S /usr/lib/sendmailIn my case, this returns:
postfix: /usr/lib/sendmail
What if you want to know what package would install a file? That's a job for apt-file. Note that this utility may not be installed by default. You'll also need to update its cache by running apt-file update. Then run apt-file filename that you want to see. The more specific you can be, the better. If you look for a single string that's likely to be in many filenames (like "vim"), you'll get quite a few results. If you look for something very specific like /usr/lib/xml2Conf.sh, then it will provide only one result. So if I search for /etc/apache2/apache2.conf even on a system without Apache installed, it will tell me that the package I'm looking for is apache2.2-common.
Saving a list of all installed software. Say you want to do a clean install of Debian (or a Debian derivative) to upgrade rather than apt-get dist-upgrade, but you don't want to figure out by trial and error what packages you had before -- simply run
dpkg --get-selectionsand you'll see a full list of packages that are installed.
But what about restoring the packages? That's easy. Run
dpkg--get-selections > installed-packages.txtWhen you have the clean system, run
dpkg --set-selections < installed-packages.txtDo be sure to back this file up before doing the install, of course.
Your computer keeps a list of possible software sources in a file called '/etc/apt/sources.list'. Whenever you tell it to go and update its list of available software packages, it looks through this file to find the addresses of servers and then asks them to supply a list of current packages. This file also lists other local sources, such as CD-ROMs that you may have used when you installed Debian.
A typical entry for an Internet-based software server will look something like:
deb http://ftp.au.debian.org/debian stable main contrib
Apt can intelligently handle multiple sources, so you can add extra lines to this file to get access to more software. If it sees the same package available from multiple sources, Apt will just pick the source that contains the highest version and install that.
Synaptic provides a very nice way to manage the entries in your sources.list without editing the file directly: just open the 'Settings' menu and select 'Repositories' for a nicely formatted list with options to add, delete, edit, enable and disable entries in the list.
So how do you find software servers to add to your sources.list? Servers providing Debian-compatible packages have started springing up all over the Internet, and there is a project underway to provide a centralised directory at www.apt-get.org. You can search for a package there, and it will tell you the lines you have to add to your sources.list to get access to the relevant server.
Note that third-party Debian packages may not be of the same quality as the official packages. If you download a package off a dubious source via the Internet, you have no idea what actually went into the package: it may be very high quality and carefully maintained, or it may be buggy and never updated. If you know what you're doing third party sources can be a boon, but always exercise caution when using anything other than the official sources.
| webmaster@phas.ubc.ca | [Dept. Home Page] | last updated: 08/01/11 |