All notes

Walk through


mount /, /home on /mnt:
    fdisk -l
    fdisk /dev/sda # n - new, s - save.
    mkfs.ext4 /dev/sda1
    mount /dev/sda1 /mnt/
wifi-menu, systemctl stop dhcpcd.service, man netctl.
edit /etc/pacman.d/mirrorlist
pacstrap /mnt base
genfstab -p /mnt >> /mnt/etc/fstab. use -U or -L for UUID or labels.
arch-chroot /mnt
echo wcfThinkpad > /etc/hostname

ln -s /usr/share/zoneinfo/zone/subzone /etc/localtime
# Set date and time:
date +%Y%m%d -s "2017-04-11"
date +%T -s "21:39:21"

uncomment the needed locales in /etc/locale.gen, run: locale-gen. echo LANG=en_US.UTF-8 > /etc/locale.conf
mkinitcpio -p linux
change root passwd.

install grub.
grub-install /dev/sda
需要安装os-prober. 安装后, 再执行grub-mkconfig -o /boot/grub/grub.cfg

# Enable dhcpcd.service on all interfaces.
sudo systemctl enable dhcpcd

wpa_supplicant -Dn180211,wext -iwlan0 -c<(wpa_passphrase ssid psk)
scan_ssid=1 for hidden ssid.


mkinitcpio is a Bash script used to create an initial ramdisk environment.

Initial ramdisk environment is commonly used to make preparations before the real root file system can be mounted. The initial ramdisk is used for those (wikipedia):

initrd and initramfs refer to two different methods of achieving this.

In the initrd scheme, the image may be a file system image (optionally compressed), which is made available in a special block device (/dev/ram) that is then mounted as the initial root file system.

In the initramfs scheme (available since the Linux kernel 2.6.13), the image may be a cpio archive (optionally compressed). The archive is unpacked by the kernel into a special instance of a tmpfs that becomes the initial root file system. This scheme has the advantage of not requiring an intermediate file system or block drivers to be compiled into the kernel.



cpio is a general file archiver utility and its associated file format.

Its name is derived from the phrase copy in and out, in close description of the program's use of standard input and standard output in its operation.

The use of cpio by the RPM Package Manager, in the initramfs program of Linux kernel 2.6, and in Apple Computer's Installer (pax) make cpio an important archiving tool.


pacman -S xorg-server gnome-shell xorg-xinit
echo "exec gnome-session" >> ~/.xinitrc

sudo systemctl enable gdm
sudo systemctl start gdm


# To install flash for Chromium, install the pepper-flash package.
sudo pacman -S pepper-flash
# Make sure Flash is allowed to run in chrome://settings/content/flash.


Important paths

Trash: ~/.local/share/Trash/files. It's the FreeDesktop standard location.

Desktop entries


[Desktop Entry]
Type=Application                          # Indicates the type as listed above
Version=1.0                               # The version of the desktop entry specification to which this file complies
Name=jMemorize                            # The name of the application
Comment=Flash card based learning tool    # A comment which can/will be used as a tooltip
Exec=jmemorize                            # The executable of the application.
Icon=jmemorize                            # The name of the icon that will be used to display this entry
Terminal=false                            # Describes whether this application needs to be run in a terminal or not
Categories=Education;Languages;Java;      # Describes the categories in which this entry should be shown

# To validate. It is part of the package desktop-file-utils.
desktop-file-validate your desktop file


For XDG-compliant desktop environment, such as GNOME or KDE, the desktop environment will automatically start *.desktop files found in the following directories:

System-wide: $XDG_CONFIG_DIRS/autostart/ (/etc/xdg/autostart/ by default)
GNOME also starts files found in /usr/share/gnome/autostart/
User-specific: $XDG_CONFIG_HOME/autostart/ (~/.config/autostart/ by default)

Users can override system-wide *.desktop files by copying them into the user-specific ~/.config/autostart/ folder.


Quick Reference

#---------- -S: sync

# -w, --downloadonly: Retrieve all packages from the server, but do not install/upgrade anything.

# --noconfirm: Bypass any and all “Are you sure?” messages. It’s not a good idea to do this unless you want to run pacman from a script.

pacman -Syu
pacman -Syuw

# Show all package groups
pacman -Sg
# Show all package in a group
pacman -Sgg _base_
# List all files in an installed package
pacman -Ql binutils

# To list all files in an uninstalled package
sudo pacman -S pkgfile
sudo pkgfile -u
pkgfile -s ss
# core/iproute2
pkgfile -l core/iproute2

#---------- -Q: query

# Query/search for installed packages.
pacman -Qs apache

# Find systemd unit files
pacman -Qql apache | grep -Fe .service -e .socket

