Most common Linux Commands

Other commands:

  1. apt-cache search (sudo not required)

It is useful to get the exact package names to be used for an “apt install”. I use “apt-cache search”. For example:

apt-cache search numpy | grep python3

Of course these days one can also do a search with apt (apt has the best of apt-get, apt-cache, …), but I find it to not be as reliably grep-able.

  1. dpkg --get-selections and “sudo dpkg --set-selections”

The first gives a list of installed/deinstalled pacakges. The second will set dpkg selections so that if you do a “sudo apt update” and “sudo apt upgrade” it will install all the packages. I find this useful if I’ve done a lot of installs and I want to wipe and reinstall with the same package selections.

dpkg --get-selections > package_list.txt

And after a system reinstall one can duplicate those installed packages by copying that package_list.txt file and setting those selections:

sudo dpkg --set-selections < package_list.txt
sudo apt update
sudo apt upgrade

2 Likes