Overview: install/uninstall/manage/clean/upgrade/downgrad software in Arch
Welcome, Guest.
He could not keep viruses out of Windows! Do you want Bill Gates' MANDATORY Covid-19 Vaccine? Sign this petition!
"Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety." -Benjamin Franklin

Author Topic: Overview: install/uninstall/manage/clean/upgrade/downgrad software in Arch  (Read 5224 times)

Offline Bendo

  • Forum Staff
  • Contributor
  • *******
  • Posts: 363
Basic Overview for Arch newbies: install/uninstall/manage/clean/upgrade/downgrade software in Arch from official repos, AUR and source

As there often seems to be some confusion among new Arch users about how to install things in Arch and what this words like AUR/yaourt/pacman mean, I wrote a simple overview.
It doesn't provide very much background knowledge or “whys”, more “how-tos” and is very simplified.
The terms package/software/application or technical terms in general are used a little bit sloppy.
As English isn't my first language there might be some mistakes, feel free to correct me.

0. What you should know

1. Where do I find software?

2. How to install software from the official repositories

3. How to install software from the AUR

4. How to remove installed software

5. How to clean up your system

6. Upgrading & Downgrading

7. Configuration

8. AUR Troubleshooting

9. Basics of compiling from source

0. What you should know before you start reading:

-How to open a terminal
-How to change directory inside the terminal: cd /path/to/directory
-A package is an unit of files which are needed to install a certain application with the help of a package manager. (simplified!!!)
-Repository: Packages a grouped together in certain repositories (repos) of a distro, where they are maintained and made available for the users.A repo is for packages what a kiosk is for breads and bagels.
-Programs often rely on other (additional) software components which have to be installed on the system in order to run them. We call those components dependencies.
-Pacman is Arch's package manager. A package manager is a tool which automatically installs software using a packaging system so that we don't have to compile everything manually from source (simplified!!!)

-you should know that you have base-devel installed ;) otherwise run
Code: [Select]
sudo pacman -S base-devel

Post Merge: April 26, 2015, 04:03:43 PM

1. Where do I find software?

The two most common sources for software are
a) the Official Repositories of Arch Linux and
b) the Arch User Repository (A.U.R.).
In the official repos you find common, popular software as binary packages, maintained by Arch developers. The AUR is a user repo where everybody can create an account and upload + maintain software.
If enough users vote for an AUR package it can eventually land in the official repos.
First you can search for a package in the Official Repositories here: https://www.archlinux.org/packages/
If you don't find your package there or you need a different version , search the Arch User Repository here:
If you aren't sure which software you actually need for a certain purpose, here is a list of applications with some recommendations:

If you use Firefox you can install https://www.archlinux.org/packages/community/any/arch-firefox-search/ what will integrate a search engine for the Official Repos and the AUR in your Browser.

Post Merge: April 26, 2015, 04:07:04 PM

2. How to install software from the official repositories:
To download and install a package as well as all dependencies which are necessary to run it, you use “pacman”, the package manager of Arch Linux. Open a terminal, you only need one single command:
Code: [Select]
pacman -S <package>For example to install the tar archiving utility (which we will need) we type:

Code: [Select]
pacman -S tar
If you're new to the command line, it's very simple. We call the program which is responsible for installing software (pacman), we tell pacman what to do ( -S for synchronize with remote repo) and we tell pacman the target of this action (the “tar” utility).

Pacman will tell you which package you are about to install, which dependencies it's going to install for you, how many space the application will need after installation and asks you to confirm that, just press <return> or
<n+return> if you're unhappy with something.
To interrupt an already running download/installation press <ctrl+c>.
If you want so search for a package in the official repos, you also can do that from the command line using pacman instead of the web interface:
Code: [Select]
pacman -Ss <keyword>
will list matching packages with their official package names and short descriptions.
You can now check if the package was successfully installed by performing a “Query” operation with pacman.
Code: [Select]
pacman -Qs <packagename>
Again we call the program (pacman) we tell it what to do (Query our package database, search for name) and the target of this operation (packagename).

Altogether it looks liket that (example: VLC media player):

