Arch Linux 软件安装和用法

隐藏 GRUB 加载

参考资料

    # vim /etc/default/grub
    # grub-mkconfig -o /boot/grub/grub.cfg

修改 /etc/default/grub

-GRUB_TIMEOUT=1
+GRUB_TIMEOUT=0

Reflector 更新镜像

https://wiki.archlinux.org/title/reflector

开机自动执行

/etc/xdg/reflector/reflector.conf

--save /etc/pacman.d/mirrorlist
--country China
--protocol https
--latest 5
systemctl enable reflector
systemctl start reflector
vim /usr/lib/systemd/system/reflector.service

[Service] -> ExecStart 值的开始添加 /usr/bin/proxychains ,目的是使用代理。之所以这样做是因为中国的网络对国外内容不友好,如果不设置代理,直接执行 systemctl start reflector 会出现如下错误:

# error: failed to retrieve mirrorstatus data: URLError: <urlopen error [Errno 101] Network is unreachable>

通过 Pacman hook 自动化以上步骤

这样每次升级软件包时,都会自动更新软件镜像。

/etc/pacman.d/hooks/mirrorupgrade.hook

[Trigger]
Operation = Upgrade
Type = Package
Target = pacman-mirrorlist

[Action]
Description = Updating pacman-mirrorlist with reflector and removing pacnew...
When = PostTransaction
Depends = reflector
Exec = /bin/sh -c 'systemctl start reflector.service; [ -f /etc/pacman.d/mirrorlist.pacnew ] && rm /etc/pacman.d/mirrorlist.pacnew'

网络

中兴 F30 随身 Wifi 无法连接网络,显示 Limited Connectivity(This device appears to be connected to a network but is unable to reach the internet.)

在英文 ArchLinux 论坛看到一个帖子与随身 Wifi 相关的。

插上随身 Wifi 后,输入 lsusb 命令,找到对应的英文名称 ZTE WCDMA Technologies MSM SZXF Mobile Boardband 。经过搜索之后,我判断是近期和 NetworkManager 相关的包升级后出的问题。

一些插上随身 Wifi 的 journalctl -f 的日志输出:

Jan 21 22:50:39 arch kernel: usb 1-1.4: new high-speed USB device number 10 using xhci_hcd
Jan 21 22:50:39 arch kernel: usb 1-1.4: New USB device found, idVendor=19d2, idProduct=1225, bcdDevice= 1.01
Jan 21 22:50:39 arch kernel: usb 1-1.4: New USB device strings: Mfr=2, Product=4, SerialNumber=5
Jan 21 22:50:39 arch kernel: usb 1-1.4: Product: SZXF Mobile Boardband
Jan 21 22:50:39 arch kernel: usb 1-1.4: Manufacturer: SZXF,Incorporated
Jan 21 22:50:39 arch kernel: usb 1-1.4: SerialNumber: 1234567890ABCDEF
Jan 21 22:50:39 arch kernel: usb-storage 1-1.4:1.0: USB Mass Storage device detected
Jan 21 22:50:39 arch kernel: usb-storage 1-1.4:1.0: Quirks match for vid 19d2 pid 1225: 1
Jan 21 22:50:39 arch kernel: scsi host3: usb-storage 1-1.4:1.0
Jan 21 22:50:39 arch mtp-probe[10214]: checking bus 1, device 10: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.4"
Jan 21 22:50:39 arch mtp-probe[10214]: bus: 1, device: 10 was not an MTP device
Jan 21 22:50:39 arch mtp-probe[10226]: checking bus 1, device 10: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.4"
Jan 21 22:50:39 arch mtp-probe[10226]: bus: 1, device: 10 was not an MTP device
Jan 21 22:50:40 arch kernel: scsi 3:0:0:0: CD-ROM            SZXF     USB SCSI CD-ROM  2.31 PQ: 0 ANSI: 2
Jan 21 22:50:40 arch kernel: sr 3:0:0:0: Power-on or device reset occurred
Jan 21 22:50:40 arch kernel: sr 3:0:0:0: [sr0] scsi-1 drive
Jan 21 22:50:40 arch kernel: sr 3:0:0:0: Attached scsi CD-ROM sr0
Jan 21 22:50:43 arch kernel: usb 1-1.4: USB disconnect, device number 10
Jan 21 22:50:43 arch kernel: usb 1-1.4: new high-speed USB device number 11 using xhci_hcd
Jan 21 22:50:44 arch kernel: usb 1-1.4: New USB device found, idVendor=19d2, idProduct=1557, bcdDevice= 1.01
Jan 21 22:50:44 arch kernel: usb 1-1.4: New USB device strings: Mfr=2, Product=4, SerialNumber=5
Jan 21 22:50:44 arch kernel: usb 1-1.4: Product: SZXF Mobile Boardband
Jan 21 22:50:44 arch kernel: usb 1-1.4: Manufacturer: SZXF,Incorporated
Jan 21 22:50:44 arch kernel: usb 1-1.4: SerialNumber: 1234567890ABCDEF
Jan 21 22:50:44 arch kernel: cdc_ether 1-1.4:1.0 eth0: register 'cdc_ether' at usb-0000:00:14.0-1.4, ZTE CDC Ethernet Device, 34:4b:50:00:00:00
Jan 21 22:50:44 arch kernel: usb-storage 1-1.4:1.2: USB Mass Storage device detected
Jan 21 22:50:44 arch kernel: scsi host3: usb-storage 1-1.4:1.2
Jan 21 22:50:44 arch NetworkManager[511]: <info>  [1705848644.0628] manager: (eth0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/67)
Jan 21 22:50:44 arch mtp-probe[10245]: checking bus 1, device 11: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.4"
Jan 21 22:50:44 arch mtp-probe[10245]: bus: 1, device: 11 was not an MTP device
Jan 21 22:50:44 arch NetworkManager[511]: <info>  [1705848644.0764] audit: op="statistics" interface="eth0" ifindex=59 args="500" pid=1018 uid=1000 result="success"
Jan 21 22:50:44 arch NetworkManager[511]: <info>  [1705848644.0848] audit: op="statistics" interface="eth0" ifindex=59 args="500" pid=1018 uid=1000 result="success"
Jan 21 22:50:44 arch kernel: cdc_ether 1-1.4:1.0 enp0s20f0u1u4: renamed from eth0
Jan 21 22:50:44 arch NetworkManager[511]: <info>  [1705848644.1406] device (eth0): interface index 59 renamed iface from 'eth0' to 'enp0s20f0u1u4'
Jan 21 22:50:44 arch NetworkManager[511]: <info>  [1705848644.1626] device (enp0s20f0u1u4): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Jan 21 22:50:44 arch NetworkManager[511]: <info>  [1705848644.1669] device (enp0s20f0u1u4): carrier: link connected
Jan 21 22:50:44 arch NetworkManager[511]: <info>  [1705848644.1680] device (enp0s20f0u1u4): state change: unavailable -> disconnected (reason 'carrier-changed', sys-iface-state: 'managed')
Jan 21 22:50:44 arch tailscaled[669]: monitor: RTM_DELROUTE: src=, dst=ff00::/8, gw=, outif=59, table=255
Jan 21 22:50:44 arch mtp-probe[10264]: checking bus 1, device 11: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.4"
Jan 21 22:50:44 arch mtp-probe[10264]: bus: 1, device: 11 was not an MTP device
Jan 21 22:50:44 arch NetworkManager[511]: <info>  [1705848644.1821] device (enp0s20f0u1u4): state change: disconnected -> unavailable (reason 'carrier-changed', sys-iface-state: 'managed')
Jan 21 22:50:45 arch kernel: scsi 3:0:0:0: Direct-Access     SZXF MMC  Storage 2.31         PQ: 0 ANSI: 2
Jan 21 22:50:45 arch kernel: sd 3:0:0:0: Power-on or device reset occurred
Jan 21 22:50:45 arch kernel: sd 3:0:0:0: [sdc] Media removed, stopped polling
Jan 21 22:50:45 arch kernel: sd 3:0:0:0: [sdc] Attached SCSI removable disk

