To install packages using these PKGBUILDs, we require an AUR helper like yay. yay doesn’t come preinstalled on Arch Linux and isn’t available in the official Arch repositories either. So how do you install yay to download packages from the AUR on your Arch desktop? Let’s find out.

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 an AUR helper (similar to how we’ll install yay below), but as the name suggests, an “AUR helper” assists you in the installation process, making it easier for you to install packages with minimum user interaction.

To install yay on your Arch desktop, first, download the following dependencies:

Then, clone the yay repository using the git clone command:

Change your present working directory to the newly-downloaded yay folder using the cd command:

Finally, use the makepkg command to build and install yay:

If the above command throws the “cannot find the fakeroot binary” error, make sure you’ve successfully installed the base-devel package and then re-run the command.

Once done, verify the installation by checking the version of yay installed.

If the output returns a version number, you have succeeded in installing yay.

The AUR isn’t originally built for use on Linux distros other than Arch Linux and its derivatives (like 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 Using yay

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, whereas to remove one, you’ve to use the -R option.

Now that you know the similarity between the two package managers, let’s begin with package management on Arch Linux using yay.

Searching for AUR Packages

Like Pacman, yay allows users to search for packages prior to installing them. If you’re unsure about the name of a particular package, you can use the yay command with the search term to find related packages.

For example, to search for packages with “chrome” in their name:

Output:

To search for a package on both the official repositories and the AUR, use the -Ss flag:

You can also specify multiple keywords to perform a narrow, more focused search as follows:

The aforementioned command will first search for term1 and then narrow down the results by searching for term2 in the returned results.

Installing Packages With yay

As discussed before, to install packages with yay, simply specify the package name next to the -S flag:

To install the Google Chrome AUR package using yay:

To only get the PKGBUILD of a package, use the -G or –getpkgbuild flag:

You can also choose to print the PKGBUILD by using the -p flag with -G:

Output:

Removing Packages With yay

When you don’t need an AUR package and want to remove it from your system, use the -R option:

To uninstall Google Chrome:

If you want to remove the dependencies along with the package, append the -ns flag to the previous command:

Upgrading AUR Packages

Invoking the yay command without any arguments will perform a full system upgrade similar to the pacman -Syu command. Note that this command will also synchronize and upgrade packages from the official repositories in addition to the AUR.

To only update AUR packages, use the -Sua flag with the command:

If you don’t want to update a package on Arch Linux, you’ll have to modify the configuration file located at /etc/pacman.conf. Linux also allows you to downgrade packages on your system if you want.

Using yay to Remove Unnecessary Dependencies

Unused dependencies can quickly pile up and consume a huge chunk of your system storage if not taken care of. You can either choose to remove the dependencies along with the packages by using the -Rns flag each time you remove something, or you can take the better route by sweeping them away all at once using the -Yc flag.

The -Y in the command stands for “yay” and will only perform operations on packages installed using yay.

Additional yay Commands

To print package statistics and system health with yay, run the following command:

Output:

In case you need help with the commands, you can easily get command-line help using the –help flag:

Alternatively, you can view the yay manual page using:

The AUR Has Got Everything You Need!

Now that installing AUR packages is a breeze for you, go check out the AUR and search for software that you’ve always wanted to install on Linux. There’s a good chance that it’ll be available in the repository.

Keep in mind that using the AUR also poses a security risk. Since anyone can add their PKGBUILD to the AUR, these installation scripts aren’t often tested and reviewed properly. But that doesn’t mean you should stop downloading packages from the AUR altogether.

Instead, minimize the risk by reviewing the PKGBUILDs before installing the packages. Not only will this keep your system safe, but you’ll also learn how packages in the AUR work.