Here is another way to install software from the official repos which will prepare you for installing software from the AUR (so don't skip that!):
Find your software with the web interface and click on “Download from Mirror”.
Save to your home directory. You downloaded a package archive which will look like this:
You can install such a local .pkg.tar.xz file with

Code: [Select]
pacman -U <packagename>.pkg.tar.xz
So you can think of pacman -S <packagename> as downloading a pkg.tar.xz file, performing the pacman -U installation and deleting files which aren't needed.

Post Merge: April 26, 2015, 04:12:40 PM

3. How to install software from the AUR.
Remember that we are talking about a User Repo:
After you found your application in the AUR make sure it's not marked as flagged out, take a look at the comment area if there are any complaints or hints how to fix problems. The number of 'votes' gives you an idea how many users are satisfied with the package.
Click on “Votes” to list them in descending order.
If there are different versions of the same software, most of the time a suffix like -git or -dev tells you that you look at a development version of a package. It may include new features but to stay on the safe side rather install the stable version.
If you decided to install the application, click on 'Download tarball' and safe it to your Download (or any other) folder.
Open a terminal and change directory to your Download folder.

Code: [Select]
cd Downloads
You just downloaded a compressed tar.gz file.
Decompress it with the tar tool
Code: [Select]
tar xzfv <packagename.tar.gz.>
Don't type the entire name, use the tab key to auto-complete.
This will create a new folder, named <packagename>.
Change directory to your new folder:
Code: [Select]
cd <packagename>
If you take a look at the files with
Code: [Select]
you'll see that there isn't any local pkg.tar.xz file to perform an installation like we did in the previous chapter.
What we have instead is a so called PKGBUILD file. This is a simple script which contains all information needed to build such a .pkg.tar.xz file and install it with pacman. You can take a look at the PKGBUILD file with any text editor
Code: [Select]

You don't need to be a programmer to understand most stuff in there. The PKGBUILD contains some information about the package, points to necessarily source files either local or via an URL (for example github), and some functions() like build() or package().
Don't worry you can don't need to understand everything, close your editor.
We now run the makepkg tool which will look for a PKGBUILD file in our current directory and use its information to build a .pkg.tar.xz file.

Code: [Select]
makepkg -s
After makepkg finished, take a look at your files with ls
You see that we now have our <packagename>.pkg.tar.xz file and we can install our software just like in the previous chapter with

Code: [Select]
pacman -U <packagename>.pkg.tar.xz
Don't type the entire package name, either use the tab key to auto complete or type
pacman -U *.xz
instead, since usually there is only one .pkg.tar.xz file.
That's it.
Even faster: Add the “i” option to makepkg

Code: [Select]
makepkg -si will automatically install the .xz file with pacman.
So the entire installation process comes down to: download the tarball, decompress it with tar xzvf, run makepkg -si.

There are also different (unofficial) AUR helpers available, applications which automatize the steps above.
The most common ones are yaourt and packer.
Install yaourt from the AUR as described above https://aur.archlinux.org/packages/yaourt/
If you now want to install a package from the AUR, simply open a terminal and type
Code: [Select]
yaourt <packagename>
It automatically downloads the PKGBUILD, builds a pkg.tar.xz file and installs it.
While doing so you will have to answer a couple of questions like
'Do you want to edit the PKGBUILD' which is up to you, but most of the time you won't.
'select an editor for viewing the PKGBUILD' , just type in the name of a command line text editor for example nano or vim, press return.
'continue building ….' press return.
It's pretty intuitive.

Post Merge: April 26, 2015, 04:15:25 PM

4. How to remove installed software

Pacman can not only install software but also remove it from your system.
The basic command to remove a package is:
Code: [Select]
pacman -R <packagename>
However this will keep ALL the package's dependencies on your system.
Some of them may be needed by other packages, others may become orphans and useless.
Fortunately we can use:
Code: [Select]
pacman -Rs <packagename>
to uninstall a package and all its dependencies which are NOT needed by any other installed packages and were not installed manually. Highly recommended to keep your system clean!

If you use pacman -Rs, Arch still keeps some configuration files and saves them as .pacsave files on your system.
To avoid that and delete a package with its orphaned dependencies and config files we can add the –nosave option:
Code: [Select]
pacman -Rns <packagename>

Post Merge: April 26, 2015, 04:18:46 PM

5. How to clean your system

You can also use pacman to keep an overview over your system and find+remove unneeded packages.
We already worked with the Query operation, but now we don't want to search our local database for a certain package by its name but we want to list all packages which full-fill certain criteria.

Code: [Select]
pacman -Qdt
-Q: Query -d: dependencies -t: unrequired
Will list all packages which were installed as dependencies for other packages AND aren't required as dependencies by any program which is installed on your machine at the moment.They are orphans and basically any package which shows up in this list can be removed.

You could remove this entire list with one command

Code: [Select]
sudo pacman -Rns $(pacman -Qdtq)
command1 $(command2), applies command1 to the output of command2.
If that's too complicated for you, open your ~/.bashrc file and add this line
alias clean='sudo pacman -Rns $(pacman -Qdtq)'
Save the file, type source ~/.bashrc, press return. Now you just have to open a terminal and type clean to remove unneeded dependencies.

Another usefull query option is:
Code: [Select]
pacman -Qet
Query, explicit, unrequired will list all packages (not only dependencies) which you have explicitly installed as such AND aren't required by any other packages.
So if you're running out of space or you just want to keep your system clean, this is exactly the list of packages which can be removed without breaking other software on your Arch system. Just inspect the list and remove what you don't need.

You can check how much cache pacman collected (pacman saves each package to its cache /var/cache/pacman/pkg) with

Code: [Select]
du -sh /var/cache/pacman/pkg
(always use the -h:human readable flag if you are expecting file size as output)

Code: [Select]
pacman -Sc will delete packages from the cache which aren't needed anymore.
You also may take a look at the tool https://aur.archlinux.org/packages/paccache/
However as wee see later, the cached packages can be useful to downgrade, it's your decision where your priorities are.

Of course there are a bunch of applications for cleaning you system available for Linux in general (and Arch) for example https://github.com/graysky2/lostfiles or defrag tools etc.
You CAN use them, you probably don't HAVE to. Personally I even recommend to not use those applications as the danger of false positives and the risk of harming your system is much higher than the possible benefits.

Post Merge: April 26, 2015, 04:22:32 PM

6. Upgrading & Downgrading

When you want to upgrade your Arch Linux:
Step 1: check https://www.archlinux.org/
Step 2: check https://www.archlinux.org/feeds/news/
Step 3: check https://bbs.archlinux.org/
Step 4: check https://twitter.com/archlinux

No of course not, but seriously so many problems and questions could be avoided if people would actually use the excellent services that arch provides on their homepage. People put work in there FOR YOU.
Step 1 is enough though as Arch is much more stable than you may think.
Bu if you update without checking archlinux.org first, it didn't break. You did break it ;)
Maybe you want to add your mail to a mailing list https://lists.archlinux.org//listinfo/arch-announce/

To upgrade a certain package, simply use the Synchronize option which you already know:
Code: [Select]
pacman -S <packagename>
To upgrade your entire system use:
Code: [Select]
pacman -Syu
Now there is one problem left: Software which was installed from the AUR.
You downloaded a PKGBUILD, built a local package archive and installed it via pacman. Obviously you can't upgrade that by synchronizing your database with some remote repo.
One way to upgrade AUR packages would be to constantly, manually check if there are new versions available for every AUR package on your system, download the PKGBUILDS, build new .tar.xz files, install them.

A more common way is to simply install yaourt und type

Code: [Select]
yaourt -Syua
what is the same as pacman -Syu but in addition automatically does what I described above with AUR packages.
It's easy but I also feel like I loose a little bit of control with that approach. Troubleshooting can become quite annoying if there are problems with one PKGBUILD somewhere in the middle of the updating process when you are tied to yaourt's question-answer interface. You might just skip the troublemakers and take a look at them manually afterwards.
Personally I prefer a little tool called cower but at the end of the day there isn't that much of a difference

If you update your system and you have problems with the new version of a certain package(s) you might want to downgrade them.
We already talked about the fact that pacman caches every package which you downloaded.
So if you upgraded your system and pacman -Qs <packagename> shows you now have <packagename5> installed but you want to downgrade to the previous <packagename4> version, look if there is a <packagename4>.pkg.tar.xz file in /var/cache/pacman/pkg

Code: [Select]
ls /var/cache/pacman/pkg | grep <packagename>
If it's there simply install it with pacman

Code: [Select]
pacman -U /var/cache/pacman/pkg/<packagename4>.pkg.tar.xz
If you run into problems with dependencies, some people will tell you to ignore them using a -d flag. DO NOT DO THAT until you know exactly what you are doing.

Post Merge: April 26, 2015, 04:24:26 PM

7. Configuration
Pacman itself is configured with the help of a config file, located at /etc/pacman.conf
The output of pacman is logged in: /var/log/pacman.log
Your mirrorlist is stored at: /etc/pacman.d/mirrorlist

So we don't go in depth here, a couple of things you might want to take a look at:
Open /etc/pacman.conf in any text editor with root permissions:

Code: [Select]
sudo vim /etc/pacman.conf
Go to #Misc Options, uncomment #Color (delete the #) and add the line IloveCandy underneath to make pacman more beautiful ;)
Jump to the #REPOSITORIES section.
What I simply called 'official Repositories' is actually divided in a core, an extra, a community, a multilib and the testing repositories.
You can uncomment (delete #) the repos you wanna use.
Software which is expected to be unstable and isn't already tested in depth lands in the testing repo first, before they may be included in the core or extra repo.
I recommend to not use them especially for newbies.
The community repos is the one where packages from AUR end up when a trusted user puts them in.
The multilib repo should be enabled if you want to use 32bit apps on a 64bit Arch system.

For more options look at https://www.archlinux.org/pacman/pacman.conf.5.html

Update your mirrorlist:
Visit https://www.archlinux.org/mirrorlist/ enter your current location, click generate and replace the content of /etc/pacman.d/mirrorlist with the output, uncomment the servers you wanna use (uncomment all).


Code: [Select]
as root to improve database access.

Post Merge: April 26, 2015, 04:31:29 PM

8. AUR Troubleshooting

Some fast workarounds for common problems with the AUR.

I) You try to run makepkg but get an Error with the PGP signature(s)

I'm not the biggest fan of simply disabling security features if you have problems with them but it's still good to know that you can add the option

Code: [Select]
makepkg -s –skippgpcheck
In any case you should try to find out why you that problem and how to solve it first:
Open the PKGBUILD file in any text editor and check if it contains a line like that
validpgpkeys=('*long_number*') # * NAME_OF_PERSON* , for example:
validpgpkeys=('487EACC08557AD082088DABA1EB2638FF56C0C53') # Dave Reisner
If so, open your ~/.gnupg/gpg.conf file and add the following line:
keyserver-options auto-key-retrieve
If it still doesn't work try to import the key manually
Code: [Select]
gpg --recv-keys <KEY>
If such a line is completely missing in the package build, look at the name at the top of the pkgbuild, research his public PGP Key
and add it to your user's keyring
Code: [Select]
gpg --recv-key <KEY>
gpg --lsign <KEY>

II) You're trying to run makepkg but it complains about missing dependencies

