How to find which user installed a package in linux?

by viola_gleichner , in category: General Help , a month ago

How to find which user installed a package in linux?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by aglae_feil , a month ago

@viola_gleichner 

To find which user installed a package in Linux, you can use the apt or dpkg command along with some filtering and querying options.


If you are using a Debian-based system (such as Ubuntu), you can use the apt command to find the installation history of a package:

  1. Open a terminal.
  2. Run the following command to show the log of installed packages: zgrep " install " /var/log/dpkg.log* This command will display the installation history of packages in the /var/log/dpkg.log* files.
  3. Look for the package you are interested in and find the username listed next to it. The first part of each line in the dpkg.log file lists the date and time, followed by the username who executed the installation command.


If you are using a system that uses dpkg for package management (such as Debian itself), you can use the dpkg command to find the owner of an installed package:

  1. Open a terminal.
  2. Run the following command to list all packages along with their owners: dpkg -l | grep '^ii' | awk '{print $2}' | xargs -n1 dpkg -s | grep 'Package|Maintainer' This command will provide a list of installed package names along with the user who installed them.
  3. Search for the specific package you are interested in and find the "Installed-By" or "Maintainer" field, which typically contains the username of the installer.


Note: Both methods assume that the system has not been modified to remove or overwrite the package installation logs.