summaryrefslogtreecommitdiff
path: root/content/articles/pacman-essentials.md
blob: 1153ba150c098ffcb3112ed2c6b381386a1440d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
{
	"title": "Pacman essentials",
	"subtitle": "Arch Linux package manager explained for everyday users"
}

#### Introduction

The program `pacman` is the package manager of the [Arch Linux][1]
distribution. It should be exclusively used to install, update and remove
software to an Arch Linux system.

As a terminal program it has no graphical user interface (GUI). This might be
uncommon for new users but has advantages like being simple, scriptable and
easily to document like on this page.

With an open terminal and this guide you should be able to manage the software
on your Arch Linux instance in most cases.

#### Getting necessary permissions

A regular Linux user is allowed to use pacman to get information. This includes
for example the package search with `pacman -Ss <keyword>`.

Only the user `root` is allowed to use pacman to update, install or remove
software packages. Other users are able to get temporary root permissions by
using a program like `sudo`.

Thus a pacman call like `pacman -Syu` should be rewritten to `sudo pacman -Syu`
to run it with root permissions. It should be mentioned that using `sudo` is
not required if logged in as user `root` or could be substituted by another
program like `doas`.

#### Full system update

Every Arch Linux installation should be regularly updated. For this purpose
the following command is used:

```
sudo pacman -Syu
```

It runs interactively which means that questions should be answered by the user
with pressing `y` or `n` followed by the `Enter` key. The default option (the
bigger letter in `[Y/n]` or `[y/N]`) is a good option in most cases.

Updating a system every week is a good rule of thumb. It is especially
convenient to update the system before poweroff because most of it can run
without interaction. The poweroff can also be automatically triggered after a
successful update with `sudo pacman -Syu && poweroff`.

#### Package search

One can search for existing packages with this command:

```
pacman -Ss <keyword>
```

`<keyword>` should be replaced by keywords like `firefox`. Furthermore the
package search on the [Arch Linux homepage][1] in the upper right corner can be
used.

The Arch Linux wiki contains also a long [list of applications][2] which is an
excellent place to search for needed programs by category.

#### Package installation

Installing a package is simple:

```
sudo pacman -S <package-name>
```

`<package-name>` should be replaced by the lower case package name found with
the package search (see above) like `firefox` or `gimp`.

It is also possible to install multiple packages with a space-separated list of
packages like `sudo pacman -S firefox gimp` or together with a full system
update `sudo pacman -Syu firefox`.

#### Package removal

The recommended command to remove one or multiple packages is:

```
sudo pacman -Rs <package-1> <package-2>
```

The options `-Rs` select removal with `R` and recursive with `s`. The latter
option removes dependencies of this package too. Dependencies are packages
which are needed for the selected package to work. They get installed
automatically. The `s` option will leave a dependency on the system if
installed explicitly by the user or needed by another package.

#### Further documentation

This page is just a little cheat sheet especially targeted at new Arch Linux
users. The following references point to the official documentation about
pacman:

- The manual page of pacman: `man pacman` (exit with `q`)
- Arch Wiki: [pacman][3]
- Arch Wiki: [pacman/Tips and tricks][4]

They should be consulted to get further information and should be trusted more
than this page if in conflict with its content.


[1]: https://archlinux.org/
[2]: https://wiki.archlinux.org/title/List_of_applications
[3]: https://wiki.archlinux.org/title/Pacman
[4]: https://wiki.archlinux.org/title/Pacman/Tips_and_tricks