It will tell you which are missing but you also find a complete list of needed dependencies in the PKGBUILD file. To make and run an application you need all dependencies which are listed inside depends=(…) and makedepends=(...) but you can ignore optdepends=(…)

Install all this dependencies with pacman as described in chapter 2, if one is in the AUR, install it like described in chapter 3.
Add a –asdep flag after pacman -S or pacman -U when installing them.
Try to run makepkg again.
If there are still complains, open the PKGBUILD script and compare the dependencies and their version inside the braces with what you actually have installed.
Maybe there is a little mistake in the version restriction, or there was a little change in the nomenclature of a dependency or there simply is a little typo. In this case edit the PKGBUILD with any text editor.

III) You run makepkg but it complains about a missing package() function

Well the PKGBUILD isn't up to date, there was a change in rules and now the package function is the only required function. If you open your PKGBUILD file you'll probably see that there is a function() which looks like that:

but no package() {…} function.
Fixing this problem can be either very simple or “complicated” depending on the individual situation.
You can try this: Simply replace the word build() with package().
With some simple PKGBUILDS this will be enough.

Similar approach:
Just add an empty package function underneath the build function:

Now copy every line with <make install> and <install> from the build() function into the package(){} function and delete it from the build() function.
Delete the || return 1 after those lines.
If there is a <cd...> command in the build function also copy it to the package() function (must occur before the make install and install lines) but don't delete it from the build() function.
Try again.

