A tutorial on the basics of maintaining your Linux system
Hello again! Last time we talked about how to install and run a Linux distribution, specifically Endeavour OS, but this tutorial will work for every major Arch-based distribution. In this post we'll talk about:
- How to use the package manager: “pacman”
- How to use the AUR
- How to keep your installation up to date
Without further ado, let's get started.
How to use “pacman”
Pacman, short for package manager, is the package manager for Arch Linux and Arch-based distributions. It is my personal favorite package manager for it's simplicity and ease of use, while also being extremely robust. One advantage of Linux over Windows is the way that you install software. In Linux you'll be using a package manager to install your software almost all the time, advantages include:
- Easy installation of software with just a single command, no more having to download .exe files and installing manually.
- Simple way to manage software and their updates, no more using outdated software, although you can if you wanted to with just a few configurations.
Extra added security assuming you're downloading from a trust and reliable repository. Before we do install or uninstall anything with pacman, let's make our system up to date. Because Arch Linux is a rolling release distribution, you'll get updates as soon as they're available on the repository, so expect frequent updates for all of your software. Follow the mentality of “Install once, update daily.” Unlike non-rolling release distributions, Arch Linux doesn't really have a “version,” like how Centos has Centos 7 or Centos 8; Arch Linux is just Arch Linux, and you shouldn't need to reinstall just to keep your system up to date, just update with pacman and you're good! In order to update your system with pacman, use the command “sudo pacman -Syu”. I'll break down each part of the command so that you can understand it:
sudo: this means run the command as the root (admin) user. Because we are upgrading the packages for every user on the system, we need to run the command as root so that the packages can be installed in the correct place. Use “sudo” in front of any command to run the command as the root user.
pacman: this is just running the command pacman, our package manager.
-Syu: A combination of -S, -y, and -u.
- -S: synchronize (install/update) packages with the remote repository. Package manager download packages off of repositories, in this case the Arch Linux repos, but you can add your own custom repos too, so long as they work with Arch Linux.
- -y: refresh and get a fresh copy of the repository database. This is essentially updating our repo database with the remote repo database.
- -u: upgrades all packages that are out of date according to the repo database. Because we refreshed the database with the -y command, -u will now compare the currently installed software version with the software version in the database, if it is out of date then pacman will update it.
I know that it seems a bit confusing, but honestly you don't even really have to know what the command means. All you need to know that running “sudo pacman -Syu” will update your system, and you should run it daily in order to not fall behind on updates. Because we just did a fresh install of Endeavour OS, depending on how old the ISO was, we might be very far behind on updates, or not at all; you might get only a few updates needed, or a few hundred, in either case, just run the command, proceed by hitting “y,” and go grab a cup of coffee.
Hopefully the update went smoothly and no errors occurred. A reboot of the system is highly recommended as some packages like the Linux kernel needs a reboot for the changes to take effect. Once you reboot, everything should've hopefully booted fine and you should be back on the desktop environment.
Great! Now that our Linux is all up to date, let's learn how to install a single package:
- sudo pacman -S “package-name”
Easy right? But what if you don't know the package name on hand? We can search for packages by using the command:
- pacman -Ss “part of package name or description”
- Notice how we don't need root access in this command because we aren't actually installing anything.
Now let's learn how to uninstall a package:
- sudo pacman -R(sn) “package-name”
- The “-sn” is optional, it basically means “uninstall package along with all of it's dependencies that aren't needed by other packages.” For example, let's say a software needs 5 dependencies, and when you installed it, you installed 6 packages, the software itself and it's 5 dependencies. When you uninstall the software with just “sudo pacman -R,” it only removes the software, but not the 5 dependencies. With “sudo pacman -Rsn,” it removes the software, along with the 5 dependencies, assuming the dependencies aren't required by any other package.
That should cover the basic necessities for using pacman! We now know how to install, update, and uninstall. If you need to do anything else with pacman, remember that search engines are always your best friends, unless they're spyware search engines, in which case don't use them. Stackoverflow gets a lot of bad rep but for a beginner user, they're pretty good.
How to use the AUR.
As explained in the last post, Arch Linux comes with AUR support, a community ran repository of software that can't be found on the main repository. If the package on the AUR becomes popular enough, often time it can move from the AUR to the official Arch Linux repos. Keep in mind though that because AUR packages are ran by users and managed by them, it can be risky as some users can be total dickbags and install malware on your machine; although this is extremely unlikely, you should always exercise caution when using the AUR.
There are many ways to install packages from the AUR, but the most popular and easy way is to use an “AUR Helper.” In this case, Endeavour comes with “yay,” a very popular and robust AUR Helper. If you're comfortable with using pacman, using yay will be second nature because a lot of the commands are identical.
In order to install an AUR package, first find the package name. What I like to do is search up “Arch Linux “package-name” on my favorite search engine, and this finds me the package name 99% of the time. Keep in mind that if the package isn't on the AUR but on the official repos, then using yay isn't necessary and pacman will work fine. You can also go to the AUR homepage and search for packages from there.
Once you've found the package name of the package you want to install, installing it is a piece of cake:
- yay -S “package-name”
- yay recommends not running yay as root due to permissions issue involving another command makepkg. But don't worry as it will prompt you for the sudo password midway through the installation.
Once the AUR package has been installed, the package is now being managed by pacman,so you can uninstall the package with either “pacman -R(sn)” or “yay -Rsn,” your choice. Keep in mind that yay is basically a front-end to pacman, with support for the AUR. So in theory you could just use exclusively yay for installing, removing, and updating software. But I don't do this because idk I probably have autism. So for the pacman section above, every command listed up there that has the word “pacman” can be replaced with “yay,” but please note that sudo still isn't required as you are using yay now, yay will have it's own way of prompting you for root access
Removing programs with yay is simple, it's the exact same as the pacman command:
- yay -R(sn) “package-name”
As stated before, you can uninstall packages not installed through yay, with yay. So packages on the main repos installed through pacman can be managed by yay because in a sense yay is just pacman with some extra features like AUR support.
Anyways that should do it for this blog post. Thanks for taking the time to read all of it. I know that it can seem confusing at parts but always remember that this should be fun, but a hassle or a chore. Search engines are your best friend as always, and feel free to contact me with any and all questions you have.