#---------- -R: remove

# -s, --recursive: Remove each target specified including all of their dependencies, provided (A) they are not required by other packages; and (B) they were not explicitly installed by the user. This operation is recursive and analogous to a backwards --sync operation, and it helps keep a clean system without orphans. If you want to omit condition (B), pass this option twice.
# -u, --unneeded: Removes targets that are not required by any other packages. This is mostly useful when removing a group without using the -c option, to avoid breaking any dependencies.

pacman -Rs packageName
pacman -Ru groupName

Upgrading automatically

pacman -Syuw --noconfirm
yes | pacman -Syu


Error: missing key when pacman -Syu

The error looks like this:

error: required key missing from keyring
error: failed to commit transaction (unexpected error)


sudo pacman -S archlinux-keyring


The other way may work:

sudo pacman-key --refresh-keys

ArchWiki.To disable PGP signature checking completely, edit /etc/pacman.conf and uncomment the following line under [options]:

SigLevel = Never

You need to comment out any repository-specific SigLevel settings too because they override the global settings.

Adding unofficial keys

It is necessary when adding your own key to the pacman keyring, or enabling a signed unofficial repository.

Pacnew and Pacsave

ArchWiki: Pacnew and Pacsave.

During a package upgrade (pacman -Syu, pacman -Su or pacman -U), .pacnew files are created to avoid overwriting a file which already exists and was previously modified by the user.

.pacsave file may be created during a package removal (pacman -R).

Pacman will output the following log both to console and /var/log/pacman.log:

warning: /etc/pam.d/usermod installed as /etc/pam.d/usermod.pacnew
warning: /etc/pam.d/usermod saved as /etc/pam.d/usermod.pacsave

To locate those files:

find /etc -regextype posix-extended -regex ".+\.pac(new|save)" 2> /dev/null

# Then:
locate -e --regex "\.pac(new|save)$"

egrep "pac(new|save)" /var/log/pacman.log

# This command will automatically find all pacnew files.
# It uses vimdiff by default.
# Or set your own diff program
DIFFPROG=your_editor pacdiff

Check passwd

# Use this command to check the integrity of /etc/passwd
# Check the integrity of group

Advanced explanation

.pacnew is generated by 3-way MD5 sum comparison.

original = X, current = X, new = X
original = X, current = X, new = Y
original = X, current = Y, new = Y
  Under all these conditions, the new conf will overwrite the current one directly.

original = X, current = Y, new = X
  Kee current conf as is, without notifying the user.

original = X, current = Y, new = Z
  New conf is saved as .pacnew.


Android connect

MTP (Media Transfer Protocol), is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).

  1. Install gvfs-mtp. GVfs: GNOME Virtual file system.
  2. Restart.
  3. If there is any problem, type "sudo journalctl -f" for more debug info.
  4. Try unplug and plug the android.

The volume will be mounted on "/run/user/1000/gvfs/".

Firefox has ugly fonts

Install Infinality, which has patched versions of fontconfig and freetype2.

  1. Add the lines to /etc/pacman.conf:
    Server =$arch
  2. Add the key (962DDE58) and locally sign it:
    sudo pacman-key -r 962DDE58
    sudo pacman-key --lsign-key 962DDE58
  3. Sync database files, and install the packages:
    sudo pacman -Sy
    sudo pacman -S fontconfig-infinality-ultimate
  4. It turns out the connection to is not stable...

Disable automatic suspend

StackExchange: How to disable auto suspend.

Edit /etc/systemd/logind.conf, and make sure HandleLidSwitch=ignore, IdleAction=ignore, reload logind.conf: systemctl restart systemd-logind.

wcfNote: also remember to go to Gnome setting panel to disable suspension.

Default applications


mimeapps.list recommends to specify default (preferred) applications for MIME-types in these two kinds of files:

# Precedence:

# user overrides

# sysadmin and vendor overrides

# distribution-provided defaults

When the program update-desktop-database is run (usually as root during the (un)installation of a package), it updates mimeinfo.cache under /usr/local/share/applications and /usr/share/applications directories. These files keep track of which MIME-types are associated with which .desktop files overall, and should not be edited by the user.


Open gnome-control-center, open System > Details > Default Applications.


Custom file association

In this example, 'foobar' will be associated with all *.foo files. This will only affect the current user.

Edit ~/.local/share/mime/packages/application-x-foobar.xml and add this text:

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="">
    <mime-type type="application/x-foobar">
        <comment>foo file</comment>
        <icon name="application-x-foobar"/>
        <glob pattern="*.foo"/>

Create the file ~/.local/share/applications/foobar.desktop to contain something like:

[Desktop Entry]

Now update the applications and mime database with:

