{"id":434,"date":"2014-12-24T18:03:13","date_gmt":"2014-12-24T16:03:13","guid":{"rendered":"http:\/\/www.bashpi.org\/?page_id=434"},"modified":"2025-01-15T12:21:52","modified_gmt":"2025-01-15T10:21:52","slug":"package-management","status":"publish","type":"page","link":"https:\/\/www.bashpi.org\/?page_id=434","title":{"rendered":"Package management"},"content":{"rendered":"<p>As I have to deal with both Red Hat and Debian based Linux distributions, I decided to make my own comparison cheat-sheet for the package management. It would look really nice as table where everything is side-by-side but it would not fit here in that way. Note for beginners: rpm\/yum\/dnf\/repoquery\/yumdownloader are package management tools in <a href=\"http:\/\/en.wikipedia.org\/wiki\/List_of_Linux_distributions\">Red Hat based distros<\/a> and apt*\/dpkg* in <a href=\"http:\/\/en.wikipedia.org\/wiki\/List_of_Linux_distributions\">Debian based distros<\/a>. Apk is used in Alpine Linux.<\/p>\n<p><strong>HINT: If you know, what is the command in debian and want to know what is it in red-hat or vice-versa, use your browser search! <\/strong><\/p>\n<ul>\n<li>Refresh information coming from repositories<\/li>\n<\/ul>\n<pre><code class=\"language-bash\">yum clean metadata\napt-get update\napk update\n<\/code><\/pre>\n<p>Note: yum will reload package info on next run.<\/p>\n<ul>\n<li>Search package from available repositories by partial package name<\/li>\n<\/ul>\n<pre><code class=\"language-bash\">yum list &lt;partial package name&gt;\u00a0\napt-cache search &lt;search string&gt;\napk list &lt;search string&gt;  # use leading\/trailing wildcards!\n<\/code><\/pre>\n<ul>\n<li>Search package from available repositories by string in information\/description<\/li>\n<\/ul>\n<pre><code class=\"language-bash\">yum search &lt;search string&gt;\napt-cache search &lt;search string&gt;\napk search &lt;search string&gt;\n<\/code><\/pre>\n<ul>\n<li>Install package from repository<\/li>\n<\/ul>\n<pre><code class=\"language-bash\">yum install &lt;package name&gt;\napt-get install &lt;package name&gt;\napt install &lt;package name&gt;\napk add &lt;package name&gt;<\/code><\/pre>\n<ul>\n<li>Install package from given package file, without dependencies<\/li>\n<\/ul>\n<pre><code class=\"language-bash\">rpm -ivh &lt;rpm-file&gt;\ndpkg -i &lt;deb-file&gt;<br class=\"language-bash\" \/><\/code><\/pre>\n<p>Note: You will keep getting errors with Debian tools like dpkg\/apt until you satisfy dependencies.<\/p>\n<ul>\n<li>Install package from given file and resolve dependencies<\/li>\n<\/ul>\n<pre><code class=\"language-bash\">yum install &lt;rpm-file&gt;\ndpkg -i &lt;deb-file&gt;; apt-get -f install\n<\/code><\/pre>\n<p>Note: <em>yum localinstall &lt;rpm-file&gt;<\/em> has same results<\/p>\n<ul>\n<li>Reinstall package, useful if you have manually deleted\/changed some content<\/li>\n<\/ul>\n<pre>yum reinstall &lt;package name&gt;<\/pre>\n<ul>\n<li>Upgrade package with new version from package file or install if it is not yet installed<\/li>\n<\/ul>\n<pre>\u00a0rpm -Uvh &lt;rpm-file&gt;<\/pre>\n<ul>\n<li>Upgrade all packages \/ Install all upgrades<\/li>\n<\/ul>\n<pre>yum update\napt-get upgrade<\/pre>\n<ul>\n<li>Upgrade specific package<\/li>\n<\/ul>\n<pre>yum update &lt;package name&gt;<\/pre>\n<ul>\n<li>Upgrade specific package to specific version<\/li>\n<\/ul>\n<pre>yum upgrade-to &lt;package name&gt;-&lt;version&gt;<\/pre>\n<p>Note: For example <em>yum upgrade-to wget-1.11.4-3.el5_8.2<\/em><\/p>\n<ul>\n<li>Remove installed package but keep configuration files<\/li>\n<\/ul>\n<pre>dpkg -r &lt;package name&gt;\napt-get remove &lt;package name&gt;<\/pre>\n<ul>\n<li>Remove installed packages along with all configuration files and created directories<\/li>\n<\/ul>\n<pre>rpm -ev &lt;package name&gt;\nyum remove &lt;package name&gt;\ndpkg -P &lt;package name&gt;<\/pre>\n<p>Note: Another word for this operation is purge<\/p>\n<ul>\n<li>Remove automatically installed packages (remove packages which were installed automatically to satisfy dependencies).<\/li>\n<\/ul>\n<pre>apt-get autoremove<\/pre>\n<p>To remove automatically installed dependencies with yum, use yum history to get the transaction ID and then undo\/rollback the transaction. It will only remove packages and dependencies installed during one transaction.<\/p>\n<pre>This gives you transaction ID (column 1)\n# yum history list packagename\nThis will rollback the transaction\n# yum history undo &lt;ID&gt;<\/pre>\n<ul>\n<li>Download package from repository<\/li>\n<\/ul>\n<pre>apt-get download &lt;package name&gt;\nyumdownloader &lt;package name&gt;\n<\/pre>\n<p>Note: This is just download without installing<\/p>\n<ul>\n<li>Display installed package name from which specific file originated<\/li>\n<\/ul>\n<pre>rpm -qf &lt;filename with full path&gt;\nrepoquery --plugins -f &lt;filename with full path&gt;\ndpkg -S &lt;filename with full path&gt;<\/pre>\n<ul>\n<li>Display not installed package name which will provide specific file<\/li>\n<\/ul>\n<pre>yum provides &lt;filename with full path&gt;\napt-file -Fl search &lt;filename with full path&gt;<\/pre>\n<p>Note: Run apt-file update first<\/p>\n<ul>\n<li>Display all installed packages<\/li>\n<\/ul>\n<pre>rpm -qa\nyum list installed\nrepoquery --plugins -a --installed\ndpkg --list<\/pre>\n<ul>\n<li>Display all packages available from repositories<\/li>\n<\/ul>\n<pre>yum list\nrepoquery --plugins -a\napt-cache pkgnames<\/pre>\n<ul>\n<li>Display information about installed package<\/li>\n<\/ul>\n<pre>rpm -qi &lt;package name&gt;\ndpkg -p &lt;package name&gt;<\/pre>\n<ul>\n<li>Display information about uninstalled package file<\/li>\n<\/ul>\n<pre>rpm -qpi &lt;rpm-file&gt;\ndpkg --info &lt;deb-file&gt;<\/pre>\n<ul>\n<li>Display file lists (contents) of uninstalled package file<\/li>\n<\/ul>\n<pre>rpm -qpl &lt;rpm-file&gt;\ndpkg -c &lt;deb-file&gt;<\/pre>\n<ul>\n<li>Display file lists (contents) of installed package (originating files)<\/li>\n<\/ul>\n<pre>rpm -ql &lt;package name&gt;\ndpkg -L &lt;package name&gt;<\/pre>\n<ul>\n<li>Display information about package available from repository<\/li>\n<\/ul>\n<pre>yum info &lt;package name&gt;\nrepoquery --plugins -i &lt;package name&gt;\napt-cache showpkg &lt;package name&gt;<\/pre>\n<ul>\n<li>Display file list of package available from repository<\/li>\n<\/ul>\n<pre>repoquery --plugins -l &lt;package name&gt;\n<\/pre>\n<ul>\n<li>Display list of most recently installed packages with dates<\/li>\n<\/ul>\n<pre>\u00a0rpm -qa --last<\/pre>\n<ul>\n<li>Display package management history<\/li>\n<\/ul>\n<pre>\u00a0yum history<\/pre>\n<p>Note: If history command does not exist, your yum version is too old<\/p>\n<ul>\n<li>Display configuration files of specific package<\/li>\n<\/ul>\n<pre>\u00a0rpm -qc &lt;package name&gt;<\/pre>\n<ul>\n<li>Display configuration files associated with specific file<\/li>\n<\/ul>\n<pre>\u00a0rpm -qcf &lt;filename with full path&gt;<\/pre>\n<ul>\n<li>Display package dependencies<\/li>\n<\/ul>\n<pre>rpm -qpR &lt;rpm-file&gt;\nrpm -qR &lt;package name&gt;<\/pre>\n<ul>\n<li>Clean package cache only<\/li>\n<\/ul>\n<pre>\u00a0yum clean packages<\/pre>\n<ul>\n<li>Clean package cache, metadata and everything else<\/li>\n<\/ul>\n<pre>yum clean all\napt-get clean<\/pre>\n<ul>\n<li>Extract rpm \/ deb package contents without installing<\/li>\n<\/ul>\n<pre>rpm2cpio &lt;rpm-file&gt; |cpio -idmv\ndpkg -x &lt;deb-file&gt; &lt;target-directory&gt;<\/pre>\n<ul>\n<li>Is rpm file relocatable ?<\/li>\n<\/ul>\n<pre><code>rpm -qpi &lt;rpm-file&gt; | grep Relocations\n<\/code><\/pre>\n<ul>\n<li>Install package to different location &#8211; can be done by root and non-root user if package is relocatable and you have write rights to the specified location<\/li>\n<\/ul>\n<pre><code>rpm -Uvh --prefix \/alternate\/location &lt;relocatable-rpm-file&gt;<\/code><\/pre>\n<ul>\n<li>Display RPM GPG key signature and ID &#8211; useful when adding channel to Spacewalk\/ RHEL Satellite. Green and Blue is the signature. Blue is ID.<\/li>\n<\/ul>\n<pre><code># gpg --quiet --with-fingerprint RPM-GPG-KEY-graylog\npub 2048R\/B1606F22 2014-06-04 TORCH GmbH &lt;packages@torch.sh&gt;\nKey fingerprint = <span style=\"color: #008000;\">28AB 6EB5 7277 9C2A D196 BE22 <span style=\"color: #0000ff;\">D44C 1D8D<\/span> B160 6F22<\/span>\n<\/code><\/pre>\n<ul>\n<li>Install rpm without GPG check<\/li>\n<\/ul>\n<pre><code># yum --nogpgcheck install &lt;package name&gt;<\/code><\/pre>\n<ul>\n<li>Install GPG key<\/li>\n<\/ul>\n<pre><code># rpm --import &lt;gpg-key-file&gt;<\/code><\/pre>\n<p>To be continued.<\/p>\n<p>If you found this useful, say thanks, click on some banners or <a href=\"http:\/\/www.bashpi.org\/?page_id=105\">donate<\/a>, I can always use some beer money.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As I have to deal with both Red Hat and Debian based Linux distributions, I decided to make my own comparison cheat-sheet for the package management. It would look really nice as table where everything is side-by-side but it would not fit here in that way. Note for beginners: rpm\/yum\/dnf\/repoquery\/yumdownloader are package management tools in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":397,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-434","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.bashpi.org\/index.php?rest_route=\/wp\/v2\/pages\/434","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bashpi.org\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bashpi.org\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bashpi.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bashpi.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=434"}],"version-history":[{"count":24,"href":"https:\/\/www.bashpi.org\/index.php?rest_route=\/wp\/v2\/pages\/434\/revisions"}],"predecessor-version":[{"id":1141,"href":"https:\/\/www.bashpi.org\/index.php?rest_route=\/wp\/v2\/pages\/434\/revisions\/1141"}],"up":[{"embeddable":true,"href":"https:\/\/www.bashpi.org\/index.php?rest_route=\/wp\/v2\/pages\/397"}],"wp:attachment":[{"href":"https:\/\/www.bashpi.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}