Ubuntu – .deb equivalents to .rpm commands

debpackage-management

I'm used to RPM based systems, and there's many commands I'm not yet sure how to do with .deb packages. This is mostly for use with custom packages, i.e. not stuff apt-get installed.

It'd be great if someone could provide a translation of the commands here:
(by "package file" it's meant to operate on a physical .rpm/.deb file)


Feature                              rpm                                deb
----------------------------------------------------------------------------------
View all installed packages          rpm -qa
View files in an installed package   rpm -ql packagename
View files in an package file        rpm -qlp ./packagename.rpm
View package info, installed package rpm -qi packagename (1)
View package info, package file      rpm -qip ./packagename.rpm (1)
View pre/post install shell scripts  rpm -q --scripts packagename
View changelog for a package file    rpm -qp --changelog ./packagename.rpm
Uninstall a package                  rpm -e packagename                    dpkg -r/dpkg -P
Install a package file               rpm -ivh ./packagename.rpm            dpkg -i
Upgrade a package from a file        rpm -Uvh ./packagename.rpm
Find which package owns a file       rpm -qif /some/file.foo
List dependencies of a package       rpm -q --requires packagename
List dependencies of a package file  rpm -qp --requires ./packagename.rpm

(1) see e.g. info output example here

Best Answer

I try to fill or complement what @SeanBright leaved out:

Feature                              rpm                                   deb
----------------------------------------------------------------------------------
View all installed packages          rpm -qa                               dpkg -l, dpkg-query -Wf '${Package}\n'
View package info, installed package rpm -qi packagename (1)               apt-cache show packagename
View pre/post install shell scripts  rpm -q --scripts packagename          cat /var/lib/dpkg/info/packagename.{pre,post}{inst,rm}
View changelog for a package file    rpm -qp --changelog ./packagename.rpm dpkg-deb --fsys-tarfile packagename.deb | tar -O -xvf - ./usr/share/doc/packagename/changelog.gz | gunzip
Uninstall a package                  rpm -e packagename                    apt-get remove/purge packagename
Upgrade a package from a file        rpm -Uvh ./packagename.rpm            dpkg -i packagename.deb
Find which package owns a file       rpm -qif /some/file.foo               dpkg -S /dome/file.foo
List dependencies of a package       rpm -q --requires packagename         apt-cache depends package
List dependencies of a package file  rpm -qp --requires ./packagename.rpm  (shown in package's info)
Related Question