update-desktop-database ~/.local/share/applications
update-mime-database    ~/.local/share/mime

Applications do not appear in the Open With... context menu

Locate the .desktop file in /usr/share/applications, edit it as root, and add %U to the end of the Exec= line.

/lib/modules/4.11.9-1-ARCH/modules.devname not found

Warning: /lib/modules/4.11.9-1-ARCH/modules.devname not found - ignoring
version 232
Error: device 'UUID=b5a9a977-e9a7-4d3d-96a9-dcf9c3a9010d' not found. Skipping fsck.
Error: can't find UUID=b5a9a977-e9a7-4d3d-96a9-dcf9c3a9010d 
You are now being dropped into a emergency shell.


# Use a livecd to mount all partitions and use arch-chroot.
mount /dev/sda1 /mnt
arch-chroot /mnt

Regenerate initramfs using:
mkinitcpio -p linux

If you use grub:
grub-mkconfig -o /mnt/boot/grub/grub.cfg


Rescale images

# Rescale all images in a dir to 800 pixel width.

if [ -z "$1" ]; then
	exit -1;

for i in $(ls $1); do
	if [ $i != "." ]; then
		convert -filter Cubic -resize 800 $i $i.s.jpg


sudo pacman -S xf86-input-synaptics

After installation of xf86-input-synaptics, a default configuration file is located at /usr/share/X11/xorg.conf.d/50-synaptics.conf. Users can copy this file to /etc/X11/xorg.conf.d/ and edit it to configure the various driver options available.

Startup programs

Several ways to add auto startup apps: ArchBBS.

ArchBBS. Create ~/.config/systemd/user/myapp.service with the following content:

Description=Some text


and enabled it with systemctl enable myapp.service. After reboot the app was started.

Boot process



# Install build tools
sudo pacman -S binutils make gcc

Ref. 要为单个用户安装字体,请使用 ~/.local/share/fonts (~/.fonts/ 现在已经过时了)。要让 Xserver 能直接载入字体(而不使用某些字体服务),就需要将新增字体的目录加入到 FontPath 中。它位于您的 Xorg 设置目录中(例如 /etc/X11/xorg.conf 或 /etc/xorg.conf) 中。 更新 fontconfig 的字体缓存: fc-cache -vf

Input method

# Get the output in English.
LC_ALL=C <var>command</var>

IBus (Intelligent Input Bus) is an input method framework, a system for entering foreign characters. IBus functions similarly to Fcitx, SCIM and UIM.

sudo pacman -S ibus
# sudo pacman -S ibus-rime
sudo pacman -S ibus-libpinyin
sudo pacman -S gnome-control-center
# First type "ibus-setup" and add input method there.
# and then type "gnome-control-center" and add languages there.
# Now type Super+space to switch input methods.

# To start ibus with GNOME, add this in ~/.profile and restart the GNOME.
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
ibus-daemon -d -x

For more, see github: ibus-libpinyin.

File system


sudo pacman -S exfat-utils
sudo pacman -S fuse-exfat



# <file system>   <dir>		<type>    <options>  <dump>  <pass>
/dev/NTFS-part  /mnt/windows  ntfs-3g   defaults		  0       0

# Mount internal Windows partition with linux compatible permissions, i.e. 755 for directories (dmask=022) and 644 for files (fmask=133)
UUID=01CD2ABB65E17DE0 /run/media/user1/Windows ntfs-3g uid=user1,gid=users,dmask=022,fmask=133 0 0


rTorrent is recommended for its lightweightness and speed. ArchWiki.



cabal update
cabal install pandoc pandoc-citeproc

# or
cabal install cabal-install
~/.cabal/bin/cabal update
~/.cabal/bin/cabal install pandoc


systemctl start sshd.service systemctl enable sshd.service




wpa_passphrase MYSSID passphrase

# network={
#     ssid="MYSSID"
#     #psk="passphrase"
#     psk=59e0d07fa4c7741797a4e394f38a5c321e3bed51d54ad5fcbd3f84bc7415d73d
# }



# 请不要修改下面这一行内容,否则将不能正常工作

# 确保只有root用户能读取WPA的配置

# 使用wpa_supplicant来扫描和选择AP

# 简单的情形:WPA-PSk密码验证方式,PSK是ASCII密码短语,所有合法的加密方式都允许连接
  psk="very secret passphrase"
  # 优先级越高,就能越早匹配到。

# 与前面的设置相同,但要求对特定的SSID进行扫描(针对那些拒绝广播SSID的AP 也就我们常说的隐藏ap)
  ssid="second ssid"
  psk="very secret passphrase"

