Skip to content

Arch Linux Basics

Pacman CLI for Debian users

The following table sketches more or less my mental model of mapping pacman commands to the corresponding apt commands. A great overview of other mappings for other package managers can be found on this great Arch Wiki article.

Debian Arch Linux Description
apt install pkg pacman -S pkg Install package pkg.
apt remove pkg pacman -Rs pkg Remove package pkg.
apt purge pkg pacman -Rns pkg Remove package pkg and config files.
apt download pkg pacman -Sw pkg Download package pkg.
apt update pacman -Sy Update local package database.
apt update && apt upgrade pacman -Syu Upgrade installed packages.
apt search pkg pacman -Ss pkg Search for package pkg.
apt show pkg pacman -Si pkg Show infornation about package pkg.
apt list -i pacman -Qe List installed packages.
apt list -u pacman -Qu List packages that can be updated.
apt-file file pacman -Qo file Show which package owns a certain file.
apt policy pkg pacman -Qe/-Qi pkg Show version of installed package.

AUR

The required tools for installing packages from the AUR are makepkg and git. For this reason one has to install the package base-devel.

Moreover, for installing software from AUR, you need a basic knowledge of the tools git, makepkg, and the AUR website. Of course one could use an AUR helper like yaourt or pacaur. However, it doesn't hurt to know how it is done manually.

For managing manually software and dependencies from the AUR without an AUR helper, it's a good idea to create a directory called aur where you will git clone every AUR package.

Example workflow:

git clone https://aur.archlinux.org/package-name
cd package-name
makepkg -s
makepkg -i

Simple packages

For example, simple AUR packages like neofetch can be installed as follows:

git clone https://aur.archlinux.org/neofetch
cd neofetch
makepkg -si

The table blow explains some of the used makepkg options.

Command Description
makepkg Build the package using the PKGBUILD in the current directory.
makepkg -s Install missing dependencies using pacman.
makepkg -i Installed the build package.
makepkg -c Clean up leftover work files and directories after a successful build.

Complex packages

Other and more complex AUR packages like the awesome terminal emulator tilix require some manual dependency resolution :-). For example, it depends on the AUR package gtkd which needs to be installed first before we can proceed with the manual installation of tilix.

Summarized this package can be installed as follows:

mkdir ~/aur && cd ~/aur
git clone https://aur.archlinix.org/gtkd && cd gtkd && makepkg -si && cd ~/aur
git clone https://aur.archlinux.org/tilix && cd tilix && makepkg -si && cd ~/aur

Overall, the workflow of installing manually software from the AUR is as follows:

  1. Go the website aur.archlinux.org and search for the package.
  2. Once found, copy the Git clone URL and use git to clone the repo of the AUR package. In other words, run git clone https://aur.archlinux.org/{package-name}
  3. Next, install the required AUR dependencies that are mentioned on the AUR website.
  4. Afterwards, cd to the package directory and check the PKGBUILD file if it does what it is supposed to do!
  5. Next, install the dependencies and build the package using makepkg -s.
  6. Once the package is build, install it via makepkg -i.

Base installation

This section provides basic instructions to install Arch Linux on a Thinkpad T450s system with a btrfs root filesystem and an ext4 home partition.

Create partitions

There are a plenty of different tools to parition a hard disk, including fdisk, gdisk, as well as cfdisk. Personally, I prefer fdisk as it is straightforward to use.

Before we partition the hard disk, we have first to think about our partition layout. In the following, I use a partition layout for an UEFI/GPT system. Moreover, I just want to have a basic btrfs root filesystem and a separate home partition using the ext4 filesystem. Also note that we need to have a separate EFI partition using the fat32 filesystem. To keep things simple, I also use a swap partition.

So in short, I end up with the following partition scheme:

Mount point  | Partition | Type             | Filesystem type | Size
/boot        | /dev/sda1 | EFI System       | fat32           | 1G
[SWAP]       | /dev/sda2 | Linux Swap       | swap            | 12G
/            | /dev/sda3 | Linux Filesystem | btrfs           | 60G
/home        | /dev/sda4 | Linux Filesystem | ext4            | Remainder

To implement this scheme, let's fire up fidisk. In my case, I need to partition /dev/sda:

fdisk /dev/sda
  • Enter g to create a GPT partition table.
  • Enter n to create a primary partition for /boot.
  • Enter t and hit 1 for EFI partition type.
  • Enter n to create a primary partition for swap.
  • Enter t and hit 19 for swap partition type.
  • Enter n to create a primary partition for for /.
  • Enter n to create a primary partition for for /home.
  • Enter w to save the partition scheme.

Format partitions

Now that we have partitioned our disk, we need to format the partitions. In short, we need to:

  • format /dev/sda1 using fat32,
  • format /dev/sda2 using mkswap,
  • format /dev/sda3 using mkfs.btrfs,
  • format /dev/sda4 using mkfs.ext4.
