archlinux 安装命令自用一览

  • ~5.96K 字
  1. 1. 安装准备
  2. 2. 第一阶段
  3. 3. 第二阶段
  4. 4. 第三阶段
  5. 5. 第四阶段
  6. 6. 第五阶段
  7. 7. 第六阶段
  8. 8. 常用急救包
    1. 8.1. journalctl cheat sheet
    2. 8.2. chroot

因为经常需要装系统,故将我的 archlinux 安装过程中的命令列在此。
新手请勿使用。

参考教程:archlinux 简明安装

该网站建议保存在本地。

安装准备

ventoy

如果原有 windows 是专业版,记得先记录 bitlocker 恢复密钥。关闭 bitlocker 在 meta 键后搜索 bitlocker 即可。

家庭版没有 bitlocker。

然后都要在 bios 里关闭安全启动(如果没有关闭 bitlocker,此时会要求输入恢复密钥)

wifi 连接使用手机热点(确保是英文),只建议使用热点,不使用校园网或者路由器

第一阶段

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
systemctl stop reflector.service

iwctl
device list
station wlan0 scan
station wlan0 get-networks
station wlan0 connect wifi-name
exit

ping -c 3 baidu.com
timedatectl set-ntp true

# use ssh connect; for example
passwd # set root password
systemctl start sshd
ip a
ssh root@192.168.1.100

vim /etc/pacman.d/mirrorlist

Server = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
Server = https://repo.huaweicloud.com/archlinux/$repo/os/$arch
Server = https://mirror.lzu.edu.cn/archlinux/$repo/os/$arch

lsblk -f

cfdisk /dev/nvme0n1
4G EFI
16G swap
300G root
left home

# remeber to `write`

mkfs.fat -F 32 /dev/nvme0n1p1
mkswap /dev/nvme0n1p2
mkfs.ext4 /dev/nvme0n1p3
mkfs.ext4 /dev/nvme0n1p4

swapon /dev/nvme0n1p2
mount /dev/nvme0n1p3 /mnt/
mount /dev/nvme0n1p4 /mnt/home --mkdir
mount /dev/nvme0n1p1 /mnt/boot --mkdir

df -h

# output error is ok
pacstrap /mnt base base-devel linux linux-firmware
pacstrap /mnt networkmanager vim sudo zsh zsh-completions

genfstab -U /mnt > /mnt/etc/fstab

arch-chroot /mnt

vim /etc/hostname

myarch

vim /etc/hosts
127.0.1.1 myarch.localdomain myarch

ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

hwclock --systohc

vim /etc/locale.gen
# en_US.UTF-8 UTF-8
# zh_CN.UTF-8 UTF-8

locale-gen

echo 'LANG=en_US.UTF-8' > /etc/locale.conf

passwd root

pacman -S intel-ucode
pacman -S grub efibootmgr os-prober

grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=ARCH

vim /etc/default/grub

# delete quiet
# modify 3 to 5
# add nowatchdog
GRUB_DISABLE_OS_PROBER=false

grub-mkconfig -o /boot/grub/grub.cfg

exit
umount -R /mnt
reboot

第二阶段

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
systemctl enable --now NetworkManager
ping -c 3 baidu.com

nmcli dev wifi list
nmcli dev wifi connect "wifi name" password "wifi password"

# here is another useful connect wifi way
ip a
wpa_passphrase "MyWiFi" "mypassword" > /etc/wpa_supplicant/wpa_supplicant.conf
wpa_supplicant -B -i <无线设备名> -c /etc/wpa_supplicant/wpa_supplicant.conf

pacman -S fastfetch
fastfetch

# if iso is not latest
pacman -Syu

vim ~/.bash_profile

export EDITOR='vim'
useradd -m -G wheel -s /bin/zsh myusername # /etc/passwd
# chsh -s /usr/bin/zsh myusername
passwd myusername

EDITOR=vim visudo
# delete `#` in `#%wheel ALL=(ALL:ALL) ALL`

vim /etc/pacman.conf
# delete multilib comment

# add these:
[archlinuxcn]
Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch # 中国科学技术大学开源镜像站
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch # 清华大学开源软件镜像站
Server = https://mirrors.hit.edu.cn/archlinuxcn/$arch # 哈尔滨工业大学开源镜像站
Server = https://repo.huaweicloud.com/archlinuxcn/$arch # 华为开源镜像站