# 仅使用WPA-PSK方式。允许使用任何合法的加密方式的组合
  pairwise=CCMP TKIP
  group=CCMP TKIP WEP104 WEP40

# 明文连接方式(不使用WPA和IEEE802.1X)

# 共享WEP密钥连接方式(不使用WPA和IEEE802.1X)
  # 引号包含的密钥是ASCII密钥
  # 没有引号包含的密钥是十六进制密钥

# 共享WEP密钥连接方式(无WPA和IEEE802.1X),使用共享密钥IEEE802.11验证方式

# 在IBSS/ad-hoc网络中使用WPA-None/TKIP
  ssid="test adhoc"
  psk="secret passphrase"

Where is nslookup

As an alternative to drill, there are also the dig, host, and nslookup tools from the "bind-tools" package.

wcfNote: use "drill NAME".

Samba, smb, nmb samba.

To provide basic file sharing through SMB start/enable smb.service and/or nmb.service services. The nmb.service service may not always be required (nmbd - NetBIOS name server to provide NetBIOS over IP naming services to clients).

Note: In samba 4.8.0-1, the units were renamed from smbd.service and nmbd.service to smb.service and nmb.service.

The smbd/nmbd/winbindd services have been renamed to smb/nmb/winbind from samba 4.8.0-1.

#----- Add a user
smbpasswd -a samba_user
# Change password
smbpasswd samba_user

#----- List users
pdbedit -L -v

Graphics cards


sudo pacman -S nvidia nvidia-utils

# Check VDPAU
sudo pacman -S vdpauinfo

dkms.conf not exists

# Reinstall it sudo pacman -S nvidia-dkms

Browser plugins


Flash player

GNU Gnash


Adobe flash player

Video libs


Video Decode and Presentation API for Unix (VDPAU) is an open source library and API to offload portions of the video decoding process and video post-processing to the GPU video-hardware.


Arch User Repository.

It contains package descriptions (PKGBUILDs) that allow you to compile a package from source with makepkg and then install it via pacman.

Good packages may be entered into the community repository (directly accessible by pacman or abs).

CAUTION: carefully check the PKGBUILD and any .install file for malicious commands.

# Make sure build tools are installed.
pacman -S --needed base-devel

# Optimize /etc/makepkg.conf

tar -xvf foo.tar.gz
cd foo

# -s, --syncdeps, Install missing dependencies using pacman.
# -r/--rmdeps removes the build-time dependencies after build
# -i/--install
makepkg -s

# -U, --upgrade, Upgrade or add package(s) to the system and install the required dependencies from sync repositories.
sudo pacman -U foo-0.1-1-i686.pkg.tar.xz

# To list all foreign packages:
# -Q, --query
# -m, --foreign, Restrict or filter output to packages that were not found in the sync database(s). Typically these are packages that were downloaded manually and installed with --upgrade.
pacman -Qm 

# Remove
# -s, --recursive: Remove each target specified including all of their dependencies, provided that (A) they are not required by other packages; and (B) they were not explicitly installed by the user. This operation is recursive and analogous to a backwards --sync operation, and it helps keep a clean system without orphans. If you want to omit condition (B), pass this option twice.
pacman -Rss packageName


Booting into UEFI mode


Usual commands

dkms Dynamic Kernel Module Support.

# Tab-completion is available by doing:
source /usr/share/bash-completion/completions/dkms

# To list the current status of modules, versions and kernels within the tree:
dkms status

# Rebuild all modules for the currently running kernel:
dkms autoinstall
# For a specific kernel:
dkms autoinstall -k 3.16.4-1-ARCH

# To build a specific module for the currently running kernel:
dkms install -m nvidia -v 334.21
# or simply:
dkms install nvidia/334.21
# To build a module for all kernels:
dkms install nvidia/334.21 --all

# To remove a module (old ones are not automatically removed):
dkms remove -m nvidia -v 331.49 --all
# or simply:
dkms remove nvidia/331.49 --all

netstat, ss

pacman -Qo /bin/netstat
# /bin/netstat is owned by net-tools 1.60.20110819cvs-3
# So install "net-tools" will let you have netstat/route back.
# NOTE: net-tools are deprecated and you should be using iproute2 instead. e.g. use "ss" instead of netstat.


SuperUser. Whatprovides equivalent for arch/pacman.

sudo pkgfile -u
# -s, --search. It is the default operation.
pkgfile aclocal
pkgfile -s aclocal

Other tools


ArchWiki: dropbox.

~/.dropbox - Dropbox's configuration directory
~/Dropbox - Dropbox's download directory (default)

Start at login

systemctl enable --user dropbox

Proxy settings

The easiest way to set Dropbox's proxy settings is by defining them manually in the Proxies tab of the Preferences window.