Arch Guide

04. Initial configuration

How to create and edit text files

We previously installed the text editor nano. To start nano with a given file name (the file you want to create or edit) like /some/file, run:
nano /some/file

Once again, the left side of the flashing rectangle is your cursor. Moving it over the top/bottom scrolls up/down one line. Using the page up/down keys on your keyboard scrolls up/down one screen height worth of lines.

After you're done editing or entering text, press Ctrl+X to exit, then Y to save and press enter to confirm the file name we already entered while starting nano.


There's a faster way to write some text to a file (without nano):

To overwrite /some/file with text [text], run:
echo [text] > /some/file

If your text contains spaces, you need to put quotes around it like this:
echo "Hello world!" > /some/file

The same applies to file names containing spaces:
echo [text] > "/etc/some file"

In case you want to write the text as a new line at the back of the existing file contents instead of replacing them, use >> instead of >:
echo "new line" >> /some/file


To output a file's contents, use cat. For /some/file, you'd need to run:
cat /some/file

Entering the environment

We will now temporarily change our root directory to /mnt, so we'll essentially run commands on our Arch installation.

You can do that by running:
arch-chroot /mnt /bin/bash

Installing sudo

sudo can be used to run things as the user root without logging in as such (because you shouldn't do everything as the root user), of course only if the current account is permitted to use sudo, we'll set that up later.

To install sudo, run:
pacman -S sudo

NTFS support

If you'd like to be able to use drives formatted as NTFS (such as drives with Windows installations and most large drives formatted using Windows or for Windows usage), you need to add support for it to your Arch installation.

You can do that by installing ntfs-3g like so:
pacman -S ntfs-3g

Installing NetworkManager

We will use NetworkManager to handle and configure our network connection. If you want, you can also use something like dhcpcd instead.

You can install NetworkManager by running:
pacman -S networkmanager

We also need to enable the corresponding service so it's loaded when we boot our system:
systemctl enable NetworkManager

Setting a root password

In order to log in after booting, we need to set a password for the user root by running:
passwd

You will have to enter the same password twice and you won't see any characters you're typing (or that you're typing anything at all), just press enter after each password entry.

Setting the time

First, we'll need to set the correct time zone. These are usually named after big cities near you (such as Berlin in Europe for Germany's time zone or names such as "Central Time".

If you're not sure, simply search "[your city] time zone" online. If you find something like "Central European Time" (not present), look up a datasheet for time zones (like here) and search for the name you found.

To list possible groups of time zones (such as "Europe" or "US"), run:
ls -d /usr/share/zoneinfo/*/

To list time zones in a group (e.g. Europe), run:
ls /usr/share/zoneinfo/Europe

Once you've found the correct time zone file (e.g. Europe/Berlin), set it as the one to use by running:
ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime

After that's done, sync your hardware clock (RTC) by running:
hwclock --systohc

If you are dual-booting with Windows, you should set your hardware clock to use the local time instead of UTC (because Windows uses the local time and can't really deal with an RTC set to UTC):
timedatectl set-local-rtc 1

Setting the locale

Open the file /etc/locale.gen in nano (like described at the top of the page). If you want your locale to be English for the US, look for en_US.

To search in nano, press Ctrl+W, enter whatever you're looking for (like en_US) and press enter. It will relocate the cursor to the first/next instance of the search term (as long as it found it).

Once you've found your desired locale, you need to uncomment the lines that start with that code by removing the # in the beginning of those lines.

For example, if you want to use en_US with character encodings UTF-8 and ISO-8859-1, make it look like this:
#...
#en_SG ISO-8859-1
en_US.UTF-8 UTF-8
en_US ISO-8859-1
#en_ZA.UTF-8 UTF-8
#...

Save and exit nano.

Now, apply the change by running:
locale-gen

Setting the language

Set your system language to use one of the locales you uncommented (e.g. en_US.UTF-8, I recommend UTF-8) by writing something like LANG=en_US.UTF-8 to /etc/locale.conf.

You can do this in one command (like described above):
echo "LANG=en_US.UTF-8" > /etc/locale.conf

Setting the keyboard layout

We need to set the keyboard layout for a second time, you can use the same keyboard code as at the start of the guide.

Set it by writing something like KEYMAP=de-latin1 to /etc/vconsole.conf.

Setting the hostname

Your hostname is the name other computers on your network can see.

You can set it by writing it (nothing else) to /etc/hostname.

Adding localhost to /etc/hosts

To be able to reach your own computer as localhost, add the following two lines to /etc/hosts (replace [TAB] with a press of the tab key):
127.0.0.1[TAB]localhost[TAB][YOUR HOSTNAME]
::1[TAB]localhost[YOUR HOSTNAME]

Using disk encryption?

If you're using disk encryption, you need to do one more thing - otherwise skip this step.

Edit the HOOKS=... line in /etc/mkinitcpio.conf in a way so that encrypt, keyboard and keymap are in front of filesystems.

The line should look more or less like this:
HOOKS=(base udev autodetect modconf kms keyboard keymap consolefont block encrypt filesystems fsck)

Once that's done, run (if you're using a kernel other than linux, replace it with your kernel's name):
mkinitcpio -p linux

[Troubleshooting] If the first attempt of entering your disk password is always wrong (later on) because it's using the wrong keyboard layout, edit the HOOKS=... line to either move keymap in front of autodetect or remove autodetect entirely, then run the mkinitcpio command again.

Exiting the environment

To leave the /mnt environment again, run:
exit

Note that you don't need to do this if you're planning to use GRUB as a boot manager in the next step since that step starts by entering the /mnt environment again.

Next: Boot setup