$ sudo debfoster

If you have installed/removed any packages, you will see an output something like below. As you see in the output, Screen package is not listed in my keepers list. Because, I installed it after creating the keepers list. So, debfoster asks me whether I want to keep this or not. If you're not sure what to do, type H to display the help section.

Keep screen? [Ynpsiuqx?], [H]elp: H Yes Keep screen. [default] No Delete screen. Prune Delete screen and the packages it is keeping installed. Skip Skip this question. Help Print this message. Info or ? Show information about screen. Undo Undo last response. Quit Exit without removing packages. Exit Remove unwanted packages and exit. Keep screen? [Ynpsiuqx?], [H]elp:

Debfoster will display all the possible options. Type Y if you don't want to remove the packages. The screen package will now be added to the keepers file and Debfoster will not remove it in the future transactions, unless you manually removed it yourself using "apt-get remove screen" command. Type N to delete the screen package. Type P to delete screen and the packages it is keeping installed. Type info or ? to display the details of the package. Q to exit without removing the package. And, type E to remove the packages and exit.

Viewing packages in the Keepers list

To view the list of packages in the debfoster database, run:

$ debfoster -a

Here is the list of packages in my Ubuntu 16.04 LTS desktop.

The following packages are on the keeper list: account-plugin-aim brasero debfoster deja-dup-backend-gvfs dialog firefox-locale-en gdebi gir1.2-webkit-3.0 git hyphen-en-us indicator-multiload language-pack-gnome-en libarchive-extract-perl libcpan-meta-perl libmodule-build-perl libmodule-pluggable-perl libpackage-constants-perl libpod-latex-perl libreoffice-help-en-us libreoffice-style-human libterm-ui-perl libtext-soundex-perl libvisual-0.4-plugins linux-generic linux-headers-4.4.0-15-generic linux-image-extra-4.4.0-15-generic myspell-en-au myspell-en-gb myspell-en-za mythes-en-us oneconf openoffice.org-hyphenation openssh-server python-pip python3-smbc rhythmbox-plugin-cdrecorder rhythmbox-plugin-magnatune samba-common screen shutter ssh-askpass-gnome telepathy-idle thunderbird-locale-en-us ubuntu-desktop ubuntu-minimal ubuntu-sso-client-qt ubuntu-standard ubuntu-wallpapers-wily wbritish xserver-xorg-video-cirrus xserver-xorg-video-mach64 xserver-xorg-video-mga xserver-xorg-video-neomagic xserver-xorg-video-openchrome xserver-xorg-video-r128 xserver-xorg-video-savage xserver-xorg-video-siliconmotion xserver-xorg-video-sisusb xserver-xorg-video-tdfx xserver-xorg-video-trident

Use different keeper file

By default, debfoster will maintain the installed packages at /var/lib/debfoster/keepers file. You can, however, specify a different debfoster database (keepers file, of course) using -k flag like below.

$ debfoster -k <path-to-keeper-file>

Viewing orphaned packages

You don't always need to run "sudo debfoster" command to check for the orphaned packages. You can simply use -s flag like below to view if there are any orphaned packages.

$ debfoster -s The following packages have been orphaned: tmux

As you see in the above output, I have one orphaned package. If it is necessary package and don't want debfoster to remove it, we can simply add it to the keepers file by running the following command:

$ sudo debfoster

It will ask you to keep tmux or not. If you keep the tmux in keepers file, simply type Y.

Keep tmux? [Ynpsiuqx?], [H]elp:Y

Alternatively, you can manually edit the keepers file and add tmux in the list.

$ sudo vi /var/lib/debfoster/keepers

Add tmux in it.

[...] tmux

Type :wq to save an quit the file. Now, you will not see any orphaned packages when running "debfoster -s" command.

Please note that here orphaned package means a package which is not mentioned in the debfoster database. It doesn't mean the package is completely not necessary. For example, screen and tmux utilities are quite useful. So, we can add them to debfoster database.

Adding/removing packages

Since debfoster is a wrapper for apt-get and dpkg package managers, you can also use it to add or remove packages.

To install a package, run:

$ sudo debfoster screen

Now debfoster will run apt-get for you and install the specified package.

To remove a package, simply place a minus (−) directly after its name like below.

$ sudo debfoster screen- Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: screen* 0 upgraded, 0 newly installed, 1 to remove and 608 not upgraded. After this operation, 972 kB disk space will be freed. Do you want to continue? [Y/n]

Finding dependencies

To list all packages that a package depends on, use -d flag.

$ debfoster -d screen

And, to list all packages in the debfoster database that depend on the given package, use -e flag like below.

$ debfoster -e screen

For more details, refer the man pages.

$ man debfoster

As you can see, Debfoster helps you to keep track of what you've installed and remove all other packages which are not required. Again, I warn you - you must use this application very carefully. Don't remove important system-related packages like Ubuntu-base, grub, current Kernel etc. If you do, you may end up with an unusable system.

Suggested read: