I am trying to write a script where I can tell whether the package is a pre-installed or it was installed by user.

And also can we have way to get to know that following are the dependencies of the package 'X'

  • 2
    please clarify what package manager you are using. You use both rpm and dpkg tags which is very confusing. – Chris Maes Apr 3 '20 at 5:47
  • I was looking for both actually, that's why added both tags. Anyways, I have removed dpkg.. – Dharmender Lodhi Apr 3 '20 at 6:21
  • 2
    In the APT world, the opposite of manual is automatic, not system. And more than essential can be installed at operating system installation time. The assumed dichotomy underpinning the entire question is simply not the case. – JdeBP Apr 3 '20 at 6:56

on the rpm level you cannot really know. Depending on the package manager you use there might be some information stored there.

Note that this only works if the user ran the installation commands with sudo. If he became root, you'll never know who did it.


yum history

gives you a list of transactions and which user launched the command.


dnf history

gives you a list of transactions, but doesn't list the user by default. You can however run:

dnf history info <ID>

and then you will see the user who launched the command


there is no way to know this afaik.

  • yum history is giving the username and install only, but which package is installed isn't specified. – Dharmender Lodhi Apr 3 '20 at 6:24
  • it is specified if you dig into the transaction (same as dnf): yum history info <ID> – Chris Maes Apr 3 '20 at 7:04

Your tags are unclear, we don't know which package manager you use. But since you used the tag arch-linux I am going to answer for pacman.

Well the first question is a hard one, it is not really possible to my knowledge and heavily depends on your installation. There isn't one standard Linux installation since there are many different distributions, desktop environments, installer options,... But one way would be to look up which groups of packages are installed with your setup and get the other ones (which are likely to be installed by the user) with the following command: comm -23 <(pacman -Qeq | sort) <(pacman -Qgq base | sort) where base is one of the groups that you got preinstalled for sure.

To the second part of the question: You can get information about a package using pacman -Si <yourpackage> and if you want to get the output reduced to just the dependencies check out this thread

  • +1 for "tags are unclear" – Chris Maes Apr 3 '20 at 5:47
  • 1
    @ChrisMaes It would have been better to comment that but I have a too low reputation to do that, so I wrote an answer and put it into there. By the time I wrote it I saw that you already commented that ^^ – luca Apr 3 '20 at 5:50

Check the packages included with the distro in question at installation time at the distro's website. Those are pre-installed; everything else was added post-insta;;/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.