Installing Packages

Before installing and upgrading packages, it is a good idea to synchronize the local package database with the remote repositories.

pacman -Sy

…or, equivalently:

pacman –sync –refresh

To install or upgrade a single package or list of packages (including dependencies), issue the following command:

pacman -S package_name1 package_name2

Sometimes there are multiple versions of a package in different repositories (e.g. extra and testing). You can specify which one to install:

pacman -S extra/package_name
pacman -S testing/package_name

You can also refresh the package database before installing a package in one command:

pacman -Sy package_name

Removing Packages

To remove a single package, leaving all of its dependencies installed:

pacman -R package_name

To remove a package’s dependencies which aren’t required by any other installed package:

pacman -Rs package_name

By default, pacman backs up configuration files of removed applications in place by adding the extension *.pacsave to them. If you want to delete configuration files as well when removing the corresponding package (this behavior is called purging on Debian-based systems) you can use:

pacman -Rn package_name

Of course, this can be extended with -s to also delete now-unnecessary dependencies. Thus, the command to truly remove a package, its configuration, and all dependencies which aren’t needed anymore is:

pacman -Rsn package_name

Note! Pacman will not remove configuration files that are created after the package was installed. You can manually remove them from your home folder.

Upgrading the System

Pacman can update all packages on the system with just one command. This could take quite a while depending on how up-to-date your system is.

pacman -Su

However, the best option is to synchronize the repository databases AND update your system in one go with the following:

pacman -Syu

Querying the Package Database

Pacman can search for packages in the database, searching both in packages’ names and descriptions:

pacman -Ss package

To search for already installed packages:

pacman -Qs package

Once you know the name of the package you are looking for, you can get more information about it:

pacman -Si package
pacman -Qi package

To retrieve a list of the files installed by the package:

pacman -Ql package

You can also query the database to know which package a file on your file system belongs to.

pacman -Qo /path/to/a/file

To list all packages no longer required as dependencies (orphans):

pacman -Qdt

Pacman queries the local package database with the -Q flag. See:

pacman -Q –help

…and queries the sync databases with the -S flag. See:

pacman -S –help

It is good practice to keep periodic backups of all pacman-installed packages. In the event of a system crash which is unrecoverable by other means, pacman can then easily reinstall the very same packages onto a new installation.

First, backup the current list of packages (which are available in a repository):

pacman -Qqe | grep -v “$(pacman -Qmq)” > pkglist

Store the pkglist on a USB key or other convenient medium.

Copy the pkglist file to the new installation, and navigate to the directory containing it.

Issue the following command:

pacman -S $(cat pkglist)

Additional Information

Pacman is quite an extensive package management tool. Here is just a brief collection of other features.

For a more detailed list of switches please refer to pacman –help or man pacman.

Configuration

Pacman configuration is located in /etc/pacman.conf. In depth information about the configuration file can be found in man pacman.conf.
General Options

General options are in [options] section. Read the man page or look in the default pacman.conf for information on what can be done here.
Repositories

In this section you define which repositories to use, as referred to in /etc/pacman.conf. They can be defined directly here, or you can include them from another file.

All official repositories use the same /etc/pacman.d/mirrorlist file which contains a variable ‘$repo’, so you only need to maintain one list.

The following is an example for the official repositories which have a lot of mirrors. Avoid using ftp.archlinux.org as it is throttled.
[core]
# Add your preferred servers here, they will be used first
Include = /etc/pacman.d/mirrorlist

[extra]
# Add your preferred servers here, they will be used first
Include = /etc/pacman.d/mirrorlist

[community]
# Add your preferred servers here, they will be used first
Include = /etc/pacman.d/mirrorlist

Note: Care should be taken when using testing repository!

Errors

If you receive the following error:

not found in sync db

…this likely due to the package not being located because the repository has not been set correctly.

# let everyone connect to you
sshd: ALL
# OR you can restrict it to a certain ip
sshd: 192.168.0.1
# OR restrict for an IP range
sshd: 10.0.0.0/255.255.255.0
# OR restrict for an IP match
sshd: 192.168.1.

Tired of having ‘vi’ (elvis actually) as the default editor when launching stuff like ‘crontab -e’ and such from the commandline? Would you much rather have emacs, joe, pico or some other editor as the default? It is easy to change, just set the environment variable VISUAL to the full path of your favorite editor, and it will be used instead.

To do it, just execute this command:

$ export VISUAL=/usr/bin/nano

Now ‘nano’ is the default editor. You can make this change permanent for a single user by putting the ‘export VISUAL=’ line into the .bash_profile file in the home dir of the user in question, or you can make it a systemwide default by putting it into the /etc/profile file.

Next, set the version of Slackware you wish to keep on your computer. You can set it to 11.0 or current. Current is the most up-to-date version, and it may be unstable and could pose problems, but it should be easier to upgrade to the next version when it rolls out. I keep some servers on current and others, the ones I consider critical, on 11.0:

# swaret --set VERSION=current

Now you can update the list of packages Swaret uses:

# swaret --update

When that command completes successfully you can run the upgrades. You can use the -a switch to automatically install all new updates without being prompted, or use no switch to be prompted for each package update:

# swaret --upgrade

Since version 11.0 has just come out there won’t be many updates right away, so don’t expect much at first.

You can also use Swaret to install programs that were not installed originally by using this command (replace package-name with the actual name of the package):