也出现了 wpa_supplicant[575]: wlp3s0: CTRL-EVENT-BEACON-LOSS

设置代理

Clash

pacman -S clash
clash # Generate config.yaml, Country.mmdb in ~/.config/clash
## download yaml file from your service provider, rename it to config.yaml, put it under your clash folder

# open clash at start https://github.com/Dreamacro/clash/wiki/clash-as-a-daemon
vim /etc/systemd/system/clash.service

/etc/systemd/system/clash.service

[Unit]
Description=Clash daemon, A rule-based proxy in Go.
After=network.target

[Service]
Type=simple
Restart=always
ExecStart=/usr/local/bin/clash -d "/home/archie/.config/clash"

[Install]
WantedBy=multi-user.target

proxychains-ng

https://github.com/rofl0r/proxychains-ng

pacman -S proxychains-ng

输入法配置——Fcitx5

# Install fcitx5-im group(fcitx5, fcitx5-configtool, fcitx5-gtk, fcitx5-qt),并安装词库、主题:
pacman -S fcitx5-im fcitx5-chinese-addons fcitx5-pinyin-zhwiki fcitx5-material-color

添加对 gtk,qt 类(指通过 gtk、qt 编程得到的软件)软件的支持:

# /etc/profile
export XMODIFIERS="@im=fcitx"
export GTK_IM_MODULE="fcitx"
export QT_IM_MODULE="fcitx"

配置开机启动;主题:material-color-black

但是,当我安装好时,不能在 Konsole 这个命令行模拟器输入中文,尝试很多办法 /etc/profile (如上所示),在 ~/.profile 等文件中加入以上相同的内容,但是(可能因为没有关机再开机)依然不可行。终于在 Wayland environment - Environment variables 这里发现,需要设置 Wayland 环境变量。

fcitx5 使用发现

Enter 回车键异常:中文模式下,按 ; 后再按 Enter 无法输入英文分号。可能不是问题,刚从 fcitx4 升级到 fcitx5。

经过这些时间的磨合,发现:这的确是一个 bug。过段时间,我改变了想法,想到这可能是因为不同软件之间 Enter 键的作用不同造成的。

码表(其实是个人词库)

字体

Coding with Character

使用的是以前用过的 GNOME 桌面环境的默认字体设置:

所有安装的字体:

pacman -S noto-fonts noto-fonts-emoji noto-fonts-cjk adobe-source-han-sans-cn-fonts adobe-source-han-serif-cn-fonts

中文,英文:

noto-fonts, noto-fonts-cjk, adobe-source-han-sans-cn-fonts, adobe-source-han-serif-cn-fonts

代码:

Source Code Pro

Emoji:

  • noto-fonts-emoji
  • 命令行安装的字体所在的目录: /usr/share/fonts/
  • 手动安装的字体所在的目录: ~/.local/share/fonts/
fc-cache -fv # 更新字体缓存

用户配置字体配置文件位于 ~/.config/fontconfig/.fonts.conf

https://wiki.archlinux.org/title/Font_configuration/Examples#Chinese_in_Noto_Fonts

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>

  <match target="font">
    <edit mode="assign" name="rgba">
      <const>rgb</const>
    </edit>
  </match>

  <match target="font">
    <edit mode="assign" name="hintstyle">
      <const>hintslight</const>
    </edit>
  </match>

  <match target="font">
    <edit mode="assign" name="antialias">
      <bool>true</bool>
    </edit>
  </match>

  <!-- Map fonts that are commonly used by web pages to our preferred fonts -->
  <match target="pattern">
    <test qual="any" name="family"><string>Cantarell</string></test>
    <edit name="family" mode="assign" binding="same"><string>sans-serif</string></edit>
  </match>

  <match target="pattern">
    <test qual="any" name="family"><string>BlexMono Nerd Font Mono</string></test>
    <edit name="family" mode="assign" binding="same"><string>monospace</string></edit>
  </match>

  <!-- Default font for the zh_CN locale (no fc-match pattern) -->
  <match>
    <test compare="contains" name="lang">
      <string>zh_CN</string>
    </test>
    <edit mode="prepend" name="family">
      <string>Noto Sans CJK SC</string>
    </edit>
  </match>

  <!-- Default sans-serif font -->
  <match target="pattern">
    <test qual="any" name="family">
      <string>sans-serif</string></test>
    <edit name="family" mode="prepend" binding="same">
      <string>Noto Sans</string>
    </edit>
  </match>

  <!-- Default serif fonts -->
  <match target="pattern">
    <test qual="any" name="family">
      <string>serif</string>
    </test>
    <edit name="family" mode="prepend" binding="same">
      <string>Noto Serif</string>
    </edit>
  </match>

  <!-- Default monospace fonts -->
  <match target="pattern">
    <test qual="any" name="family">
      <string>monospace</string>
    </test>
    <edit name="family" mode="prepend" binding="same">
      <string>BlexMono Nerd Font Mono</string>
    </edit>
  </match>

  <!-- Fallback fonts preference order -->
  <alias>
    <family>sans-serif</family>
    <prefer>
      <family>Noto Sans</family>
      <family>Noto Sans CJK SC</family>
      <family>Noto Sans CJK TC</family>
      <family>Noto Sans CJK JP</family>
      <family>Noto Sans CJK KR</family>
      <family>Noto Color Emoji</family>
      <family>Noto Emoji</family>
    </prefer>
  </alias>
  <alias>
    <family>serif</family>
    <prefer>
      <family>Noto Serif</family>
      <family>Noto Serif CJK SC</family>
      <family>Noto Serif CJK TC</family>
      <family>Noto Serif CJK JP</family>
      <family>Noto Serif CJK KR</family>
      <family>Noto Color Emoji</family>
      <family>Noto Emoji</family>
    </prefer>
  </alias>
  <alias>
    <family>monospace</family>
    <prefer>
      <family>BlexMono Nerd Font Mono</family>
      <family>Noto Color Emoji</family>
      <family>Noto Emoji</family>
    </prefer>
  </alias>

  <selectfont>
    <rejectfont>
      <pattern>
        <patelt name="family" >
          <!-- This font is causing problem with GitHub -->
          <string>Nimbus Sans</string>
        </patelt>
      </pattern>
    </rejectfont>
  </selectfont>

</fontconfig>

参考:

  1. https://wiki.archlinux.org/title/Microsoft_fonts
  2. https://wiki.archlinux.org/title/Fonts
  3. https://wiki.archlinux.org/title/Font_configuration
  4. fontconfig user docs
  5. https://szclsya.me/zh-cn/posts/fonts/linux-config-guide/
  6. Get emojis working on arch linux with noto-fonts-emoji(文章里的配置步骤有点错误)
  7. Noto Emoji Color fontconfig for Konsole
  8. Font configuration for CJK support in Ubuntu

蓝牙

systemctl enable --now bluetooth

无法添加蓝牙耳机

# 来自 bluetooth.service 的 systemd log
# ConfigurationDirectory 'bluetooth' already exists but the mode is different. (File system: 755 ConfigurationDirectoryMode: 555)
# src/device.c:device_set_wake_support() Unable to set wake_support without RPA resolution
# src/adapter.c:set_device_privacy_complete() Set device flags return status: Invalid Parameters

经过搜索发现一些人遇到过类似问题