pacman -Syyu

pacman -S plasma-meta konsole dolphin
pacman -S plasma-workspace xdg-desktop-portal

systemctl enable sddm
reboot

第三阶段

现在默认是 wayland

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
ping -c 3 baidu.com

sudo pacman -S sof-firmware alsa-firmware alsa-ucm-conf # 声音固件
sudo pacman -S ntfs-3g # 使系统可以识别 NTFS 格式的硬盘
sudo pacman -S adobe-source-han-serif-cn-fonts wqy-zenhei # 安装几个开源中文字体。一般装上文泉驿就能解决大多 wine 应用中文方块的问题
sudo pacman -S noto-fonts noto-fonts-cjk noto-fonts-emoji noto-fonts-extra # 安装谷歌开源字体及表情
sudo pacman -S firefox chromium # 安装常用的火狐、chromium 浏览器
sudo pacman -S ark # 压缩软件。在 dolphin 中可用右键解压压缩包
sudo pacman -S packagekit-qt6 packagekit appstream-qt appstream # 确保 Discover(软件中心)可用,需重启
sudo pacman -S gwenview # 图片查看器
sudo pacman -S archlinux-keyring
sudo pacman -S paru

sudo systemctl enable --now bluetooth

# add key[usually no need]
sudo pacman-key --lsign-key "farseerfc@archlinux.org"
sudo pacman -S archlinuxcn-keyring

vim ~/.bashrc

export EDITOR='vim'

sudo pacman -S fcitx5-im fcitx5-chinese-addons fcitx5-anthy fcitx5-pinyin-moegirl fcitx5-material-color

mkdir -p ~/.config/environment.d
vim ~/.config/environment.d/im.conf

XMODIFIERS=@im=fcitx

如果使用 Wayland,在「系统设置 - 输入设备 - 虚拟键盘」中选中 Fcitx 5

打开 System Settings > Language and Regional Settings > 在 Language 中点击 Add languages… > 选择中文加入 ADD,再拖拽到第一位 > 点击 Apply

打开 系统设置 > 区域设置 > 输入法

点击提示信息中的 运行 Fcitx

点击 添加输入法 > 找到简体中文下的 Pinyin > 点击 添加 即可加入拼音输入法(现在默认有)

第四阶段

急救地址

intel 核显

1
sudo pacman -S mesa lib32-mesa vulkan-intel lib32-vulkan-intel

nvidia

少女祈祷中…

第五阶段

截图使用 spectacle

1
2
3
4
5
6
sudo pacman -S zellij
sudo pacman -S clash-verge-rev
sudo pacman -S linuxqq
sudo pacman -S telegram-desktop miniconda neovim uv cmake kitty lazygit
paru -S visual-studio-code-bin google-chrome bluemail
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh

第六阶段

常见配置见下一篇

常用急救包

journalctl cheat sheet

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

`journalctl` 用来读取 **systemd-journald** 收集的日志
这些日志比 `/var/log/messages` 或 `/var/log/syslog` 更完整,包含了内核、系统服务、用户进程的统一日志
会按时间顺序显示日志,从最早到最新

# 查看最新日志 & 持续跟随
journalctl -f # 类似 `tail -f /var/log/syslog`,实时输出新日志

# 限制显示的条数
journalctl -n 50

# 按时间范围过滤
journalctl --since "2025-09-20 10:00:00" --until "2025-09-21 12:00:00"
journalctl --since yesterday
journalctl --since "10 min ago"

# 查看某个服务的日志
# `-u`:unit(systemd 单元),跟着服务名
journalctl -u sshd

# 查看某个启动过程的日志
journalctl -b # 显示本次开机的日志
journalctl -b -1 # 显示上一次启动的日志。

# 内核日志
journalctl -k # 相当于 `dmesg`

chroot

要安装东西先连接网络

1
2
3
4
5
6
7
8
9
lsblk -f
mount /dev/nvme0n1p3 /mnt
mount /dev/nvme0n1p4 /mnt/home
mount /dev/nvme0n1p1 /mnt/boot
swapon /dev/nvme0n1p2
arch-chroot /mnt
exit
umount -R /mnt
reboot