Post Merge: April 26, 2015, 04:38:22 PM

9. Basics of compiling from source

This is only a short introduction, using a very simple example.
Sometimes you want to install something which is neither in the repos nor in the AUR (or broken, not up-to-date, whatever) and you aren't familiar with writing PKGBUILDs for the Arch Build System, so you want to compile it from source.
We will compile GNU Aris, a little helper tool for people interested in math and logic and we only will need 3 commands: ./configure, make, make install.
That's it.
First I open a terminal and run
Code: [Select]
which arisand I get which: no aris in (…….), so nope I don't have it installed on my system.
Next thing to do: Get the source files.
We create a new folder 'aris' in our home directory, go to https://ftp.gnu.org/gnu/aris/aris-2.2.tar.gz and save it to ~/aris.
We open a terminal and go to our aris folder with cd aris
and decompress our download with
Code: [Select]
tar xzf aris-2.2.tar.gz
cd aris-2.2

If you want, take your time and explore the files and directories.
You see that we have a README and an INSTALL text file. Usually we would take a look at those files with the text editor of your choice, as there could/will be some useful instructions and information.
However right now I can tell that we don't need any further instructions and can follow the most basic procedure.

The src directory contains the actual source code, if you want you can open aris.c in a text editor
Code: [Select]
vim aris.c
That's how program code in C looks like, and that's what we want to compile to 0s and 1s.
But now we go to work.
Change directory to your aris-2.2 directory again and look at the files with ls, you'll spot a file called configure.
Use the file command to determine it's file type
Code: [Select]
file configure
and you will get:
configure: POSIX shell script, ASCII text executable