# dmesg | grep Bluetooth 输出
[    2.357525] usb 1-8: Product: Bluetooth Radio
[    3.057353] Bluetooth: Core ver 2.22
[    3.057403] Bluetooth: HCI device and connection manager initialized
[    3.057410] Bluetooth: HCI socket layer initialized
[    3.057413] Bluetooth: L2CAP socket layer initialized
[    3.057420] Bluetooth: SCO socket layer initialized
[    3.716563] Bluetooth: hci0: RTL: examining hci_ver=08 hci_rev=000c lmp_ver=08 lmp_subver=8821
[    3.717200] Bluetooth: hci0: RTL: rom_version status=0 version=1
[    3.717204] Bluetooth: hci0: RTL: loading rtl_bt/rtl8821c_fw.bin
[    3.722382] Bluetooth: hci0: RTL: loading rtl_bt/rtl8821c_config.bin
[    3.723300] Bluetooth: hci0: RTL: cfg_sz 10, total sz 31990
[    4.174265] Bluetooth: hci0: RTL: fw version 0x829a7644
[    5.868007] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[    5.868012] Bluetooth: BNEP filters: protocol multicast
[    5.868017] Bluetooth: BNEP socket layer initialized
[    6.136304] Bluetooth: hci0: Bad flag given (0x2) vs supported (0x1)
[   17.200632] Bluetooth: RFCOMM TTY layer initialized
[   17.200645] Bluetooth: RFCOMM socket layer initialized
[   17.200654] Bluetooth: RFCOMM ver 1.11
[   32.473238] Bluetooth: hci0: unexpected cc 0x0c7c length: 1 < 3
[  962.089278] Bluetooth: hci0: Bad flag given (0x2) vs supported (0x1)
[  971.016364] Bluetooth: hci0: unexpected cc 0x0c7c length: 1 < 3

之后按照这里的说法,执行以下命令安装 bluedevil, bluez-utils, pulseaudio-bluetooth。重启之后问题解决了。

yay -Syyuu bluedevil bluez-utils pulseaudio-bluetooth

Git

pacman -S openssh
wget -O ~/.gitconfig https://github.com/tianheg/dotfiles/raw/main/gitconfig
# 不要忘记 commit.gpgsign true

## SSH
chmod 400 ~/.ssh/id_ed25519
# 解决 sign_and_send_pubkey: signing failed for ED25519 "/home/user/.ssh/id_ed25519" from agent: agent refused operation; git@github.com: Permission denied (publickey).

git-credential-oauth

https://github.com/hickford/git-credential-oauth

## way 1
export GCO_VERSION=0.7.0
wget -q https://github.com/hickford/git-credential-oauth/releases/download/v${GCO_VERSION}/git-credential-oauth_${GCO_VERSION}_linux_amd64.tar.gz -O - | tar -xz -C .
# three files: git-credential-oauth*  LICENSE.txt  README.md
sudo mv git-credential-oauth /usr/local/bin

## way 2
yay -S git-credential-oauth

### next step
echo url=https://github.com | git credential fill # complete the authentication process

GPG

修改 ~/.gnupg/ 权限:

