Orphan Package removal

From PacBSD Wiki
Revision as of 07:24, 8 May 2014 by Claud (talk | contribs) (Created page with "=Introducing the Orphans= As the months turn into years since the initial install of our Arch based installations, (isn't the rolling release system wonderful) we tend to acc...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introducing the Orphans

As the months turn into years since the initial install of our Arch based installations, (isn't the rolling release system wonderful) we tend to accumulate orphan packages that are basically just useless clutter on our HDDs.

Some ways of dealing with this problem follow:

pacman -Qdt  

will give you a list of packages installed as dependency for another package that are no longer required, i.e. orphans.

You can automatically remove them, along with their dependencies, with something like:

pacman -Rs $(pacman -Qqdt)

Though I prefer to manually highlight, copy & paste them (with a space between them) onto a command line after the following:

sudo pacman -Rsn

I call the above command with my ~/.bashrc alias pdelete . Which means I just have to enter pdelete at the user prompt & add whatever I want deleted after that word.

The alias follows, but first you'll need to open ~/.bashrc in your favourite text editor. Which is not so simple as it is a hidden file, as can be seen by the <.dot> at the start of its name.

An easy way to open it is to type the following into your Terminal replacing <text.editor.name> with the name of your text editor, such as gedit. There is no need to use sudo as this file is from your user account not that of the root:

<text.editor.name> .bashrc

OK, back to the alias; if you like it, you can just copy (highlight the text by triple left mouse button clicking on it & then from the right mouse button menu choose copy) & paste (right mouse button menu again) it into your ~/.bashrc file:

alias pdelete="sudo pacman -Rsn"

Manipulate orphan list

Sometimes a package that pacman detects as an orphan may be a program that you still use. This is because that program originally came as a dependency of another package, but you removed the latter. When running the above command to automatically remove orphans, you may accidentally remove such packages. To prevent this from happening you can solve this by tricking pacman that it is an explicitely installed package:

pacman -D --asexplicit <packagename>

For example: Some users reported that gnome-shell showed up in their list of orphans, while they actually were still using it. After using the command below everything should be fine.

pacman -D --asexplicit gnome-shell

A practical example:

I just cleaned out my system, which was initially a Manjaro Gnome/Cinnamon install (for a brief period), before I deleted Gnome/Cinnamon & installed Openbox & customised my system to suit the way I like it to be.

Even though I have already manually deleted quite a bit of stuff, I just removed the following (not all of that was Gnome/Cinnamon leftovers but they were ALL orphans):

Targets (22): intltool-debian-0.35.0-2  mysql-clients-5.5.29-1  bluez-hcidump-2.4-1  boost-1.50.0-3
             bzr-2.5.1-2  cmake-  consolekit-0.4.6-4  dos2unix-6.0.2-1  dpkg-1.16.9-1
             dri2proto-2.8-1  glproto-1.4.16-1  html2text-1.3.2a-9  imake-1.0.5-1
             lib32-mesa-9.0.1-1  mhwd-catalyst-legacy-12.6-2  mysql-5.5.29-1
             perl-io-string-1.08-8  perl-timedate-1.20-3  po-debconf-1.0.16-2  po4a-0.42-1
             python2-distribute-0.6.32-1  rrdtool-1.4.7-3

Total Removed Size:     338.79 MiB

So now I have 338.79 MB more space on my drive & that much less clutter.

Handling the pacman .pac* files:

For anyone unfamiliar with the .pac* files here is the best place to find out about them: [1]

In order to keep your Manjaro system clean & functioning properly, we need to firstly locate these .pac* files (which are built into pacman in an effort to maintain stability - please read the info' in the supplied link re. these files?) so that we can have a look at them & decide if they are of any value or not.

Finding the .pac* Files

They can be found in a variety of ways: I like the use of the locate command, as it is very quick & very slick:

locate -e --regex "\.pac(new|save|orig)$"

For anyone who doesn't have locate on their machine they need to install mlocate which is done from the command line with the following command:

sudo pacman -S mlocate

Though I do the same thing by typing in the following which uses an alias from my ~/.bashrc :

pS mlocate

& then run updatedb as root like so:

sudo updatedb

This command will very quickly make a database of all of the files on your system & as a bonus, when you install mlocate it installs a script that sets up a daily cron job with the purpose of updating the database every day for you. Though you can of course do it manually by issuing the above command any time you want.

If you were going to issue the updatedb command often, you may like to make an alias for it. From what you have seen of my aliases you should be able to put one together without much trouble.

Is the .pac* file useful?

You need to look at the contents of the .pac* files with your text editor. Due to them being files owned by root , you will need to at least use sudo to call your editor if you need to modify your original configuration file with changes bought in by the .pacnew file. (I expect that this is usually going to be taken care of by the Manjaro dev' team. I'll verify that & modify the text here accordingly.)

If once checked we find that the .pac* files are of no value, we delete them, most of them are of no value, but we should look before we delete as sometimes, particularly .pacnew files can carry critically important new configuration file changes.

So there are three types of files that we need to deal with:

*.pacnew , *.pacsave & *.pacorig

For information on these files the best place to look is on this page in the Archwiki: [2]

Other ways to do it:

There are other options to be found in the AUR that have been made for dealing with the .pac* files, here is a list from the Archwiki: [3]

A .pac* file Summation:

I think the thing that those new to the Arch rolling release system need to keep in mind, is that these .pac* files are seldom a cause for problems. Most Arch users don't even bother looking at them or for them & perhaps once in a while have a clean out.

So don't stress over these things. If there is something important that has to happen involving one or more of them, I'm sure it will be made very obvious in the Manjaro forum & blog. Though more likely it will be done for you by the dev' team.

Removing leftover <.dot> configuration files from the /home directory:

Mundus is a tool with a GUI that can make this job easy. Especially for people that are unfamiliar with their system's hidden <.dot> configuration files.

The following is from this page: [4]

Mundus is a small utility that can help you keep your /home folder clean. It keeps an internal database of known applications and folders, and automagically detects those apps that where uninstalled but left configuration files. Each supported application is also called a module, and each folder it describes is called a submodule.


There are two options to make backups before cleaning a directory.


If the directory to clean is below the size limit, a backup will be automatically executed before the clean begins.


The alternative, just click the Backup button when selecting a submodule.

Mundus can be installed in Manjaro with the following command:

yaourt -S mundus

The /var/log Directory:

In keeping with the topic of this thread, I'll mention that it's also a good idea to keep an eye on the /var/log directory, in case some logs are growing too large - (in fact log files growing large in a short period of time can mean you have problems in your system). During my Arch days, I'd trim my log files down from time to time, usually I'd keep just the last 30 days.

You must have root privileges to edit the log files, so you need to open your favourite text editor in root mode. An example follows:

sudo gedit

A method to easily remove any number of orphan or just unwanted programs

Quickly make a list of all of the pacman installed programs on your system

You can use the following command to get a list of all of the packages installed on your machine via pacman (this command doesn't list packages installed from the AUR):

$ pacman -Qqen > pkglist.txt 

If you open the Terminal & just copy & paste the above command (without the $ terminal prompt - which is here to tell you that we can do this with user privilege, no need for # root privileges) into the command line & hit enter, the list will be saved in your /home/<user.name> folder (so quickly you will think that the command failed).

Easily view your new pkglist.txt

Type the following to see the list (you can of course open it with your favourite text editor too):

$ more pkglist.txt

When you use more , you hit the space bar to move to the next page, you can scroll back through it using your mouse, & hitting q quits more & instantly returns you to the command prompt.

So what do you do with this pkglist.txt?

The reason I'm telling you about this, is that it gives you the actual names of the packages that you need to use when you delete them (you can do other things with this list too, see here: [5] ).

Doing it this way is much easier than searching through your /var/cache/pacman/pkg directory, you can highlight the files that you want to delete & then move to another tab in your Terminal where you paste them to the command line that you use do delete them (the delete command is next).

How do I delete these unwanted programmes?

Deleting what you want to is as easy as adding the files that you don't want separated by a space to the following command, I'll add some files in the example below:

$ sudo pacman -Rsn leafpad vlc terminator geany mplayer gufw

Sometimes when you put a lot of files in a list to operate on, the system will complain about some of them for whatever reasons. If this happens you just hit the up arrow button to bring your original command line with the packages in it that you want to delete & using your left & right arrow (cursor control) keys, you navigate the command line & remove the troublesome file(s) from the list you want to delete.