Arch Linux 软件安装和用法
隐藏 GRUB 加载
1 # vim /etc/default/grub
2 # grub-mkconfig -o /boot/grub/grub.cfg
修改 /etc/default/grub
:
1-GRUB_TIMEOUT=1
2+GRUB_TIMEOUT=0
Reflector 更新镜像
https://wiki.archlinux.org/title/reflector
开机自动执行
/etc/xdg/reflector/reflector.conf
:
1--save /etc/pacman.d/mirrorlist
2--country China
3--protocol https
4--latest 5
1systemctl enable reflector
2systemctl start reflector
3vim /usr/lib/systemd/system/reflector.service
在 [Service] -> ExecStart
值的开始添加 /usr/bin/proxychains
,目的是使用代理。之所以这样做是因为中国的网络对国外内容不友好,如果不设置代理,直接执行 systemctl start reflector
会出现如下错误:
1# error: failed to retrieve mirrorstatus data: URLError: <urlopen error [Errno 101] Network is unreachable>
通过 Pacman hook 自动化以上步骤
这样每次升级软件包时,都会自动更新软件镜像。
/etc/pacman.d/hooks/mirrorupgrade.hook
:
1[Trigger]
2Operation = Upgrade
3Type = Package
4Target = pacman-mirrorlist
5
6[Action]
7Description = Updating pacman-mirrorlist with reflector and removing pacnew...
8When = PostTransaction
9Depends = reflector
10Exec = /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
的日志输出:
1Jan 21 22:50:39 arch kernel: usb 1-1.4: new high-speed USB device number 10 using xhci_hcd
2Jan 21 22:50:39 arch kernel: usb 1-1.4: New USB device found, idVendor=19d2, idProduct=1225, bcdDevice= 1.01
3Jan 21 22:50:39 arch kernel: usb 1-1.4: New USB device strings: Mfr=2, Product=4, SerialNumber=5
4Jan 21 22:50:39 arch kernel: usb 1-1.4: Product: SZXF Mobile Boardband
5Jan 21 22:50:39 arch kernel: usb 1-1.4: Manufacturer: SZXF,Incorporated
6Jan 21 22:50:39 arch kernel: usb 1-1.4: SerialNumber: 1234567890ABCDEF
7Jan 21 22:50:39 arch kernel: usb-storage 1-1.4:1.0: USB Mass Storage device detected
8Jan 21 22:50:39 arch kernel: usb-storage 1-1.4:1.0: Quirks match for vid 19d2 pid 1225: 1
9Jan 21 22:50:39 arch kernel: scsi host3: usb-storage 1-1.4:1.0
10Jan 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"
11Jan 21 22:50:39 arch mtp-probe[10214]: bus: 1, device: 10 was not an MTP device
12Jan 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"
13Jan 21 22:50:39 arch mtp-probe[10226]: bus: 1, device: 10 was not an MTP device
14Jan 21 22:50:40 arch kernel: scsi 3:0:0:0: CD-ROM SZXF USB SCSI CD-ROM 2.31 PQ: 0 ANSI: 2
15Jan 21 22:50:40 arch kernel: sr 3:0:0:0: Power-on or device reset occurred
16Jan 21 22:50:40 arch kernel: sr 3:0:0:0: [sr0] scsi-1 drive
17Jan 21 22:50:40 arch kernel: sr 3:0:0:0: Attached scsi CD-ROM sr0
18Jan 21 22:50:43 arch kernel: usb 1-1.4: USB disconnect, device number 10
19Jan 21 22:50:43 arch kernel: usb 1-1.4: new high-speed USB device number 11 using xhci_hcd
20Jan 21 22:50:44 arch kernel: usb 1-1.4: New USB device found, idVendor=19d2, idProduct=1557, bcdDevice= 1.01
21Jan 21 22:50:44 arch kernel: usb 1-1.4: New USB device strings: Mfr=2, Product=4, SerialNumber=5
22Jan 21 22:50:44 arch kernel: usb 1-1.4: Product: SZXF Mobile Boardband
23Jan 21 22:50:44 arch kernel: usb 1-1.4: Manufacturer: SZXF,Incorporated
24Jan 21 22:50:44 arch kernel: usb 1-1.4: SerialNumber: 1234567890ABCDEF
25Jan 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
26Jan 21 22:50:44 arch kernel: usb-storage 1-1.4:1.2: USB Mass Storage device detected
27Jan 21 22:50:44 arch kernel: scsi host3: usb-storage 1-1.4:1.2
28Jan 21 22:50:44 arch NetworkManager[511]: <info> [1705848644.0628] manager: (eth0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/67)
29Jan 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"
30Jan 21 22:50:44 arch mtp-probe[10245]: bus: 1, device: 11 was not an MTP device
31Jan 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"
32Jan 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"
33Jan 21 22:50:44 arch kernel: cdc_ether 1-1.4:1.0 enp0s20f0u1u4: renamed from eth0
34Jan 21 22:50:44 arch NetworkManager[511]: <info> [1705848644.1406] device (eth0): interface index 59 renamed iface from 'eth0' to 'enp0s20f0u1u4'
35Jan 21 22:50:44 arch NetworkManager[511]: <info> [1705848644.1626] device (enp0s20f0u1u4): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
36Jan 21 22:50:44 arch NetworkManager[511]: <info> [1705848644.1669] device (enp0s20f0u1u4): carrier: link connected
37Jan 21 22:50:44 arch NetworkManager[511]: <info> [1705848644.1680] device (enp0s20f0u1u4): state change: unavailable -> disconnected (reason 'carrier-changed', sys-iface-state: 'managed')
38Jan 21 22:50:44 arch tailscaled[669]: monitor: RTM_DELROUTE: src=, dst=ff00::/8, gw=, outif=59, table=255
39Jan 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"
40Jan 21 22:50:44 arch mtp-probe[10264]: bus: 1, device: 11 was not an MTP device
41Jan 21 22:50:44 arch NetworkManager[511]: <info> [1705848644.1821] device (enp0s20f0u1u4): state change: disconnected -> unavailable (reason 'carrier-changed', sys-iface-state: 'managed')
42Jan 21 22:50:45 arch kernel: scsi 3:0:0:0: Direct-Access SZXF MMC Storage 2.31 PQ: 0 ANSI: 2
43Jan 21 22:50:45 arch kernel: sd 3:0:0:0: Power-on or device reset occurred
44Jan 21 22:50:45 arch kernel: sd 3:0:0:0: [sdc] Media removed, stopped polling
45Jan 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
1pacman -S clash
2clash # Generate config.yaml, Country.mmdb in ~/.config/clash
3## download yaml file from your service provider, rename it to config.yaml, put it under your clash folder
4
5# open clash at start https://github.com/Dreamacro/clash/wiki/clash-as-a-daemon
6vim /etc/systemd/system/clash.service
/etc/systemd/system/clash.service
:
1[Unit]
2Description=Clash daemon, A rule-based proxy in Go.
3After=network.target
4
5[Service]
6Type=simple
7Restart=always
8ExecStart=/usr/local/bin/clash -d "/home/archie/.config/clash"
9
10[Install]
11WantedBy=multi-user.target
proxychains-ng
https://github.com/rofl0r/proxychains-ng
1pacman -S proxychains-ng
输入法配置——Fcitx5
1# Install fcitx5-im group(fcitx5, fcitx5-configtool, fcitx5-gtk, fcitx5-qt),并安装词库、主题:
2pacman -S fcitx5-im fcitx5-chinese-addons fcitx5-pinyin-zhwiki fcitx5-material-color
添加对 gtk,qt 类(指通过 gtk、qt 编程得到的软件)软件的支持:
1# /etc/profile
2export XMODIFIERS="@im=fcitx"
3export GTK_IM_MODULE="fcitx"
4export QT_IM_MODULE="fcitx"
配置开机启动;主题:material-color-black
但是,当我安装好时,不能在 Konsole 这个命令行模拟器输入中文,尝试很多办法 /etc/profile
(如上所示),在 ~/.profile
等文件中加入以上相同的内容,但是(可能因为没有关机再开机)依然不可行。终于在 Wayland environment - Environment variables 这里发现,需要设置 Wayland 环境变量。
fcitx5 使用发现
Enter
回车键异常:中文模式下,按 ; 后再按 Enter 无法输入英文分号。可能不是问题,刚从 fcitx4 升级到 fcitx5。
经过这些时间的磨合,发现:这的确是一个 bug。过段时间,我改变了想法,想到这可能是因为不同软件之间 Enter
键的作用不同造成的。
字体
使用的是以前用过的 GNOME 桌面环境的默认字体设置:
- Cantarell Regular
- Source Code Pro Regular
- Cantarell Bold
- VF Cantonese https://visual-fonts.com/
所有安装的字体:
1pacman -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/
1fc-cache -fv # 更新字体缓存
用户配置字体配置文件位于 ~/.config/fontconfig/.fonts.conf
https://wiki.archlinux.org/title/Font_configuration/Examples#Chinese_in_Noto_Fonts
1<?xml version='1.0'?>
2<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
3<fontconfig>
4
5 <match target="font">
6 <edit mode="assign" name="rgba">
7 <const>rgb</const>
8 </edit>
9 </match>
10
11 <match target="font">
12 <edit mode="assign" name="hintstyle">
13 <const>hintslight</const>
14 </edit>
15 </match>
16
17 <match target="font">
18 <edit mode="assign" name="antialias">
19 <bool>true</bool>
20 </edit>
21 </match>
22
23 <!-- Map fonts that are commonly used by web pages to our preferred fonts -->
24 <match target="pattern">
25 <test qual="any" name="family"><string>Cantarell</string></test>
26 <edit name="family" mode="assign" binding="same"><string>sans-serif</string></edit>
27 </match>
28
29 <match target="pattern">
30 <test qual="any" name="family"><string>BlexMono Nerd Font Mono</string></test>
31 <edit name="family" mode="assign" binding="same"><string>monospace</string></edit>
32 </match>
33
34 <!-- Default font for the zh_CN locale (no fc-match pattern) -->
35 <match>
36 <test compare="contains" name="lang">
37 <string>zh_CN</string>
38 </test>
39 <edit mode="prepend" name="family">
40 <string>Noto Sans CJK SC</string>
41 </edit>
42 </match>
43
44 <!-- Default sans-serif font -->
45 <match target="pattern">
46 <test qual="any" name="family">
47 <string>sans-serif</string></test>
48 <edit name="family" mode="prepend" binding="same">
49 <string>Noto Sans</string>
50 </edit>
51 </match>
52
53 <!-- Default serif fonts -->
54 <match target="pattern">
55 <test qual="any" name="family">
56 <string>serif</string>
57 </test>
58 <edit name="family" mode="prepend" binding="same">
59 <string>Noto Serif</string>
60 </edit>
61 </match>
62
63 <!-- Default monospace fonts -->
64 <match target="pattern">
65 <test qual="any" name="family">
66 <string>monospace</string>
67 </test>
68 <edit name="family" mode="prepend" binding="same">
69 <string>BlexMono Nerd Font Mono</string>
70 </edit>
71 </match>
72
73 <!-- Fallback fonts preference order -->
74 <alias>
75 <family>sans-serif</family>
76 <prefer>
77 <family>Noto Sans</family>
78 <family>Noto Sans CJK SC</family>
79 <family>Noto Sans CJK TC</family>
80 <family>Noto Sans CJK JP</family>
81 <family>Noto Sans CJK KR</family>
82 <family>Noto Color Emoji</family>
83 <family>Noto Emoji</family>
84 </prefer>
85 </alias>
86 <alias>
87 <family>serif</family>
88 <prefer>
89 <family>Noto Serif</family>
90 <family>Noto Serif CJK SC</family>
91 <family>Noto Serif CJK TC</family>
92 <family>Noto Serif CJK JP</family>
93 <family>Noto Serif CJK KR</family>
94 <family>Noto Color Emoji</family>
95 <family>Noto Emoji</family>
96 </prefer>
97 </alias>
98 <alias>
99 <family>monospace</family>
100 <prefer>
101 <family>BlexMono Nerd Font Mono</family>
102 <family>Noto Color Emoji</family>
103 <family>Noto Emoji</family>
104 </prefer>
105 </alias>
106
107 <selectfont>
108 <rejectfont>
109 <pattern>
110 <patelt name="family" >
111 <!-- This font is causing problem with GitHub -->
112 <string>Nimbus Sans</string>
113 </patelt>
114 </pattern>
115 </rejectfont>
116 </selectfont>
117
118</fontconfig>
参考:
- https://wiki.archlinux.org/title/Microsoft_fonts
- https://wiki.archlinux.org/title/Fonts
- https://wiki.archlinux.org/title/Font_configuration
- fontconfig user docs
- https://szclsya.me/zh-cn/posts/fonts/linux-config-guide/
- Get emojis working on arch linux with noto-fonts-emoji(文章里的配置步骤有点错误)
- Noto Emoji Color fontconfig for Konsole
- Font configuration for CJK support in Ubuntu
蓝牙
1systemctl enable --now bluetooth
无法添加蓝牙耳机
1# 来自 bluetooth.service 的 systemd log
2# ConfigurationDirectory 'bluetooth' already exists but the mode is different. (File system: 755 ConfigurationDirectoryMode: 555)
3# src/device.c:device_set_wake_support() Unable to set wake_support without RPA resolution
4# src/adapter.c:set_device_privacy_complete() Set device flags return status: Invalid Parameters
经过搜索发现一些人遇到过类似问题。
1# dmesg | grep Bluetooth 输出
2[ 2.357525] usb 1-8: Product: Bluetooth Radio
3[ 3.057353] Bluetooth: Core ver 2.22
4[ 3.057403] Bluetooth: HCI device and connection manager initialized
5[ 3.057410] Bluetooth: HCI socket layer initialized
6[ 3.057413] Bluetooth: L2CAP socket layer initialized
7[ 3.057420] Bluetooth: SCO socket layer initialized
8[ 3.716563] Bluetooth: hci0: RTL: examining hci_ver=08 hci_rev=000c lmp_ver=08 lmp_subver=8821
9[ 3.717200] Bluetooth: hci0: RTL: rom_version status=0 version=1
10[ 3.717204] Bluetooth: hci0: RTL: loading rtl_bt/rtl8821c_fw.bin
11[ 3.722382] Bluetooth: hci0: RTL: loading rtl_bt/rtl8821c_config.bin
12[ 3.723300] Bluetooth: hci0: RTL: cfg_sz 10, total sz 31990
13[ 4.174265] Bluetooth: hci0: RTL: fw version 0x829a7644
14[ 5.868007] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
15[ 5.868012] Bluetooth: BNEP filters: protocol multicast
16[ 5.868017] Bluetooth: BNEP socket layer initialized
17[ 6.136304] Bluetooth: hci0: Bad flag given (0x2) vs supported (0x1)
18[ 17.200632] Bluetooth: RFCOMM TTY layer initialized
19[ 17.200645] Bluetooth: RFCOMM socket layer initialized
20[ 17.200654] Bluetooth: RFCOMM ver 1.11
21[ 32.473238] Bluetooth: hci0: unexpected cc 0x0c7c length: 1 < 3
22[ 962.089278] Bluetooth: hci0: Bad flag given (0x2) vs supported (0x1)
23[ 971.016364] Bluetooth: hci0: unexpected cc 0x0c7c length: 1 < 3
之后按照这里的说法,执行以下命令安装 bluedevil, bluez-utils, pulseaudio-bluetooth。重启之后问题解决了。
1yay -Syyuu bluedevil bluez-utils pulseaudio-bluetooth
Git
1pacman -S openssh
2wget -O ~/.gitconfig https://github.com/tianheg/dotfiles/raw/main/gitconfig
3# 不要忘记 commit.gpgsign true
4
5## SSH
6chmod 400 ~/.ssh/id_ed25519
7# 解决 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
1## way 1
2export GCO_VERSION=0.7.0
3wget -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 .
4# three files: git-credential-oauth* LICENSE.txt README.md
5sudo mv git-credential-oauth /usr/local/bin
6
7## way 2
8yay -S git-credential-oauth
9
10### next step
11echo url=https://github.com | git credential fill # complete the authentication process
GPG
修改 ~/.gnupg/
权限:
1# https://superuser.com/a/954536 ; https://superuser.com/a/954639
2# Set ownership to your own user and primary group
3chown -R "$USER:$(id -gn)" ~/.gnupg
4# Set permissions to read, write, execute for only yourself, no others
5chmod 700 ~/.gnupg
6# Set permissions to read, write for only yourself, no others
7chmod 600 ~/.gnupg/*
这几条命令解决 gpg: WARNING: unsafe permissions on homedir '/home/user/.gnupg'
。
把 ~/.gnupg
文件夹保存在安全的地方 ,然后导入 GitHub(user + web-flow)公匙:
1wget -O tianheg-pubkeys.txt https://github.com/tianheg.gpg
2wget -O github-web-flow.txt https://github.com/web-flow.gpg
3gpg --import tianheg-pubkeys.txt
4gpg --import github-web-flow.txt
安装 seahorse 以防止每次 git commit 都要输入密码(不必麻烦,通过设置 ~/.gnupg/gpg-agent.conf
可以延长密码时效)。
1default-cache-ttl 28800
2max-cache-ttl 28800
键盘映射
https://tonsky.me/blog/cursor-keys/
把上下左右键映射到字母键:
1vim ~/ijkl
2xmodmap ~/ijkl
ijkl
:
1keycode 66 = Mode_switch
2keysym j = j J Left
3keysym l = l L Right
4keysym i = i I Up
5keysym k = k K Down
但是,在做完以上步骤后,我的 Left Ctrl -> CapsLock 的映射失效了,所以我需要修改文件内容。
让一切恢复之前的状态的命令: setxkbmap -layout us
。
在 KDE 桌面环境下,有方便的系统设置菜单,可以设置键盘映射。
声音
https://wiki.archlinux.org/title/Sound_system
用到的软件:ALSA(驱动接口)、PipeWire & PulseAudio(声音服务器)
错误日志:
1vlcpulse audio output error: stream connection failure: Bad state
2main audio output error: module not functional
3main decoder error: failed to create audio output
4
5pulse audio output error: overflow, flushing
6
7pulseaudio[6402]: Failed to create sink input: sink is suspended.
我又试了一次下面的命令,竟然可以了!
1pulseaudio -k
2# Kill a running daemon
目前问题未解决,声音时有时无。
在 KDE 的音量设置界面,先设置成其他声卡输出,然后再设置成 Analog Stereo Duplex。可能有效果。
~/.config/pulse/default.pa
:
1.include /etc/pulse/default.pa
2
3set-default-source alsa_output.pci-0000_00_1f.3.analog-stereo.monitor
4set-card-profile alsa_card.pci-0000_00_1f.3 output:analog-stereo+input:analog-stereo
5set-default-sink alsa_output.pci-0000_00_1f.3.analog-stereo
根据 ArchWiki 进行上述配置。
pacman
添加 archlinuxcn
添加库 /etc/pacman.conf
:
1[archlinuxcn]
2Server = https://repo.archlinuxcn.org/$arch
导入 PGP 公匙(为了验证 archlinuxcn 库):
1pacman-key --lsign-key "farseerfc@archlinux.org" # for error: ...is marginal trust
2pacman -Syy && pacman -S archlinuxcn-keyring
pacman 命令
1## 常用
2pacman -Qe # List all explicitly installed packages
3pacman -Qet # list all packages explicitly installed and not required as dependencies
4pacman -Qent # List all explicitly installed native packages (i.e. present in the sync database) that are not direct or optional dependencies
5pacman -Qn # List all native packages (installed from the sync database(s))
6pacman -Qm # List all foreign packages (typically manually downloaded and installed or packages removed from the repositories)
7
8sudo pacman -Qtdq | sudo pacman -Rns - # recursively removing orphans and their configuration files
9
10sudo pacman -Qii | awk '/^MODIFIED/ {print $2}' # print modified files under /etc
11
12pacman -Qs regex # List packages by regex
13
14pacman -Qg group_name # List installed packages under this group
15pacman -Sg group # List all packages in the package group named `group`, etc, base-devel, gnome
16pacman -Slq | rg <package> # search package_name
17pacman -Qq | grep -Ee '-(bzr|cvs|darcs|git|hg|svn)$' # list all development/unstable packages
18pacman -Syu # Update package list and upgrade all packages afterwards
19pacman -Syu git # Update package list, upgrade all packages, and then install git if it wasn’t already installed
20
21pacman -S package_name1 package_name2 # Installing specific packages
22pacman -S $(pacman -Ssq package_regex) # Install a list of packages with regex
23pacman -S extra/package_name # Install specific repositories' package
24pacman -S plasma-{desktop,mediacenter,nm}
25pacman -S plasma-{workspace{,-wallpapers},pa}
26
27pacman -S gnome # Install through group of packages
28# Enter a selection (default=all): 1-10 15 # which will select packages 1 through 10 and 15 for installation
29# Enter a selection (default=all): ^5-8 ^2 # which will select all packages except 5 through 8 and 2 for installation
30
31pacman -R package_name # remove a single package, leaving all of its dependencies installed
32pacman -Rs package_name # remove a single package and its dependencies which are not required by any other installed package
33
34pacman -Qtd # check for packages that were installed as a dependency but now, no other packages depend on them
35
36pacman -Ss string1 string2 ... # search for packages in the database
37pacman -Qs string1 string2 ... # search for already installed packages
38pacman -F string1 string2 ... # search for package file names in remote packages
39pacman -Fy string1 string2 ... # first flush local cache, then search for package file names in remote packages
40
41pacman -Si package_name # display extensive information about a given package
42pacman -Qi package_name # display extensive information about locally installed packages
43pacman -Qii package_name # also display the list of backup files and their modification states
44
45pacman -Ql package_name # retrieve a list of the files installed by a package
46pacman -Fl package_name # retrieve a list of the files installed by a remote package
47
48# 批量删除 Pacman 包
49sudo pacman -Rs $(pacman -Qq | grep some_words)
50# https://bbs.archlinux.org/viewtopic.php?pid=1533162#p1533162
51
52## Rarely use
53pacman -Qk package_name # verify the presence of the files installed by a package, Passing the k flag twice will perform a more thorough check
54pacman -Qo /path/to/file_name # query the database to know which package a file in the file system belongs to
55pacman -Qo command_name # 找到所属包
56pacman -F /path/to/file_name # query the database to know which remote package a file belongs to
应该避免执行的 pacman 指令
1pacman -Sy # never run!!!
2pacman -Rdd package # never run!!!
在 Arch 中安装包时应避免没有升级系统就刷新包列表。这样做是为了避免出现依赖问题,比如,如果一个包被从官方仓库中移除,在进行包同步时就会报错。在实践中,不要执行 pacman -Sy package_name
,应该执行 pacman -Syu package_name
。
informant
一个 Arch Linux 新闻阅读器和 pacman hook。可以帮你在更新包时检查是否还有没有阅读的 Arch Linux 新闻。
执行 pacman 命令过程中,遇到的信息/警告/错误
循环依赖:
1warning: dependency cycle detected
执行 sudo pacman -Syu
时:
1WARNING: Possibly missing firmware for module
这是一种警告。
参考:
- https://wiki.archlinux.org/title/Mkinitcpio#Possibly_missing_firmware_for_module_XXXX
- https://arcolinuxforum.com/viewtopic.php?t=1174
gpg: key 786C63F330D7CB92: no user ID for key signature packet of class 10
1gpg: key 786C63F330D7CB92: no user ID for key signature packet of class 10
2gpg: key 1EB2638FF56C0C53: no user ID for key signature packet of class 10
3gpg: next trustdb check due at 2021-10-09
4 -> Disabled 3 keys.
5
6## try 1
7# pacman-key --refresh-keys
8# pacman -S archlinux-keyring archlinuxcn-keyring
9## try 2
10# rm -R /etc/pacman.d/gnupg/ # No such file or directory
11# rm -rf /etc/pacman.d/gnupg/
12# rm -R /root/.gnupg/
13# rm -R /var/cache/pacman/pkg/
14# gpg --refresh-keys
15# pacman-key --init
16# pacman-key --populate archlinux # still display `gpg: key xxx: no user ID for key signature packet of class 10`
17# pacman-key --refresh-keys
18# 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.
解决方法:
1rm -rf /etc/pacman.d/gnupg
2pacman-key --init
3pacman-key --populate archlinux
4pacman-key --populate archlinuxcn
参考:
- Installing and upgrading packages
- Is it possible that there is a major kernel update in the repository, and that some of the driver packages have not been updated?
- https://wiki.archlinux.org/title/Pacman/Tips_and_tricks
- https://wiki.archlinux.org/title/Pacman
- https://wiki.archlinux.org/title/System_maintenance#Avoid_certain_pacman_commands
- https://wiki.archlinux.org/title/Pacman/Rosetta
- https://wiki.archlinux.org/title/Mkinitcpio
yay
Yet Another Yogurt: 又一个从 Arch User Repository 下载包的工具。
安装 yay
官方仓库:https://github.com/Jguer/yay
1# pacman -S --needed git base-devel
2git clone https://aur.archlinux.org/yay.git
3cd yay
4makepkg -si
如果想通过 pacman 官方仓库里的 yay 包安装,在版本升级时可能会有滞后。可以在通过 pacman 安装 yay 后,运行命令:
1yay -S yay
保证得到 yay 的最新版本。
使用 yay
1# Interactively search and install packages from the repos and AUR:
2yay package_name|search_term
3# Synchronize and update all packages from the repos and AUR:
4yay
5# Synchronize and update only AUR packages:
6yay -Sua
7# Install a new package from the repos and AUR:
8yay -S package_name
9# Remove an installed package and both its dependencies and configuration files:
10yay -Rns package_name
11# Search the package database for a keyword from the repos and AUR:
12yay -Ss keyword
13# Remove orphaned packages (installed as dependencies but not required by any package):
14yay -Yc
15# Show statistics for installed packages and system health:
16yay -Ps
代理 yay
https://github.com/Jguer/yay/issues/951#issuecomment-1080206297
sudo vim /etc/proxychains.conf
- 注释
proxy_dns
yay 问题
- 安装时总是出现
WARNING: Using existing $srcdir/ tree
,这个可以忽视,只是说明安装过程。 - timeout 问题 https://github.com/Jguer/yay/issues/1278#issuecomment-635833427
Missing AUR Packages
参考:
备份
- 通过
rsync
和crontab
定时将/etc
,~/.config
等配置文件备份到 Git 仓库 dotfiles 中。 - 云服务和本地的双重备份,将 Dropbox 中的文件备份到另一磁盘。
1#!/usr/bin/env bash
2
3rsync -a ~/Dropbox/ /mnt/disk/repo/backup-dropbox
4cd /mnt/disk/repo/backup-dropbox
5tar czf dropbox-backup-$(date +"%F")-$(date +"%s").tar.gz --exclude='*.tar.gz' --exclude='.dropbox-cache/' --exclude='.dropbox' *
timeshift 在最近一次系统损坏中成为了罪魁祸首:新旧 GRUB 版本的冲突让我的系统不断进入 GRUB rescue 模式,只能重装,幸好通过 USB 启动盘将一些数据备份了出来。
- https://blog.lilydjwg.me/2013/12/29/rsync-btrfs-dm-crypt-full-backup.42219.html
- https://github.com/teejee2008/timeshift
1pacman -S timeshift
timeshift
- Snapshot type: rsync (btrfs cannot use because of BTRFS snapts are saved on system partition)
- User home directories: root-include all files, user-include only hidden files
常用命令行工具
ohmyzsh
https://github.com/ohmyzsh/ohmyzsh
安装前提:
- Zsh:
pacman -S zsh
curl
/wget
installedgit
installed
1sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
2## or
3sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
4
5## plugins
6git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
7git clone https://github.com/zsh-users/zsh-syntax-highlighting ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
8git clone https://gist.github.com/475ee7768efc03727f21.git ~/.oh-my-zsh/custom/plugins/git-auto-status
9mkdir ~/.oh-my-zsh/custom/plugins/pnpm
10wget -O- https://raw.githubusercontent.com/ntnyq/omz-plugin-pnpm/main/pnpm.plugin.zsh ~/.oh-my-zsh/custom/plugins/pnpm
11
12## my configuration
13cd ~/dotfiles
14stow zsh
z.lua
1git clone https://github.com/skywind3000/z.lua.git ~/.z.lua
2pacman -S lua
eza
A modern replacement for ls
(List directory contents) https://the.exa.website
1pacman -S eza
2
3eza
4eza --oneline # List files one per line
5eza --all # List all files, including hidden files
6eza --long --all # Long format list (permissions, ownership, size and modification date) of all files
7eza --reverse --sort=size # List files with the largest at the top
8eza --long --tree --level=3 # Display a tree of files, three levels deep
9eza --long --sort=modified # List files sorted by modification date (oldest first)
10eza --long --header --icons --git # List files with their headers, icons, and Git statuses
11eza --git-ignore # Don't list files mentioned in `.gitignore`
bat
tldr
1pacman -S tldr
在 ~/.zshrc
中加入以下内容:
1export TLDR_CACHE_ENABLED=1
2export TLDR_CACHE_MAX_AGE=720
3export TLDR_PAGES_SOURCE_LOCATION="https://raw.githubusercontent.com/tldr-pages/tldr/master/pages"
4export TLDR_DOWNLOAD_CACHE_LOCATION="https://tldr-pages.github.io/assets/tldr.zip"
netstat
查看网络接口的占用情况
1pacman -S net-tools
hugo
lf
gh
GitHub 的 Cli 工具
1pacman -S gh
其他常用命令行工具
1pacman -S htop fastfetch cronie trash-cli
设置 cronie:
1crontab -e
2
3# @hourly /path/to/backup_script_file
dotfiles
Nextcloud
开始用它同步 daily 日记。
1pacman -S nextcloud-client
Virtualbox
1pacman -S virtualbox virtualbox-host-modules-arch virtualbox-ext-oracle
2# 这一次安装没有下面的错误消息,但是当我在 Virtualbox 新建虚拟机时,却出现了错误
但是,执行过几个命令好了,我不知道命令的作用,参考 这个链接:
1modprobe vboxdrv
2/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.
运行命令解决:
1modprobe vboxdrv
earlyoom
如果是为了避免系统卡死,可以安装并使用 earlyoom。
该软件默认将在空余内存、空余 swap 两者均低于 10% 时,结束 oom_score 值最高的进程,避免系统内存耗尽卡死。
1# after install
2systemctl enable --now earlyoom
Vagrant
1pacman -S vagrant
2mkdir arch-vagrant && cd $_
3vim Vagrantfile
4vagrant up
Vagrantfile
:
1Vagrant.configure("2") do |config|
2 config.vm.box = "archlinux/archlinux"
3end
运行 vagrant up
后的错误信息:
1No usable default provider could be found for your system.
2
3Vagrant relies on interactions with 3rd party systems, known as
4
5"providers", to provide Vagrant with resources to run development
6
7environments. Examples are VirtualBox, VMware, Hyper-V.
8
9The easiest solution to this message is to install VirtualBox, which
10
11is available for free on all major platforms.
12
13If you believe you already have a provider available, make sure it
14
15is properly installed and configured. You can see more details about
16
17why a particular provider isn't working by forcing usage with
18
19`vagrant up --provider=PROVIDER`, which should give you a more specific
20
21error message for that particular provider.
运行了 sudo modprobe vboxdrv
命令现在没有错误了。
1vagrant up
Output:
1Vagrant is currently configured to create VirtualBox synced folders with
2the `SharedFoldersEnableSymlinksCreate` option enabled. If the Vagrant
3guest is not trusted, you may want to disable this option. For more
4information on this option, please refer to the VirtualBox manual:
5
6 https://www.virtualbox.org/manual/ch04.html#sharedfolders
7
8This option can be disabled globally with an environment variable:
9
10 VAGRANT_DISABLE_VBOXSYMLINKCREATE=1
11
12or on a per folder basis within the Vagrantfile:
13
14 config.vm.synced_folder '/host/path', '/guest/path', SharedFoldersEnableSymlinksCreate: false
15
16NS_ERROR_INVALID_ARG
QEMU
1pacman -S qemu
Output:
1Please add your user to the brlapi group.
2Optional dependencies for brltty
3 at-spi2-core: X11/GNOME Apps accessibility [installed]
4 atk: ATK bridge for X11/GNOME accessibility [installed]
5 espeak-ng: espeak-ng driver
6 java-runtime: Java support [installed]
7 libxaw: X11 support [installed]
8 libxt: X11 support [installed]
9 libx11: for xbrlapi [installed]
10 libxfixes: for xbrlapi [installed]
11 libxtst: for xbrlapi [installed]
12 ocaml: OCaml support
13 python: Python support [installed]
14 speech-dispatcher: speech-dispatcher driver [installed]
15vde config files should be placed in /etc/vde, sample files are provided.
16iptables and dhcpd sample files have been installed to '/usr/share/vde2'.
17Merge those examples, if needed to the according config files.
VLC
音视频播放
1pacman -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.
1pacman -S gthumb
KDE
因为网络问题,无法直接从 KDE 的主题商店直接安装,所以需要手动安装。ref
Trello
1yay -S silos silo-trello
开发环境配置
JavaScript(Node.js)
1## pnpm 设置镜像
2# pnpm config set registry https://registry.npmmirror.com
Go
Rust
https://wiki.archlinux.org/title/Rust
1pacman -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,速度更快
1[source.crates-io]
2replace-with = 'rsproxy-sparse'
3[source.rsproxy]
4registry = "https://rsproxy.cn/crates.io-index"
5[source.rsproxy-sparse]
6registry = "sparse+https://rsproxy.cn/index/"
7[registries.rsproxy]
8index = "https://rsproxy.cn/crates.io-index"
9[net]
10git-fetch-with-cli = true
Scheme
Scheme 是一种 Lisp 变体。
目前使用 Guile 编译。它是一种 Scheme 实现。因为被很多核心程序依赖,所以已经安装好了。
1guile hello-world.scm
2;;; note: source file /home/archie/exercism/scheme/hello-world/hello-world.scm
3;;; newer than compiled /home/archie/.cache/guile/ccache/2.2-LE-8-3.A/home/archie/exercism/scheme/hello-world/hello-world.scm.go
4;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
5;;; or pass the --no-auto-compile argument to disable.
6;;; compiling /home/archie/exercism/scheme/hello-world/hello-world.scm
7;;; compiled /home/archie/.cache/guile/ccache/2.2-LE-8-3.A/home/archie/exercism/scheme/hello-world/hello-world.scm.go
8Hello World!
9
10guile hello-world.scm --no-auto-compile
如果关闭提示?在 ~/.zshrc
文件中添加如下别名:
1alias guile="guile --no-auto-compile"
其他常用软件
1pacman -S firefox-developer-edition keepassxc spectacle
2## aur
3yay -S google-chrome
try
https://github.com/binpash/try
1## aur
2yay -S try
3
4# or
5git clone https://github.com/binpash/try.git
6cd try
7sudo mv try /usr/local/bin
nscd
自启动
1sudo 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自带亮度调节)
需要纬度,经度
1mkdir ~/.config/redshift
2vim ~/.config/redshift/redshift.conf
~/.config/redshift/redshift.conf
:
1 [redshift]
2 location-provider=manual
3 temp-day=5500
4 temp-night=3700
5
6 [manual]
7 lat=33.165395
8 lon=115.622324
参考:
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:
1QT_QPA_PLATFORM=xcb kfontview
pulseaudio
软件安装列表
名字 | 说明 |
---|---|
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 |