# https://superuser.com/a/954536 ; https://superuser.com/a/954639
# Set ownership to your own user and primary group
chown -R "$USER:$(id -gn)" ~/.gnupg
# Set permissions to read, write, execute for only yourself, no others
chmod 700 ~/.gnupg
# Set permissions to read, write for only yourself, no others
chmod 600 ~/.gnupg/*

这几条命令解决 gpg: WARNING: unsafe permissions on homedir '/home/user/.gnupg'

~/.gnupg 文件夹保存在安全的地方 ,然后导入 GitHub(user + web-flow)公匙:

wget -O tianheg-pubkeys.txt https://github.com/tianheg.gpg
wget -O github-web-flow.txt https://github.com/web-flow.gpg
gpg --import tianheg-pubkeys.txt
gpg --import github-web-flow.txt

安装 seahorse 以防止每次 git commit 都要输入密码(不必麻烦,通过设置 ~/.gnupg/gpg-agent.conf 可以延长密码时效)。

default-cache-ttl 28800
max-cache-ttl 28800

键盘映射

https://tonsky.me/blog/cursor-keys/

把上下左右键映射到字母键:

vim ~/ijkl
xmodmap ~/ijkl

ijkl

keycode 66 = Mode_switch
keysym j = j J Left
keysym l = l L Right
keysym i = i I Up
keysym k = k K Down

但是,在做完以上步骤后,我的 Left Ctrl -> CapsLock 的映射失效了,所以我需要修改文件内容。

让一切恢复之前的状态的命令: setxkbmap -layout us

在 KDE 桌面环境下,有方便的系统设置菜单,可以设置键盘映射。

声音

https://wiki.archlinux.org/title/Sound_system

用到的软件:ALSA(驱动接口)、PipeWire & PulseAudio(声音服务器)

错误日志:

vlcpulse audio output error: stream connection failure: Bad state
main audio output error: module not functional
main decoder error: failed to create audio output

pulse audio output error: overflow, flushing

pulseaudio[6402]: Failed to create sink input: sink is suspended.

我又试了一次下面的命令,竟然可以了!

pulseaudio -k
# Kill a running daemon

目前问题未解决,声音时有时无。

在 KDE 的音量设置界面,先设置成其他声卡输出,然后再设置成 Analog Stereo Duplex。可能有效果。

~/.config/pulse/default.pa

.include /etc/pulse/default.pa

set-default-source alsa_output.pci-0000_00_1f.3.analog-stereo.monitor
set-card-profile alsa_card.pci-0000_00_1f.3 output:analog-stereo+input:analog-stereo
set-default-sink alsa_output.pci-0000_00_1f.3.analog-stereo

根据 ArchWiki 进行上述配置。

pacman

添加 archlinuxcn

添加库 /etc/pacman.conf

[archlinuxcn]
Server = https://repo.archlinuxcn.org/$arch

导入 PGP 公匙(为了验证 archlinuxcn 库):

pacman-key --lsign-key "farseerfc@archlinux.org" # for error: ...is marginal trust
pacman -Syy && pacman -S archlinuxcn-keyring

pacman 命令

## 常用
pacman -Qe # List all explicitly installed packages
pacman -Qet # list all packages explicitly installed and not required as dependencies
pacman -Qent # List all explicitly installed native packages (i.e. present in the sync database) that are not direct or optional dependencies
pacman -Qn # List all native packages (installed from the sync database(s))
pacman -Qm # List all foreign packages (typically manually downloaded and installed or packages removed from the repositories)

sudo pacman -Qtdq | sudo pacman -Rns - # recursively removing orphans and their configuration files

sudo pacman -Qii | awk '/^MODIFIED/ {print $2}' # print modified files under /etc

pacman -Qs regex # List packages by regex

pacman -Qg group_name # List installed packages under this group
pacman -Sg group # List all packages in the package group named `group`, etc, base-devel, gnome
pacman -Slq | rg <package> # search package_name
pacman -Qq | grep -Ee '-(bzr|cvs|darcs|git|hg|svn)$' # list all development/unstable packages
pacman -Syu # Update package list and upgrade all packages afterwards
pacman -Syu git # Update package list, upgrade all packages, and then install git if it wasn’t already installed

pacman -S package_name1 package_name2 # Installing specific packages
pacman -S $(pacman -Ssq package_regex) # Install a list of packages with regex
pacman -S extra/package_name # Install specific repositories' package
pacman -S plasma-{desktop,mediacenter,nm}
pacman -S plasma-{workspace{,-wallpapers},pa}

pacman -S gnome # Install through group of packages
# Enter a selection (default=all): 1-10 15 # which will select packages 1 through 10 and 15 for installation
# Enter a selection (default=all): ^5-8 ^2 # which will select all packages except 5 through 8 and 2 for installation

pacman -R package_name # remove a single package, leaving all of its dependencies installed
pacman -Rs package_name # remove a single package and its dependencies which are not required by any other installed package

pacman -Qtd # check for packages that were installed as a dependency but now, no other packages depend on them

pacman -Ss string1 string2 ... # search for packages in the database
pacman -Qs string1 string2 ... # search for already installed packages
pacman -F string1 string2 ... # search for package file names in remote packages
pacman -Fy string1 string2 ... # first flush local cache, then search for package file names in remote packages

pacman -Si package_name # display extensive information about a given package
pacman -Qi package_name # display extensive information about locally installed packages
pacman -Qii package_name # also display the list of backup files and their modification states

pacman -Ql package_name # retrieve a list of the files installed by a package
pacman -Fl package_name # retrieve a list of the files installed by a remote package

# 批量删除 Pacman 包
sudo pacman -Rs $(pacman -Qq | grep some_words)
# https://bbs.archlinux.org/viewtopic.php?pid=1533162#p1533162

## Rarely use
pacman -Qk package_name # verify the presence of the files installed by a package, Passing the k flag twice will perform a more thorough check
pacman -Qo /path/to/file_name # query the database to know which package a file in the file system belongs to
pacman -Qo command_name # 找到所属包
pacman -F /path/to/file_name # query the database to know which remote package a file belongs to

应该避免执行的 pacman 指令

pacman -Sy # never run!!!
pacman -Rdd package # never run!!!

在 Arch 中安装包时应避免没有升级系统就刷新包列表。这样做是为了避免出现依赖问题,比如,如果一个包被从官方仓库中移除,在进行包同步时就会报错。在实践中,不要执行 pacman -Sy package_name ,应该执行 pacman -Syu package_name

informant

一个 Arch Linux 新闻阅读器和 pacman hook。可以帮你在更新包时检查是否还有没有阅读的 Arch Linux 新闻。

执行 pacman 命令过程中,遇到的信息/警告/错误

循环依赖:

warning: dependency cycle detected

执行 sudo pacman -Syu 时:

WARNING: Possibly missing firmware for module

这是一种警告。

参考:

  1. https://wiki.archlinux.org/title/Mkinitcpio#Possibly_missing_firmware_for_module_XXXX
  2. https://arcolinuxforum.com/viewtopic.php?t=1174

gpg: key 786C63F330D7CB92: no user ID for key signature packet of class 10

gpg: key 786C63F330D7CB92: no user ID for key signature packet of class 10
gpg: key 1EB2638FF56C0C53: no user ID for key signature packet of class 10
gpg: next trustdb check due at 2021-10-09
  -> Disabled 3 keys.

## try 1
# pacman-key --refresh-keys
# pacman -S archlinux-keyring archlinuxcn-keyring
## try 2
# rm -R /etc/pacman.d/gnupg/ # No such file or directory
# rm -rf /etc/pacman.d/gnupg/
# rm -R /root/.gnupg/
# rm -R /var/cache/pacman/pkg/
# gpg --refresh-keys
# pacman-key --init
# pacman-key --populate archlinux # still display `gpg: key xxx: no user ID for key signature packet of class 10`
# pacman-key --refresh-keys
# pacman -Syyu

warning: /etc/pacman.d/mirrorlist installed as /etc/pacman.d/mirrorlist.pacnew

/etc/mkinitcpio.d/linux.preset: 'default' and /etc/mkinitcpio.d/linux.preset: 'fallback'

第 X 个提示:ERROR: A182F28FA78F70601453137BCF82E29597321B63 could not be locally signed.

解决方法:

rm -rf /etc/pacman.d/gnupg
pacman-key --init
pacman-key --populate archlinux
pacman-key --populate archlinuxcn

参考:

  1. Installing and upgrading packages
  2. Is it possible that there is a major kernel update in the repository, and that some of the driver packages have not been updated?
  3. https://wiki.archlinux.org/title/Pacman/Tips_and_tricks
  4. https://wiki.archlinux.org/title/Pacman
  5. https://wiki.archlinux.org/title/System_maintenance#Avoid_certain_pacman_commands
  6. https://wiki.archlinux.org/title/Pacman/Rosetta
  7. https://wiki.archlinux.org/title/Mkinitcpio

yay

Yet Another Yogurt: 又一个从 Arch User Repository 下载包的工具。

安装 yay

官方仓库:https://github.com/Jguer/yay

# pacman -S --needed git base-devel
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

如果想通过 pacman 官方仓库里的 yay 包安装,在版本升级时可能会有滞后。可以在通过 pacman 安装 yay 后,运行命令:

yay -S yay

保证得到 yay 的最新版本。

使用 yay

# Interactively search and install packages from the repos and AUR:
yay package_name|search_term
# Synchronize and update all packages from the repos and AUR:
yay
# Synchronize and update only AUR packages:
yay -Sua
# Install a new package from the repos and AUR:
yay -S package_name
# Remove an installed package and both its dependencies and configuration files:
yay -Rns package_name
# Search the package database for a keyword from the repos and AUR:
yay -Ss keyword
# Remove orphaned packages (installed as dependencies but not required by any package):
yay -Yc
# Show statistics for installed packages and system health:
yay -Ps

代理 yay

https://github.com/Jguer/yay/issues/951#issuecomment-1080206297

  1. sudo vim /etc/proxychains.conf
  2. 注释 proxy_dns

yay 问题

  1. 安装时总是出现 WARNING: Using existing $srcdir/ tree ,这个可以忽视,只是说明安装过程。
  2. timeout 问题 https://github.com/Jguer/yay/issues/1278#issuecomment-635833427
  3. Missing AUR Packages

参考:

  1. https://github.com/Jguer/yay
  2. https://github.com/Jguer/yay/issues/1248

备份

  1. 通过 rsynccrontab 定时将 /etc , ~/.config 等配置文件备份到 Git 仓库 dotfiles 中。
  2. 云服务和本地的双重备份,将 Dropbox 中的文件备份到另一磁盘。
#!/usr/bin/env bash

rsync -a ~/Dropbox/ /mnt/disk/repo/backup-dropbox
cd /mnt/disk/repo/backup-dropbox
tar czf dropbox-backup-$(date +"%F")-$(date +"%s").tar.gz --exclude='*.tar.gz' --exclude='.dropbox-cache/' --exclude='.dropbox' *

timeshift 在最近一次系统损坏中成为了罪魁祸首:新旧 GRUB 版本的冲突让我的系统不断进入 GRUB rescue 模式,只能重装,幸好通过 USB 启动盘将一些数据备份了出来。

pacman -S timeshift

timeshift

  1. Snapshot type: rsync (btrfs cannot use because of BTRFS snapts are saved on system partition)
  2. User home directories: root-include all files, user-include only hidden files

常用命令行工具

ohmyzsh

https://github.com/ohmyzsh/ohmyzsh

安装前提:

  1. Zshpacman -S zsh
  2. curl / wget installed
  3. git installed
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
## or
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

## plugins
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
git clone https://gist.github.com/475ee7768efc03727f21.git ~/.oh-my-zsh/custom/plugins/git-auto-status
mkdir ~/.oh-my-zsh/custom/plugins/pnpm
wget -O- https://raw.githubusercontent.com/ntnyq/omz-plugin-pnpm/main/pnpm.plugin.zsh ~/.oh-my-zsh/custom/plugins/pnpm

## my configuration
cd ~/dotfiles
stow zsh

z.lua

git clone https://github.com/skywind3000/z.lua.git ~/.z.lua
pacman -S lua

eza

A modern replacement for ls (List directory contents) https://the.exa.website

pacman -S eza

eza
eza --oneline # List files one per line
eza --all # List all files, including hidden files
eza --long --all # Long format list (permissions, ownership, size and modification date) of all files
eza --reverse --sort=size # List files with the largest at the top
eza --long --tree --level=3 # Display a tree of files, three levels deep
eza --long --sort=modified # List files sorted by modification date (oldest first)
eza --long --header --icons --git # List files with their headers, icons, and Git statuses
eza --git-ignore # Don't list files mentioned in `.gitignore`

bat

https://github.com/sharkdp/bat

cat 的替代

pacman -S bat bat-extras

tldr

pacman -S tldr

~/.zshrc 中加入以下内容:

export TLDR_CACHE_ENABLED=1
export TLDR_CACHE_MAX_AGE=720
export TLDR_PAGES_SOURCE_LOCATION="https://raw.githubusercontent.com/tldr-pages/tldr/master/pages"
export TLDR_DOWNLOAD_CACHE_LOCATION="https://tldr-pages.github.io/assets/tldr.zip"

netstat

查看网络接口的占用情况

pacman -S net-tools

hugo

https://gohugo.io

本博客站的生成程序

pacman -S hugo dart-sass

lf

https://github.com/gokcehan/lf

终端文件管理器

pacman -S lf

gh

GitHub 的 Cli 工具

pacman -S gh

其他常用命令行工具

pacman -S htop fastfetch cronie trash-cli

设置 cronie:

crontab -e

# @hourly /path/to/backup_script_file

Nextcloud

开始用它同步 daily 日记。

pacman -S nextcloud-client

Virtualbox

pacman -S virtualbox virtualbox-host-modules-arch virtualbox-ext-oracle
# 这一次安装没有下面的错误消息,但是当我在 Virtualbox 新建虚拟机时,却出现了错误

但是,执行过几个命令好了,我不知道命令的作用,参考 这个链接

modprobe vboxdrv
/sbin/rcvboxdrv setup

Error message:

    WARNING: The vboxdrv kernel module is not loaded. Either there is no module available for the current kernel (5.13.8-arch1-1) or it failed to load. Please recompile the kernel module and install it by

    sudo /sbin/vboxconfig

    You will not be able to start VMs until this problem is fixed.

运行命令解决:

modprobe vboxdrv

earlyoom

如果是为了避免系统卡死,可以安装并使用 earlyoom。

该软件默认将在空余内存、空余 swap 两者均低于 10% 时,结束 oom_score 值最高的进程,避免系统内存耗尽卡死。

# after install
systemctl enable --now earlyoom

Vagrant

pacman -S vagrant
mkdir arch-vagrant && cd $_
vim Vagrantfile
vagrant up

Vagrantfile :

Vagrant.configure("2") do |config|
    config.vm.box = "archlinux/archlinux"
end

运行 vagrant up 后的错误信息:

No usable default provider could be found for your system.

Vagrant relies on interactions with 3rd party systems, known as

"providers", to provide Vagrant with resources to run development

environments. Examples are VirtualBox, VMware, Hyper-V.

The easiest solution to this message is to install VirtualBox, which

is available for free on all major platforms.

If you believe you already have a provider available, make sure it

is properly installed and configured. You can see more details about

why a particular provider isn't working by forcing usage with

`vagrant up --provider=PROVIDER`, which should give you a more specific

error message for that particular provider.

运行了 sudo modprobe vboxdrv 命令现在没有错误了。

vagrant up

Output:

Vagrant is currently configured to create VirtualBox synced folders with
the `SharedFoldersEnableSymlinksCreate` option enabled. If the Vagrant
guest is not trusted, you may want to disable this option. For more
information on this option, please refer to the VirtualBox manual:

    https://www.virtualbox.org/manual/ch04.html#sharedfolders

This option can be disabled globally with an environment variable:

    VAGRANT_DISABLE_VBOXSYMLINKCREATE=1

or on a per folder basis within the Vagrantfile:

    config.vm.synced_folder '/host/path', '/guest/path', SharedFoldersEnableSymlinksCreate: false

NS_ERROR_INVALID_ARG

QEMU

pacman -S qemu

Output:

Please add your user to the brlapi group.
Optional dependencies for brltty
    at-spi2-core: X11/GNOME Apps accessibility [installed]
    atk: ATK bridge for X11/GNOME accessibility [installed]
    espeak-ng: espeak-ng driver
    java-runtime: Java support [installed]
    libxaw: X11 support [installed]
    libxt: X11 support [installed]
    libx11: for xbrlapi [installed]
    libxfixes: for xbrlapi [installed]
    libxtst: for xbrlapi [installed]
    ocaml: OCaml support
    python: Python support [installed]
    speech-dispatcher: speech-dispatcher driver [installed]
vde config files should be placed in /etc/vde, sample files are provided.
iptables and dhcpd sample files have been installed to '/usr/share/vde2'.
Merge those examples, if needed to the according config files.

VLC

音视频播放

pacman -S vlc

gThumb

https://wiki.gnome.org/action/show/Apps/Gthumb

gThumb is an image viewer and browser for the GNOME Desktop. It also includes an importer tool for transferring photos from cameras.

pacman -S gthumb

KDE

因为网络问题,无法直接从 KDE 的主题商店直接安装,所以需要手动安装。ref

Trello

yay -S silos silo-trello

开发环境配置

JavaScript(Node.js)

## pnpm 设置镜像
# pnpm config set registry https://registry.npmmirror.com

Go

Rust

https://wiki.archlinux.org/title/Rust

pacman -S rustup && rustup default stable

China mirror( https://RsProxy.cn maintained by the ByteDance team.)

设置 crates.io 镜像, 修改配置 ~/.cargo/config,已支持git协议和sparse协议,>=1.68 版本建议使用 sparse-index,速度更快

[source.crates-io]
replace-with = 'rsproxy-sparse'
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
[net]
git-fetch-with-cli = true

Scheme

https://www.scheme.org/

Scheme 是一种 Lisp 变体。

目前使用 Guile 编译。它是一种 Scheme 实现。因为被很多核心程序依赖,所以已经安装好了。

guile hello-world.scm
;;; note: source file /home/archie/exercism/scheme/hello-world/hello-world.scm
;;;       newer than compiled /home/archie/.cache/guile/ccache/2.2-LE-8-3.A/home/archie/exercism/scheme/hello-world/hello-world.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /home/archie/exercism/scheme/hello-world/hello-world.scm
;;; compiled /home/archie/.cache/guile/ccache/2.2-LE-8-3.A/home/archie/exercism/scheme/hello-world/hello-world.scm.go
Hello World!

guile hello-world.scm --no-auto-compile

如果关闭提示?在 ~/.zshrc 文件中添加如下别名:

alias guile="guile --no-auto-compile"

其他常用软件

pacman -S firefox-developer-edition keepassxc spectacle
## aur
yay -S google-chrome

try

https://github.com/binpash/try

## aur
yay -S try

# or
git clone https://github.com/binpash/try.git
cd try
sudo mv try /usr/local/bin

nscd 自启动

sudo systemctl enable nscd

nscd is a daemon that provides a cache for the most common name service requests. The default configuration file, /etc/nscd.conf, determines the behavior of the cache daemon.

redshift(KDE自带亮度调节)

需要纬度,经度

mkdir ~/.config/redshift
vim ~/.config/redshift/redshift.conf

~/.config/redshift/redshift.conf

    [redshift]
    location-provider=manual
    temp-day=5500
    temp-night=3700

    [manual]
    lat=33.165395
    lon=115.622324

参考:

  1. https://wiki.archlinux.org/title/redshift
  2. https://io-oi.me/tech/hello-arch-linux/#redshift

KDE Font Viewer

在 Wayland 环境下无法使用(未来在 KDE Plasma 6 修复)。

https://ask.fedoraproject.org/t/problem-with-kde-font-viewer/13932

This major bug occurs when running under Wayland. A workaround is to set QT_QPA_PLATFORM=xcb before starting kfontview so that it runs under X11/XWayland, see KDE bug 439470.

在命令行使用 KDE Font Viewer:

QT_QPA_PLATFORM=xcb kfontview

pulseaudio

问题:开机后播放音频没有声音

解决办法:

killall pulseaudio

refer https://unix.stackexchange.com/a/171925

软件安装列表

名字 说明
wl-clipboard Wayland clipboard utilities
spectacle KDE 开发的截图软件
net-tools 提供 netstat 命令
chromium 开源浏览器(基于 Blink 渲染引擎)
google-chrome 浏览器
firefox-developer-edition 具有开发者定制功能的 Firefox 浏览器
pulseaudio A featureful, general-purpose sound server
kmix 修复 Firefox 没有声音
profile-cleaner Simple script to vacuum and reindex sqlite databases used by browsers 用于对浏览器使用的 sqlite 数据库进行清理和重新索引的简单脚本
visual-studio-code-bin Visual Studio Code
proxychains-ng 终端内科学上网代理工具
vlc 强大的多媒体播放工具
telegram-desktop 客户端开源的加密聊天工具
gthumb 图片浏览工具,可简单编辑图片,可清除照片元数据
inkscape 强大的矢量图形编辑软件
yt-dlp YouTube 视频下载工具
glances terminal monitoring tool
keepassxc password manager
hugo static site generator
informant arch news reader and pacman hook
dnsutils provide dig command
dnsmasq 使用国外 DNS 造成国内网站访问慢的解决方法
tldr Collaborative cheatsheets for console commands
virtualbox Virtual Machine
qemu A generic and open source machine emulator and virtualizer
earlyoom Early OOM Daemon for Linux
gtk2/3/4 GObject-based multi-platform GUI toolkit
lsb-release LSB version query program
eza A modern replacement for ls (List directory contents)
sagemath Open Source Mathematics Software free alternative to Magma Maple Mathematica and Matlab Matlab dkms Dynamic Kernel Modules System
cmdpxl a totally practical command-line image editor 一个在命令行里画画的程序
octave(GUI) A high-level language, primarily intended for numerical computations.
asciiquarium An aquarium/sea animation in ASCII art
arch-wiki-man(aur) The Arch Wiki as linux man pages
konsole KDE terminal emulator
python-pipenv Sacred Marriage of Pipfile, Pip, & Virtualenv.
safeeyes(aur) Protect your eyes from eye strain using this simple and beautiful, yet extensible break reminder
bat A cat(1) clone with wings
htop Interactive process viewer
prettyping A ping wrapper making the output prettier, more colorful, more compact, and easier to read
dbeaver Free universal SQL Client for developers and database administrators (community edition)
sqlitebrowser SQLite Database browser is a light GUI editor for SQLite databases, built on top of Qt
adminer(aur) Adminer is available for MySQL, MariaDB, PostgreSQL, SQLite, MS SQL, Oracle, Elasticsearch, MongoDB and others via plugin
rnote A simple drawing application to create handwritten notes
imv a command line image viewer intended for use with tiling window managers
umlet Free UML Tool for Fast UML Diagrams
speedtest-cli Command line interface for testing internet bandwidth using speedtest.net
rslsync(aur) Resilio Sync (ex:BitTorrent Sync) - automatically sync files via secure, distributed technology
peek 录制 GIF 动图
obs-studio 录屏软件
pkgstats Submit a list of installed packages to the Arch Linux project
EtchDroid ios2usb on android
archmage(aur) converts CHM files to HTML, plain text and PDF
kernel-modules-hook Keeps your system fully functional after a kernel upgrade
wireshark-cli
pdm A modern Python package and dependency manager supporting the latest PEP standards
onlyoffice-bin(aur) Office
trash-cli replace rm
variety 自动换壁纸
ddgr DuckDuckGo in the Terminal
appimagelauncher(aur) Helper for running and integrating AppImages
欢迎通过「邮件」或者点击「这里」告诉我你的想法
Welcome to tell me your thoughts via "email" or click "here"