How to install and use yay on Arch Linux
Pacman is a powerful package manager provided by default on Arch-based distributions, but it lacks the functionality to download packages from the Arch User Repository (AUR). AUR is a community maintained repository that provides thousands of third-party packages in the form of installation scripts, also known as PKGBUILD.
To install packages that use these PKGBUILDs, an AUR helper such as yay is required. yay is not pre-installed on Arch Linux nor is it available in the official Arch repositories. So how to install yay and download packages from AUR on Arch desktop? Let's find out through the following article!
How to install yay on Arch Linux
The yay package is only available in the Arch User Repository. Note that you can manually install packages from the AUR without using the AUR helper (similar to how the article will install yay below), but as the name suggests, "the AUR helper." " assists you in the installation process, making it easier to install packages with minimal user interaction.
To install yay on the Arch desktop, first download the following dependencies:
sudo pacman -S --needed base-devel git
Then clone the yay repository with the git clone command:
git clone https://aur.archlinux.org/yay.git
Change your current working directory to the newly downloaded yay directory with the cd command:
cd yay
Finally, use the makepkg command to build and install yay:
makepkg -si
If the above command gives the error "cannot find the fakeroot binary", make sure you have successfully installed the base-devel package and then run the command again.
In addition to Arch Linux, this method also works for other Arch-based distributions, including Manjaro, EndeavorOS, and Garuda Linux.
Once done, verify the installation by checking the installed yay version.
yay --version
If the output returns the version number, you have successfully installed yay.
AUR was not originally built for use on Linux distributions other than Arch Linux and its derivatives (such as Ubuntu and Linux Mint). On such distributions, you can use Pacstall, an AUR-inspired package manager that provides pacscripts for installing software.
How to manage AUR packages with yay
The yay and Pacman commands have a lot in common. For example, to install a new package using Pacman or yay, you use the -S flag, while to remove a package you must use the -R option.
Now that you know the similarity between the two package managers, let's get started with package management on Arch Linux using yay.
Search for AUR packages
Like Pacman, yay allows users to search for packages before installing them. If you are unsure of the name of a particular package, you can use the yay command with a search term to find related packages.
yay searchterm
For example, to search for packages with "chrome" in the name:
yay chrome
Output:
To search for a package on both the official repositories and the AUR, use the -Ss flag:
yay -Ss google-chrome
You can also specify multiple keywords to perform a more focused, narrower search as follows:
yay -S term1 term2
The above command will first search for term1 and then narrow down the results by searching for term2 in the returned results.
Install packages with yay
As discussed previously, to install packages with yay, simply specify the package name next to the -S flag:
yay -S packagename
To install the Google Chrome AUR package using yay:
yay -S google-chrome
The installation process is not fully automatic and you may have to enter your superuser password in the middle of the installation process.
To get only the PKGBUILD of a package, use the -G or --getpkgbuild flag:
yay -G google-chrome
You can also choose to print PKGBUILD by using the -p flag with -G:
yay -Gp google-chrome
Output:
Remove packages with yay
When you don't need the AUR package and want to remove it from your system, use the -R option:
yay -R packagename
To uninstall Google Chrome:
yay -R google-chrome
If you want to remove dependencies with the package, append the -ns flag to the previous command:
yay -Rns google-chrome
Upgrade AUR . packages
Calling the yay command without any arguments will perform a full system upgrade similar to the pacman -Syu command. Note that this command will also sync and upgrade packages from the official repositories in addition to the AUR.
To update only AUR packages, use the -Sua flag with the command:
yay -Sua
If you do not want to update a package on Arch Linux, you will have to modify the configuration file located at /etc/pacman.conf. Linux also allows you to downgrade packages on your system if you want.
Use yay to remove unnecessary dependencies
Unused dependencies can quickly pile up and consume large amounts of system storage if left unattended. You can choose to remove the depedency along with the packages by using the -Rns flag each time you delete something, or you can choose the better route by wiping them all at once with the -Yc flag.
yay -Yc
The -Y in the command stands for "yay" and will only perform operations on packages installed with yay.
Additional yay command
To export system health and package statistics with yay, run the following command:
yay -Ps
Output:
In case you need help with commands, use the --help flag:
yay --help
Alternatively, you can check out the manual page:
man yay
You should read it
- Should I install Arch Linux?
- Instructions for installing basic Arch Linux
- How to install Arch Linux on Raspberry Pi
- How to Update Arch Linux
- How to Install Gnome on Arch Linux
- 5 distributions based on the best Arch Linux
- Arch Linux for WSL is now available in Microsoft Store
- Is Arch Linux better than Ubuntu?
- How to Install Arch Linux
- How to Install KVM in Arch Linux and Configure Virtual Machine
- How to set up XFCE desktop environment on Arch Linux
- How to install Snap application in Arch Linux