{"id":4375,"date":"2023-06-12T10:25:15","date_gmt":"2023-06-12T17:25:15","guid":{"rendered":"https:\/\/jasonsblog.ddns.net\/?p=4375"},"modified":"2023-06-12T11:47:03","modified_gmt":"2023-06-12T18:47:03","slug":"the-beginners-guide-to-using-pacman-on-arch-linux","status":"publish","type":"post","link":"https:\/\/jasonsblog.ddns.net\/index.php\/2023\/06\/12\/the-beginners-guide-to-using-pacman-on-arch-linux\/","title":{"rendered":"The Beginner&#8217;s Guide to Using Pacman on Arch Linux"},"content":{"rendered":"\n<p>This is a good write up on using Pacman with some options you wouldn&#8217;t use that often, so if you&#8217;re newer to Arch or Arch based distributions like I am, this is a good overview and reference to build upon. For example, I like to use &#8220;sudo pacman -Syyuu&#8221; when I update. But of particular interest removing packages with dependencies no longer in use, removing orphaned packages, and clearing the package cache which could be taking up gigabytes of disk space.<\/p>\n\n\n\n<p><a href=\"https:\/\/linuxiac.com\/how-to-use-pacman-to-manage-software-on-arch-linux\/\">https:\/\/linuxiac.com\/how-to-use-pacman-to-manage-software-on-arch-linux\/<\/a><\/p>\n\n\n<div class=\"wp-block-ub-divider ub_divider ub-divider-orientation-horizontal\" id=\"ub_divider_8820c8fa-013d-4c6f-bc9a-fb9238142f75\"><div class=\"ub_divider_wrapper\" style=\"position: relative; margin-bottom: 2px; width: 100%; height: 2px; \" data-divider-alignment=\"center\"><div class=\"ub_divider_line\" style=\"border-top: 2px solid #ccc; margin-top: 2px; \"><\/div><\/div><\/div>\n\n\n<p>By Bobby Borisov<\/p>\n\n\n\n<p><strong>This guide shows how to use Pacman package manager on Arch Linux to manage the software by installing, removing, and updating packages.<\/strong><\/p>\n\n\n\n<p>Want to install packages on Arch Linux but need to know how? Many people run into this issue when they first <a href=\"https:\/\/linuxiac.com\/arch-linux-install\/\">move to Arch<\/a>. But don\u2019t worry; you can easily manage packages on your Arch system using the <code>pacman<\/code> command. But first, let\u2019s answer an important question.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-pacman-package-manager\">What Is Pacman Package Manager?<\/h2>\n\n\n\n<p>Pacman (stands for&nbsp;<strong>Pac<\/strong>kage&nbsp;<strong>Man<\/strong>ager) is the default package manager for <a href=\"https:\/\/linuxiac.com\/archlinux\/\">Arch Linux<\/a>, a lightweight and flexible distro popular among experienced Linux users. Like Arch, Pacman is known for its simplicity, speed, and reliability, combining a simple binary package format with an easy-to-use&nbsp;build system.<\/p>\n\n\n\n<p>Pacman keeps the system up to date by synchronizing package lists with the official Arch repositories. In addition, this client-server model allows the user to download\/install packages with a simple command, complete with all required dependencies.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-will-you-learn-in-this-guide\">What Will You Learn in This Guide?<\/h2>\n\n\n\n<p>We will cover the basics of Pacman, including how to install, update, and remove packages, as well as some more advanced features and tips for using Pacman to its full potential. So, whether you are new to Arch or an experienced Linux user, this guide will help you get the most out of the Pacman.<\/p>\n\n\n\n<p>In addition, this guide also applies to all <a href=\"https:\/\/linuxiac.com\/best-arch-based-linux-distributions\/\">Arch-based Linux distros<\/a>, such as Manjaro, EndeavourOS, Garuda Linux, etc., using Pacman as the package manager.<\/p>\n\n\n\n<p>Of course, the official packages are just one of the sources of software on Arch. In addition, you can install some of the thousands available in the AUR repository \u2013 Arch\u2019s most significant asset that differentiates it from all other Linux distributions.<\/p>\n\n\n\n<p>However, to do this, different Pacman tools are used, known as AUR helpers. In that case, our comprehensive guide on the subject, \u201c<a href=\"https:\/\/linuxiac.com\/how-to-install-aur-packages-in-arch-linux\/\">How to Install AUR Packages in Arch Linux<\/a>,\u201d will greatly help you.<\/p>\n\n\n\n<p>Finally, you can even use one of the excellent <a href=\"https:\/\/linuxiac.com\/best-pacman-gui-frontends-for-arch-linux\/\">GUI Pacman frontends<\/a> to make installing packages in Arch as easy as possible.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-refresh-package-lists\">Refresh Package Lists<\/h2>\n\n\n\n<p>Because Arch is a <a href=\"https:\/\/linuxiac.com\/what-is-rolling-release-linux-and-what-is-the-real-benefit-of-using-it\/\">rolling-release distro<\/a>, new packages are added to the distro\u2019s repositories as soon as they are released. As a result, you should keep the Pacman database up to date by updating it fairly frequently.<\/p>\n\n\n\n<p>So, to update the package lists before installing any packages or updating the system, perform the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pacman -Sy<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-searching-for-package\">Searching for Package<\/h2>\n\n\n\n<p>To search for a specific package, for example, <code>vlc<\/code>, from a sync database (remote server), run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pacman -Ss vlc<\/code><\/pre>\n\n\n\n<p>This returns all packages with a matching \u201c<em>vlc<\/em>\u201d string in the package name or description.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-getting-information-about-package\">Getting Information About Package<\/h2>\n\n\n\n<p>To display the detailed information of the given package from the sync database, for example, <code>nginx<\/code>, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pacman -Si nginx<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-installing-a-new-package-with-pacman\">Installing a New Package with Pacman<\/h2>\n\n\n\n<p>Installing a package with Pacman is easy. Just run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pacman -S vlc<\/code><\/pre>\n\n\n\n<p>As a result, this process will automatically identify all the necessary dependencies and take care of them. In addition, to install multiple packages with a single command, use a space-separated list of packages.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-installing-a-local-package\">Installing a Local Package<\/h2>\n\n\n\n<p>Pacman stores all downloaded packages in the&nbsp;<code>\/var\/cache\/pacman\/pkg<\/code>&nbsp;directory.<\/p>\n\n\n\n<p>In case you want to install the locally downloaded package, for example,&nbsp;<code>vlc<\/code>,&nbsp;located in \/var\/cache\/pacman\/pkg\/ directory, go to the folder where the package is located and enter the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/var\/cache\/pacman\/pkg\/\nsudo pacman -U vlc-3.0.11-2-x86_64.pkg.tar.zst<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-update-upgrade-a-package\">Update\/Upgrade a Package<\/h2>\n\n\n\n<p>To update a single package, for example, <code>rsync<\/code>, run the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pacman -S rsync<\/code><\/pre>\n\n\n\n<p>To update all packages at once on your system, just run the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pacman -Syu<\/code><\/pre>\n\n\n\n<p>However, sometimes you want to upgrade the packages, but you want it to stay at an older version (because you know the newer version has removed a feature or is broken).<\/p>\n\n\n\n<p>So, if&nbsp;the <code>vlc<\/code> package&nbsp;was causing the problem, you could use the following command for this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pacman -Syu --ignore=vlc<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-remove-a-package-with-pacman\">Remove a Package with Pacman<\/h2>\n\n\n\n<p>To remove a package alongside with all its dependencies, run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pacman -Rs vlc<\/code><\/pre>\n\n\n\n<p>This command will altogether remove&nbsp;the <code>vlc<\/code>&nbsp;package and all dependencies. While removing packages, Pacman will keep the critical configuration files with the extension&nbsp;<code>.pacsave<\/code>.<\/p>\n\n\n\n<p>In addition, if you no longer want them and want to free up the hard drive, you can remove the package along with all its configuration files with the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pacman -Rns vlc<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-remove-orphaned-unused-packages\">Remove Orphaned (Unused) Packages<\/h2>\n\n\n\n<p>After removing a package in Arch Linux, there may still be some remaining orphaned (unused) packages that were dependencies of the removed package. However, these orphaned packages are not required anymore, so we can get rid of them to free up some space.<\/p>\n\n\n\n<p>To remove these packages, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pacman -Rns $(pacman -Qdtq)<\/code><\/pre>\n\n\n\n<p>If no orphans were found, the output is:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-searching-for-already-installed-packages\">Searching for Already Installed Packages<\/h2>\n\n\n\n<p>Sometimes you want to check for a specific package if it is installed locally. In this case, you can do it using the command below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pacman -Qs vlc<\/code><\/pre>\n\n\n\n<p>You can view a list of all the packages installed on your system using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pacman -Q<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-find-all-files-owned-by-a-package\">Find All Files Owned by a Package<\/h2>\n\n\n\n<p>You can find all the files that are installed by a specific package using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pacman -Ql vlc<\/code><\/pre>\n\n\n\n<p>This returns the package name and the path to files that it owns.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-find-the-package-owner-of-the-file\">Find the Package Owner of the File<\/h2>\n\n\n\n<p>If you want to check the location of the binary executable file owned by a package, use the <code>-Qo<\/code> flag.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pacman -Qo \/usr\/bin\/vlc<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-download-a-package\">Download a Package<\/h2>\n\n\n\n<p>Sometimes, you can download a package and keep it in your cache without installing it. For example, you can use the downloaded package later. To do so, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pacman -Sw vlc<\/code><\/pre>\n\n\n\n<p>The above command will only download the <code>vlc<\/code> package and keep it in the cache folder. Pacman stores all downloaded packages in the&nbsp;<code>\/var\/cache\/pacman\/pkg<\/code>&nbsp;directory.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-clean-up-package-cache\">Clean-Up Package Cache<\/h2>\n\n\n\n<p>All packages we downloaded during the installation will be stored in the cache directory, i.e.,&nbsp;<code>\/var\/cache\/pacman\/pkg\/<\/code>. But if you don\u2019t remove them periodically, they will slowly eat up your hard drive space; sooner or later, you could end up with low <a href=\"https:\/\/linuxiac.com\/check-disk-space-linux\/\">disk space<\/a>.<\/p>\n\n\n\n<p>So it is good to remove the cache periodically. For example, to remove all the cached packages and the unused sync database, execute the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pacman -Sc<\/code><\/pre>\n\n\n\n<p>In addition, if you want to remove all files from the cache, use the clean <code>c<\/code> switch twice. Of course, this is the most aggressive approach and will leave nothing in the cache folder:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pacman -Scc<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>Arch Linux is one of the most reputed and famous Linux distributions. This guide has covered most of the commands you need to know when using Pacman to install, update, and remove software on Arch.<\/p>\n\n\n\n<p>I hope that it was helpful in your journey with Arch. The official <a href=\"https:\/\/wiki.archlinux.org\/title\/Pacman\" target=\"_blank\" rel=\"noreferrer noopener\">Arch Linux Wiki<\/a> provides detailed documentation about the Pacman package manager.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a good write up on using Pacman with some options you wouldn&#8217;t use that often, so if you&#8217;re newer to Arch or Arch based distributions like I am, this is a good overview and reference to build upon. For example, I like to use &#8220;sudo pacman -Syyuu&#8221; when I update. But of particular [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-4375","post","type-post","status-publish","format-standard","hentry","category-tech"],"blocksy_meta":[],"featured_image_src":null,"author_info":{"display_name":"Jason","author_link":"https:\/\/jasonsblog.ddns.net\/index.php\/author\/jturning\/"},"_links":{"self":[{"href":"https:\/\/jasonsblog.ddns.net\/index.php\/wp-json\/wp\/v2\/posts\/4375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jasonsblog.ddns.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jasonsblog.ddns.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jasonsblog.ddns.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jasonsblog.ddns.net\/index.php\/wp-json\/wp\/v2\/comments?post=4375"}],"version-history":[{"count":4,"href":"https:\/\/jasonsblog.ddns.net\/index.php\/wp-json\/wp\/v2\/posts\/4375\/revisions"}],"predecessor-version":[{"id":4397,"href":"https:\/\/jasonsblog.ddns.net\/index.php\/wp-json\/wp\/v2\/posts\/4375\/revisions\/4397"}],"wp:attachment":[{"href":"https:\/\/jasonsblog.ddns.net\/index.php\/wp-json\/wp\/v2\/media?parent=4375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jasonsblog.ddns.net\/index.php\/wp-json\/wp\/v2\/categories?post=4375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jasonsblog.ddns.net\/index.php\/wp-json\/wp\/v2\/tags?post=4375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}