Executing this shell script is the first step of compiling from source.
The script will check if we have everything on board what we need and are ready to go, as well as possibly slightly optimize the source code for our system.
Code: [Select]
Now again look at your files with ls and watch for a file called Makefile.The Makefile will be our next tool, as it is the input for the make command, it describes how our program is organized and how it has to be put together, it's like a construction plan.
We simply type
Code: [Select]
without target, it will automatically look for a makefile called Makefile, which we have.
It will output a lot of text, the last line should look like make[1]: Leaving directory '~/aris/aris-2.2'
If there aren't any additional complaints 'make' was successful, if you type make again it should say something like
Nothing to be done for 'all-am'
 Leaving directory '
Now we only have to install aris to a place where applications are supposed to be in Linux and that's for sure not our home directory.
Fortunately make will automatically do that for us, we run make again but specify a target other than the Makefile called install, also we run it with sudo as we don't have the rights to write to the places where software is installed in Linux (thankfully!).
Code: [Select]
sudo make install  
If it's finished, type
Code: [Select]
which aris
aaand voila:
$ which aris

It's there! We just compiled aris from source with basically using three commands.
Code: [Select]
to take a look at the application :)
« Last Edit: April 27, 2015, 07:43:57 AM by Bendo »

Offline JayVii

  • Contributor
  • *******
  • Posts: 1759
    • JayVii's Page
Good job, Bendo! I'll set this topic "sticky", so everyone can see it right away.

Offline glsmaxx

  • Full Member
  • ****
  • Posts: 274
  • Old Dog Learnin' New Tricks
Bendo, you are a talented man!

I have found all of your tutorials very well written and thay have taught me a lot.

Running Manjaro-XFCE  &  Arch-XFCE
           Are There Any Others?

Offline ygstr

  • Newbie
  • **
  • Posts: 13
  • crux user
Something you should add to the Pacman guide.
Print all packages from official repositories
Code: [Select]
$ pacman -QenPrint all packages from the aur
Code: [Select]
$ pacman -QemWhen I was a arch user this helped me decide what packages I didn't want.

Offline Bendo

  • Forum Staff
  • Contributor
  • *******
  • Posts: 363
Something you should add to the Pacman guide.
Print all packages from official repositories
Code: [Select]
$ pacman -Qen
Print all packages from the aur
Code: [Select]
$ pacman -Qem
When I was a arch user this helped me decide what packages I didn't want.

Hi yungstorm,
thank you for your thoughts.
the thing is there are a lot of options, a lot of commands and flags, a lot of knowledge which are useful.
At the end of the day I didn't want to add all of them, otherwise I would just end up with a copy of the pacman man page or arch wiki, I tried to give a basic overview.
I tried to use as less commands as possible to archive certain tasks because the target group are obviously new Arch users.
Why I decided not to list these two commands but instead the one command

Code: [Select]
pacman -Qetis this:
-For removing software it's not important if you isntalled it from the AUR or official repos.
You remove both the same way.
- Qen and Qem will also list packages which are needed by other packages.
For a newbie it's not a good idea to look at this list if he wants to decide what to delete.
If we add the unrequried flag -t for both commands we have the same as
-Qet only divided in AUR and official packages which as I already said doesn't make a difference.
The only case where it does make a difference is when you want to upgrade it. However if a newbie follows the guide he will upgrade both all Aur and all official packages automatically.

So I just tried to keep it as simple as possible and to give just as many tools as needed to perform all common tasks.
But again thank you