mkfs.vfat -n EFI -F32 /dev/sda1
mkswap -L swap /dev/sda2
mkfs.btrfs -m single -L ROOT /dev/sda3
mkfs.ext4 -L HOME /dev/sda4

Create BTRFS subvolumes

First, we need to mount the root btrfs partition of our future Arch system:

mkdir /mnt/target
mount /dev/sda3 /mnt/target

Next, we create a subvolume for the arch root system and subvolume for the snapshots:

btrfs subvolume create /mnt/target/@arch
btrfs subvolume create /mnt/target/@arch_snapshots
umount /mnt/target

Afterwards, we need to mount the subvolumes:

mount -o compress=lzo,subvol=@arch /dev/sda3 /mnt/target
mount -o compress=lzo,subvol=@arch_snapshots /dev/sdb3 /mnt/target/.arch_snapshots

Finally, mount the other paritions, namely boot, home, and swap:

mkdir /mnt/target/boot
mount /dev/sda1 /mnt/target/boot
mkdir -p /mnt/target/home
mount /dev/sda4 /mnt/target/home
swapon /dev/sda2

Bootstrap the base system

In this step, we bootstrap the root filesystem of an Arch system using pacstrap:

sudo pacstrap /mnt/target base base-devel intel-ucode vim zsh wget git

Generate fstab

genfstab -U /mnt/target | tee /mnt/target/etc/fstab

Chroot into the root filesystem

arch-chroot /mnt/target

Configuration

Once we chrooted into the new root filesystem, we can configure our new system and install extra packages. This includes to configure the time zone, locales, network confguration as well as the root password.

Time zone

Create the following symlink to use the local time in Zurich:

ln -sf /usr/share/zoneinfo/Europe/Zurich /etc/localtime

Localization

Uncomment the following line in /etc/locale.conf to have US locales:

LANG=en_US.UTF-8

Create the file /etc/vconsole.conf and add the following line for a US keyboard:

KEYMAP=us

Root password

To set the root password run:

passwd

Boot loader

pacman -S grub efibootmgr
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub
grub-mkconfig -o /boot/grub/grub.cfg

Reboot into the new system

exit
umount -R /mnt/target
reboot

Network configuration

Use the command ip addr to find out the network interface:

Example output:

ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: wlp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether b2:fb:42:2b:46:ce brd ff:ff:ff:ff:ff:ff
3: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 68:f7:28:6a:0d:83 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.100/24 brd 10.0.0.255 scope global dynamic enp0s25
       valid_lft 61740sec preferred_lft 61740sec
    inet6 fe80::6bfb:b2fa:ad9a:910e/64 scope link 
       valid_lft forever preferred_lft forever
    inet6 fe80::206e:9d6f:7365:b357/64 scope link 
       valid_lft forever preferred_lft forever

Afterwards, use dhcpcd to get an IP address for your machine:

dhcpcd enp0s25

To test your internet connection use ping:

ping -c2 www.google.ch

You can enable the dhcpcd daemon on every boot via systemctl:

systemctl enable dhcpcd

Customization

Custom user

A custom user can be created as follows:

useradd -m -s /bin/zsh newuser
passwd newuser

Setup sudo

Instead of using a root account to administer your system, you can install sudo and add your user account to the group wheel:

pacman -S sudo
gpasswd -a newuser wheel

To complete the sudo configuration, we must not forget to uncomment the first line starting with #%wheel in /etc/sudoers. In other words, remove the Hashbang # before %wheel. Also note that you should use visudo to edit the sudoers file.

Other useful services

Other useful services that can be installed on a fresh Arch Linux system are:

pacman -S acpid ntp dbus avahi cups cronie
  • acpi is a flexible and extensible daemon for delivering ACPI events.
  • ntp is an implementation of the Network Time Protocol (NTP) is a protocol for synchronizing the clocks of computer systems over packet-switched, variable-latency data networks.

  • avahi is is a free Zero-configuration networking (zeroconf) implementation, including a system for multicast DNS/DNS-SD service discovery.

  • dbus is a message bus system that provides an easy way for inter-process communication.

  • cups is the standards-based, open source printing system for UNIX®-like operating systems.

  • cronie contains the standard UNIX daemon crond that runs specified programs at scheduled times and related tools.

Once installed, you need to enable these services via systemctl:

systemctl enable acpid
systemctl enable ntpd
systemctl enable avahi-daemon
systemctl enable org.cups.cupsd.service

GNOME Desktop

A basic GNOME installation without extra GNOME applications can be installed as follows:

pacman -S gnome gdm xorg-server xorg-xinit

Once installed, you need to enable the display server gdm so you're welcomed by a graphical login screen:

systemctl enable gdm

References