1466 字
7 分钟
ArchLinux使用指南
🐧 Arch Linux 使用指南
🎯 一份完整的 Arch Linux 安装配置与使用手册
📚 目录
💻 系统安装
🎯 基础安装步骤
⚠️ 注意:以下步骤为精简版安装流程,适合有经验的用户。新手请参考详细安装指南。
1. 准备工作
# 禁用 reflector 服务systemctl stop reflector.servicesystemctl status reflector.service2. 网络连接
# 解除网卡禁用rfkill unblock all
# WiFi 连接iwctl在 iwctl 界面中执行:
[iwd]# device list[iwd]# station <device> scan[iwd]# station <device> get-networks[iwd]# station <device> connect <wifi名称>[iwd]# exit测试网络连接:
ping www.baidu.com -c 43. 系统时间同步
timedatectl set-ntp truetimedatectl status4. 更换镜像源
# 备份原配置cp -a /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
# 编辑镜像列表vim /etc/pacman.d/mirrorlist添加国内镜像源:
Server = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$archServer = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$archServer = https://repo.huaweicloud.com/archlinux/$repo/os/$arch更新软件包:
pacman -Syy5. 硬盘分区方案
| 分区 | 大小 | 说明 |
|---|---|---|
/boot | 512M | 启动分区 (UEFI 必需) |
swap | 内存的 1/4 | 交换分区 |
/ | ≥20G | 根分区 |
/home | 剩余空间 | 用户数据分区 (可选) |
6. 格式化与挂载
UEFI 启动:
mkfs.fat -F32 /dev/sda1mkfs.ext4 /dev/sda3mkswap /dev/sda2swapon /dev/sda2
mount /dev/sda3 /mntmkdir /mnt/bootmount /dev/sda1 /mnt/boot7. 安装系统
pacstrap /mnt base base-devel linux linux-firmware linux-headerspacstrap /mnt vim bash-completion iwd dhcpcd ntfs-3g net-tools8. 系统配置
# 生成 fstabgenfstab -U /mnt >> /mnt/etc/fstab
# 进入新系统arch-chroot /mnt
# 设置时区ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtimehwclock --systohc
# 本地化设置vim /etc/locale.gen # 取消 en_US.UTF-8 和 zh_CN.UTF-8 注释locale-genecho "LANG=en_US.UTF-8" > /etc/locale.conf
# 设置主机名echo "ArchLinux" > /etc/hostnameecho -e "127.0.0.1 localhost\n::1 localhost\n127.0.1.1 ArchLinux.localdomain ArchLinux" >> /etc/hosts
# 设置 root 密码passwd9. 引导程序安装
# 安装微码 (根据 CPU 选择)pacman -S amd-ucode # AMD CPU# 或pacman -S intel-ucode # Intel CPU
# 安装 GRUBpacman -S grub efibootmgrgrub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
# 启用 OS 探测echo "GRUB_DISABLE_OS_PROBER=false" >> /etc/default/grubgrub-mkconfig -o /boot/grub/grub.cfg10. 完成安装
exitumount -R /mntreboot11. 安装图形界面 (KDE)
# 连接网络systemctl enable --now dhcpcd
# 安装 KDE Plasmapacman -S sddm sddm-kcmpacman -S plasma konsole kate filelight dolphin ark
# 启用显示管理器systemctl enable sddm📦 AUR 软件管理
🔧 Yay - AUR 助手
安装 Yay
pacman -S --needed git base-develgit clone https://aur.archlinux.org/yay-bin.gitcd yay-binmakepkg -si💡 提示: 使用 yay 时不需要
sudo
常用命令
| 功能 | 命令 | 说明 |
|---|---|---|
| 更新软件包 | yay -Syyu | 更新系统和 AUR 包 |
| 搜索软件 | yay -Ss 关键词 | 搜索在线软件包 |
| 安装软件 | yay -S 包名 | 安装 AUR 软件包 |
| 卸载软件 | yay -Rsn 包名 | 彻底卸载软件包 |
| 清理缓存 | yay -Scc | 清理软件包缓存 |
| 清理孤包 | yay -Rscnu $(yay -Qdtq) | 清理孤立软件包 |
🖥️ 桌面环境配置
🌐 中文环境配置
1. 安装中文本地化
# 编辑 locale.gensudo vim /etc/locale.gen取消注释:
en_US.UTF-8 UTF-8zh_CN.UTF-8 UTF-8生成 locale:
sudo locale-gen2. 用户环境变量
在 ~/.bashrc 或 ~/.xprofile 中添加:
export LANG=zh_CN.UTF-8export LANGUAGE=zh_CN:en_US3. 安装中文字体
sudo pacman -S noto-fonts-cjksudo pacman -S firefox-i18n-zh-cn # Firefox 中文语言包🛠️ 常用软件推荐
🔄 系统工具
# 系统备份 (必装)sudo pacman -S timeshift
# 系统信息显示sudo pacman -S neofetch lolcat
# Dockersudo pacman -S dockersudo systemctl enable --now docker💼 开发工具
# 编程环境sudo pacman -S git nodejs npm yarnyay -S visual-studio-code-binyay -S jetbrains-toolboxyay -S android-studio🎨 多媒体工具
# 图像处理sudo pacman -S gwenview flameshotyay -S picgo-appimage
# 视频播放sudo pacman -S mpv vlc obs-studio
# 音乐yay -S netease-cloud-music spotify📝 办公软件
# 办公套件yay -S wps-office ttf-wps-fontsyay -S typora
# PDF 阅读yay -S okularsudo pacman -S calibre🔧 实用工具
# 系统工具sudo pacman -S latte-dock albert screenkeyyay -S deepin-wine-wechat teams bleachbityay -S bitwarden-bin v2raya⚙️ 硬件配置
💾 NTFS 硬盘自动挂载
1. 安装必要工具
sudo pacman -S ntfs-3g2. 创建挂载点
sudo mkdir /mnt/sharedisk3. 获取硬盘 UUID
sudo blkid /dev/sda14. 配置自动挂载
编辑 /etc/fstab:
sudo vim /etc/fstab添加以下内容:
UUID=XXXXXX /mnt/sharedisk ntfs-3g defaults 0 0🔧 系统维护
🛠️ GRUB 引导修复
1. 重新安装 GRUB
pacman -S grub efibootmgrgrub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=GRUB2. 添加 Windows 启动项
获取 Windows 分区 UUID:
sudo blkid编辑 /etc/grub.d/40_custom:
sudo vim /etc/grub.d/40_custom添加 Windows 启动项:
if [ "${grub_platform}" == "efi" ]; then menuentry "Windows Boot Manager" { insmod part_gpt insmod fat insmod chain search --no-floppy --fs-uuid --set=root FS_UUID chainloader /EFI/Microsoft/Boot/bootmgfw.efi }fi3. 生成新配置
grub-mkconfig -o /boot/grub/grub.cfg📝 附录
⚡ 常用命令速查表
| 类别 | 命令 | 说明 |
|---|---|---|
| 系统管理 | sudo pacman -Syu | 更新整个系统 |
sudo systemctl start 服务名 | 启动服务 | |
sudo systemctl enable 服务名 | 设置开机自启 | |
| 软件管理 | pacman -Ss 关键词 | 搜索软件包 |
sudo pacman -S 包名 | 安装软件包 | |
sudo pacman -R 包名 | 卸载软件包 | |
yay -S 包名 | 安装 AUR 软件 | |
| 文件操作 | ls -la | 详细文件列表 |
chmod +x 文件 | 添加执行权限 | |
sudo chown 用户:组 文件 | 更改文件所有者 | |
| 系统信息 | neofetch | 显示系统信息 |
htop | 进程监控 | |
df -h | 磁盘空间检查 |
🚀 系统优化建议
1. 启用定时任务
# 启用定时更新sudo systemctl enable --now paccache.timer
# 启用 TRIM (SSD)sudo systemctl enable --now fstrim.timer2. 性能优化
在 /etc/sysctl.d/99-sysctl.conf 中添加:
# 减少 swap 使用vm.swappiness=10
# 提高文件系统性能vm.dirty_ratio=15vm.dirty_background_ratio=53. SSD 优化
在 /etc/fstab 中添加 noatime 参数:
UUID=xxx / ext4 defaults,noatime 0 1🆘 故障排除
1. 图形界面问题
# 检查 Xorg 日志cat /var/log/Xorg.0.log
# 重置显示配置mv ~/.config ~/.config.bak2. 网络连接问题
# 重启网络服务sudo systemctl restart NetworkManager
# 检查网络接口ip link show3. 声音问题
# 检查音频设备aplay -l
# 调节音量alsamixer
# 重启音频服务sudo systemctl restart alsa-state🔍 实用技巧
1. 快速查看系统信息
neofetch | lolcat2. 清理系统
# 清理包缓存yay -Scc
# 清理旧内核sudo pacman -Rns $(pacman -Qtdq)3. 备份系统
# 使用 Timeshift 备份sudo timeshift --create --comments "定期备份"📄 版权声明
📖 本文档基于个人实践经验整理,内容仅供参考。Arch Linux 是 Judd Vinet 的商标。
⚠️ 重要提示: 建议在操作前备份重要数据,部分操作需要 root 权限,请谨慎执行。
ArchLinux使用指南
http://blog.xeu.asia/posts/技术折腾/archlinux使用指南/