Usefull Command For Package Manager

Displaying installed files of a package

If you want to known all the files installed by a package, execute this command :

# dpkg -L name_of_package

and you will get an output that looks like this one :

root@debian:~# dpkg -L less
/.
/usr
/usr/bin
/usr/bin/less
/usr/bin/lesskey
/usr/bin/lessecho
/usr/bin/lesspipe
/usr/share
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/lessecho.1.gz
/usr/share/man/man1/lesspipe.1.gz
/usr/share/man/man1/less.1.gz
/usr/share/man/man1/lesskey.1.gz
/usr/share/doc
/usr/share/doc/less
/usr/share/doc/less/LESSOPEN
/usr/share/doc/less/README.Debian
/usr/share/doc/less/copyright
/usr/share/doc/less/changelog.gz
/usr/share/doc/less/changelog.Debian.gz
/usr/lib
/usr/lib/mime
/usr/lib/mime/packages
/usr/lib/mime/packages/less
/usr/bin/lessfile
/usr/share/man/man1/lessfile.1.gz

The same command for red hat based linux is :

# rpm -q -l package

and when you only known the filename of the package ( the rpm file ), use this command :

# rpm -q -l -p file_name_of_package

Packager owner of a file

If you want to known by which package was installed a files :

# dpkg -S /usr/lib/my_file

and you'll get an output like this one :

root@debian:~# dpkg -S /usr/bin/lessfile
less: /usr/bin/lessfile

And it does means that it was the package less that install the file !
And if you want to known what is this packages, read next section ! The same command for red hat based linux is :

# rpm -q -f file.txt

Showing description of a package

To have a brief description of a package, one brief line :

# dpkg -l less

and you will get :

root@debian:~$ dpkg -l less
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-f/Unpacked/Failed-cfg/Half-inst/t-aWait/T-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name                 Version              Description
+++-====================-====================-========
ii  less                 406-0                Pager program similar to more

As you can see, less is a program similar to more, as you probably already known what do this program. Otherwise, if you don't known, follow this link.

The same command for red hat based linux is :

# rpm -q -i package_name

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License