Debian / Ubuntu Novice Package Management Cheat Sheet

For a long time, I was hungry for not knowing how to do some basic things in Debian package managers, but, as often happens, there was nobody to ask next to, and my hands didn’t get anywhere before writing. And finally, the questions matured and I wrote my question on the Debian newsletter . Naturally, it turned out that I had missed something obvious, but I also learned a lot of non-obvious usefulness, so I decided to sketch a cheat sheet, maybe someone comes in handy.

Debian Admin Quick Reference


Basic and well-known

Getting information about new / updated packages
sudo aptitude update

Update
sudo aptitude safe-upgrade

Search for a package by package name
aptitude search key_word

Search package by exact name
aptitude search "^name$"

Search by description
aptitude search "?description("key_word")"

Package Information
aptitude show package_name

Installation
sudo aptitude install package_name

Delete
sudo aptitude remove package_name

Complete removal (together with configs)
sudo aptitude purge package_name

Clear cache of downloaded packages (free up space)
aptitude autoclean # удалятся только пакеты неактуальных версий
aptitude clean # очистится весь кэш

Installing a separately downloaded / created package (to create a package from third-party sources, use the checkinstall utility with the -D flag)
sudo dpkg -i /path/to/package.deb

For more information
man aptitude
sudo aptitude install aptitude-doc-en

and look at the documentation (/usr/share/doc/aptitude/html/en/index.html), who needs quick help on search templates, here /usr/share/doc/aptitude/html/en/ch02s04.html. If you are too lazy to put a dock, then it is on the network .
Intro to Debian Wiki: wiki.debian.org/Aptitude

And now what is not obvious or requires a full reading of the documentation

1. How after update to see which packages will be updated?
aptitude search ?upgradable

You can also use (if set)
sudo daptup

but after installing it, regular update
2 will behave exactly the same way
. How can I find out what has changed in the packages that will be updated?
Can try
sudo aptitude changelog package_name

for each package.
But it’s better to put apt-listchanges, then before any installation of updates a list of changes will be shown, by default the settings are not very convenient, so it’s better to reconfigure for yourself, for example, choose the output format (while using text, it’s probably better to use pager for large updates), letters, ask for confirmation, display all information. To do this, run
sudo dpkg-reconfigure apt-listchanges

3. What should I do if the update breaks something and needs to be rolled back?
No rollback, you can try to find the previous version of the package
sudo aptitude version package_name

and install it
sudo aptitude install package_name=version

4. How to find all packages installed manually?
there is a variant of the command (aptitude search '~ i! ~ M'), but unfortunately it does not give the desired result, so the question remains open, there are a lot of ways based on the analysis of logs
/var/log/aptitude (+ ротированные куски)
/var/log/installer/initial-status.gz
/var/log/dpkg.log (+ ротированные куски)

but there is no simple and ready-made solution, yes, information could theoretically be lost during rotations, you need to configure
5. How do I see the list of files in a package?
if the package is installed
dpkg -L package_name

for any packages put apt-file and
apt-file list package_name

6. How to see which package the file belongs to?
dpkg -S file_name

7. How to remove all packages where there is key in the package name?
sudo aptitude purge ~ikey

8. How to remove the remaining configs from remote packages?
sudo aptitude purge ~c

9. How to find the package package that contains the lib.so file:
apt-file search lib.so

10. How to convert rpm package to deb?
alien --to-deb /path/to/file.rpm

11. How to find a list of installed kernels?
dpkg --list linux-* | grep ii

12. How to install a package from testing or experimental?
On this topic you need to write separately ( for example, like this ), but in short, there are commands for this
sudo aptitude -t testing package_name

or
sudo aptitude package_name/testing

13. How to remove a meta package but leave one of the dependencies?
you will have to read the documentation about the unmarkauto key or look here .

14. How to find out what got into the file system past the package management system?
There is a cruft utility, although the question of interpreting the results (report file) is still open
sudo cruft -d / -r report --ignore /home --ignore /var --ignore /tmp

15. What are the additional repositories?
Debian - wiki.debian.org/UnofficialRepositories
Ubuntu - all sorts of PPAs
16. What else?
apt-cdrom
apt-spy
auto-apt . apt-key
apt-key
apt-add-repository
Some things
only apt-get can do There are alternative utilities for managing packages, for example
wajig , which tries to incorporate the functionality of all other utilities.

17. How to find packages depending on this
apt-cache rdepends package_name

may also come in handy
aptitude why package_name


I thank everyone who helped with their advice in the newsletter , LiveJournal ( JackYF ) and Habré ( run4way , sledopit , nazarpc , Agafonoff , amarao , traaance , adrianopol , Karamax ) Comments and additions are welcome.