All notes
ArchLinux

Walk through

Installation

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.
key_mgmt=WPA-PSK

Gnome


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

sudo systemctl enable gdm
sudo systemctl start gdm

Chromium


# 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.

Basics

Important paths

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

Desktop entries

ArchWiki.


[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

Autostart

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.

Pacman

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

bbs.archlinux.org.


pacman -Syuw --noconfirm
yes | pacman -Syu

Signature

Error: missing key when pacman -Syu

The error looks like this:

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

Solution:


sudo pacman -S archlinux-keyring

Reference: bbs.archlinux.org.

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

updatedb
# 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.
pacdiff
# Or set your own diff program
DIFFPROG=your_editor pacdiff

Check passwd


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

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.

FAQ

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:
    
    [infinality-bundle]
    Server = http://bohoomil.com/repo/$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 bohoomil.com 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

ArchWiki.

mimeapps.list

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


# Precedence:

# user overrides
$HOME/.config/

# sysadmin and vendor overrides
/etc/xdg/

# distribution-provided defaults
/usr/local/share/applications/
/usr/share/applications/

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.

Gnome-control-center

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

xdg-open

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="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="application/x-foobar">
        <comment>foo file</comment>
        <icon name="application-x-foobar"/>
        <glob-deleteall/>
        <glob pattern="*.foo"/>
    </mime-type>
</mime-info>

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


[Desktop Entry]
Name=Foobar
Exec=/usr/bin/foobar
MimeType=application/x-foobar
Icon=foobar
Terminal=false
Type=Application
Categories=AudioVideo;Player;Video;
Comment=

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.

Rescale images


#!/bin/bash
# Rescale all images in a dir to 800 pixel width.

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

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

Touchpad


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:

[Unit]
Description=Some text

[Service]
ExecStart=/myapp/myapp.sh

[Install]
WantedBy=multi-user.target
and enabled it with systemctl enable myapp.service. After reboot the app was started.

Boot process

ArchWiki.

Fonts


# 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 [email protected]=ibus
export QT_IM_MODULE=ibus
ibus-daemon -d -x

For more, see github: ibus-libpinyin.

File system

exfat


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

ntfs-3g

/etc/fstab:


# <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

Bittorrent

rTorrent is recommended for its lightweightness and speed. ArchWiki.

pandoc

PandocOrg.


cabal update
cabal install pandoc pandoc-citeproc

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

sshd

systemctl start sshd.service systemctl enable sshd.service

Network

wpa_passphrase

ArchWiki.

wpa_passphrase MYSSID passphrase

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

wpa_supplicant

163Blog.

# 请不要修改下面这一行内容,否则将不能正常工作
ctrl_interface=/var/run/wpa_supplicant

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

# 使用wpa_supplicant来扫描和选择AP
ap_scan=1

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

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

# 仅使用WPA-PSK方式。允许使用任何合法的加密方式的组合
network={
  ssid="example"
  proto=WPA
  key_mgmt=WPA-PSK
  pairwise=CCMP TKIP
  group=CCMP TKIP WEP104 WEP40
  psk=06b4be19da289f475aa46a33cb793029d4ab3db7a23ee92382eb0106c72ac7bb
  priority=2
}

# 明文连接方式(不使用WPA和IEEE802.1X)
network={
  ssid="plaintext-test"
  key_mgmt=NONE
}

# 共享WEP密钥连接方式(不使用WPA和IEEE802.1X)
network={
  ssid="static-wep-test"
  key_mgmt=NONE
  # 引号包含的密钥是ASCII密钥
  wep_key0="abcde"
  # 没有引号包含的密钥是十六进制密钥
  wep_key1=0102030405
  wep_key2="1234567890123"
  wep_tx_keyidx=0
  priority=5
}

# 共享WEP密钥连接方式(无WPA和IEEE802.1X),使用共享密钥IEEE802.11验证方式
network={
  ssid="static-wep-test2"
  key_mgmt=NONE
  wep_key0="abcde"
  wep_key1=0102030405
  wep_key2="1234567890123"
  wep_tx_keyidx=0
  priority=5
  auth_alg=SHARED
}

# 在IBSS/ad-hoc网络中使用WPA-None/TKIP
network={
  ssid="test adhoc"
  mode=1
  proto=WPA
  key_mgmt=WPA-NONE
  pairwise=NONE
  group=TKIP
  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

wiki.archlinux.org: 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.


#----- 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
vdpauinfo

Browser plugins

Java

Flash player

GNU Gnash

Lightspark

Adobe flash player

Video libs

VDPAU

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.

AUR

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

Boot

Booting into UEFI mode

ArchWiki.

Usual commands

dkms

wiki.archlinux.org. 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

bbs.archLinux.org.



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.

pkgfile

SuperUser. Whatprovides equivalent for arch/pacman.


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

Other tools

Dropbox

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.