pacman -S caddyDebian安装
apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
apt update
apt install caddy添加 http.handlers.replace_response模块
caddy add-package github.com/caddyserver/replace-response检查http.handlers.replace_response模块是否安装完成
[root@archlinux ~]# caddy list-modules | grep http.handlers.replace_response
http.handlers.replace_responseCaddy目录
[root@archlinux caddy]# tree
.
├── Caddyfile
└── conf.d修改默认 Caddyfile配置文件 注册 replace指令
nano /etc/caddy/Caddyfile{
order replace after encode
}添加网站配置
nano /etc/caddy/conf.d/example.comexample.com {
reverse_proxy https://example.com {
header_up Host {upstream_hostport}
header_up Accept-Encoding identity
}
replace aaa bbb
}重载caddy配置
systemctl reload caddy参考
https://caddyserver.com/docs/caddyfile/directives/reverse_proxy
]]>wireguard等依赖Debian
apt update -y && apt install wireguard sudo curl vim openresolv -yArch Linux
yay -S wireguard-tools openresolv wgcf vim dnsutils linux-headers --neededDebian
curl -fsSL git.io/wgcf.sh | sudo bashwgcf registerwgcf generatevim wgcf-profile.conf[Interface]
PrivateKey = 这里会自动生成
Address = 172.16.0.2/32
Address = 这里会自动生成
DNS = 8.8.8.8,8.8.4.4,2001:4860:4860::8888,2001:4860:4860::8844
MTU = 1280
[Peer]
PublicKey = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=
AllowedIPs = 0.0.0.0/0
AllowedIPs = ::/0
Endpoint = engage.cloudflareclient.com:2408更改engage.cloudflareclient.com为IPV4/6地址(如双栈网络接入忽略)
[root@archlinux ~]# nslookup engage.cloudflareclient.com
Server: 1.1.1.1
Address: 1.1.1.1#53
Non-authoritative answer:
Name: engage.cloudflareclient.com
Address: 162.159.192.1
Name: engage.cloudflareclient.com
Address: 2606:4700:d0::a29f:c001删除配置文件中的AllowedIPs = ::/0
删除配置文件中的AllowedIPs = 0.0.0.0/0
cp wgcf-profile.conf /etc/wireguard/wgcf.confwg-quick up wgcf# IPv4 Only VPS
curl -6 ip.p3terx.com
# IPv6 Only VPS
curl -4 ip.p3terx.comwg-quick down wgcfsystemctl start wg-quick@wgcf
systemctl enable wg-quick@wgcf
]]>systemctl stop reflector.service如无法连接上网络可尝试使用dhcpcd命令
iwctl列出无线网卡设备
device list 用wlan0网卡扫描网络
station wlan0 scan列出网络
station wlan0 get-networks连接网络网络SSID不支持中文
station wlan0 connect 无线网名字输入密码,连接成功后使用exit或者quit
timedatectl set-ntp true把中国的服务器排在前列
nano /etc/pacman.d/mirrorlistServer = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch 刷新软件包
pacman -Sy安装ssh远程软件
pacman -S openssh启用sshd服务
systemctl start sshdpasswd设置当前root账户的密码
ip a查看ip地址
局域网内使用其他设备连接SSH操作更方便
lsblk显示当前磁盘和分区情况
cfdisk /dev/nvme0n1系统格式可使用Btrfs或者EXT4
首先创建 Swap 分区。选中 Free space > 再选中操作 [New] > 然后按下回车 Enter 以新建 swap 分区(类似 Windows 的交换文件)
我们再只需要一个分区即可(因为使用 Btrfs 文件系统,所以根目录和用户主目录在一个分区上),所以类似的:选中 Free space > 再选中操作 [New] > 然后按下回车 Enter 以新建分区
分区类型默认即可,无需更改。接下来选中操作 [Write] 并回车 Enter > 输入 yes 并回车 Enter 确认分区操作
选中操作 [Quit] 并回车 Enter 以退出 cfdisk 分区工具
EFI引导分区可使用Windows的ESP分区。如没有可自行创建300MB的EFI引导分区
mkswap /dev/nvme0n1pxmkfs.btrfs -L Arch /dev/nvme0n1pxmkfs.ext4 /dev/nvme0n1px将 Btrfs 分区挂载到 /mnt 下
mount -t btrfs -o compress=zstd /dev/nvme0n1px /mnt创建 Btrfs 子卷
通过以下命令创建两个 Btrfs 子卷,之后将分别挂载到 / 根目录和 /home 用户主目录:
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home复查子卷情况
btrfs subvolume list -p /mnt子卷创建好后,我们需要将 /mnt 卸载掉,以挂载子卷
umount /mnt挂载/目录
mount -t btrfs -o subvol=/@,compress=zstd /dev/nvme0n1px /mnt创建home目录
mkdir /mnt/home挂载/home目录
mount -t btrfs -o subvol=/@home,compress=zstd /dev/nvme0n1px /mnt/home创建 /boot/efi 目录
mkdir -p /mnt/boot/efi 挂载 /boot/efi 目录
mount /dev/nvme0n1px /mnt/boot/efimount /dev/nvme0n1px /mnt创建 /boot/efi 目录
mkdir -p /mnt/boot/efi 挂载 /boot/efi 目录(使用Windows系统ESP分区)
mount /dev/nvme0n1px /mnt/boot/efi挂载交换分区
swapon /dev/nvme0n1px往/mnt目录里安装系统
其中最基础的四个包是base base-devel linux linux-firmware
pacstrap /mnt base base-devel linux linux-firmware dhcpcd iwd vim sudo bash-completion nano net-tools openssh man git wget zsh fishgenfstab -U /mnt >> /mnt/etc/fstab复查一下 /mnt/etc/fstab 确保没有错误:
cat /mnt/etc/fstab使用以下命令把系统环境切换到新系统下:
arch-chroot /mnt首先在 /etc/hostname 设置主机名:
nano /etc/hostname然后在 /etc/hosts 设置与其匹配的条目:
127.0.0.1 localhost
::1 localhost
127.0.1.1 myarch.localdomain myarch随后设置时区,在 /etc/localtime 下用 /usr 中合适的时区创建符号链接:
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtimehwclock --systohcLocale 决定了软件使用的语言、书写习惯和字符集。
编辑 /etc/locale.gen,去掉 en_US.UTF-8 UTF-8 以及 zh_CN.UTF-8 UTF-8 行前的注释符号(#):
nano /etc/locale.gen然后使用如下命令生成 locale
locale-gen向 /etc/locale.conf 输入内容:
echo 'LANG=en_US.UTF-8' > /etc/locale.confpasswd rootnano /etc/pacman.confctrl+w 搜索Color注意大小写 删除#号
系统报错会彩色显示 方便用户排查
[multilib]这两行前面的#号删除
再手动添加[archlinuxcn]源
我这里以中科大和网易开源镜像站为例
其他地址 如清华 阿里云 或者你所在的高校有archlinuxcn源 可以自行添加
[archlinuxcn]
Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch官方源
[archlinuxcn]
Server = https://repo.archlinuxcn.org/$arch新建用户名arch 可自行更改用户名
useradd -m -G wheel -s /bin/bash arch设置arch用户名的密码
passwd arch编辑arch用户的权限
EDITOR=nano visudoctrl+w搜索%wheel
找到# %wheel ALL=(ALL:ALL)ALL
删除前面的#号
通过以下命令安装对应芯片制造商的微码:
intel-ucode # Intel
amd-ucode # AMD
os-prober #查找已安装的操作系统 pacman -S intel-ucode grub efibootmgr os-prober安装 GRUB 到 EFI 分区:
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=Arch接下来 编辑 /etc/default/grub 文件:
nano /etc/default/grub进行如下修改:
GRUB_CMDLINE_LINUX_DEFAULT 一行中最后的 quiet 参数loglevel 的数值从 3 改成 5。这样是为了后续如果出现系统错误,方便排错nowatchdog 参数,这可以显著提高开关机速度GRUB_DISABLE_OS_PROBER=false# GRUB boot loader configuration
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Arch"
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=5 nowatchdog"
GRUB_CMDLINE_LINUX=""
GRUB_DISABLE_OS_PROBER=false
...最后生成 GRUB 所需的配置文件:
grub-mkconfig -o /boot/grub/grub.cfg如遇到报错或无法引导Windows分区可使用下面的命令
sudo LANG=C grub-mkconfig -o /boot/grub/grub.cfgpacman -S plasma-meta konsole dolphin # plasma-meta 元软件包、konsole 终端模拟器和 dolphin 文件管理器pacman -S ntfs-3g **可以读取ntfs格式磁盘 **
pacman -S os-prober **查找已安装的操作系统 **中文字体 这里如果不安装 之后设置语言的时候都是框框不好辨认
pacman -S adobe-source-han-serif-cn-fonts adobe-source-han-sans-cn-fonts wqy-zenhei wqy-microhei noto-fonts-cjk noto-fonts-emoji noto-fonts-extra ttf-dejavu pacman -S firefox ark gwenview packagekit-qt5 packagekit appstream-qt appstream man neofetch net-tools networkmanager openssh git wget pamacsystemctl enable NetworkManager sddm sshd立即启动登陆管理器
systemctl start sddm卸载本机的/mnt目录
umount -R /mnt重启
reboot输入密码登录进桌面环境
sudo pacman -S archlinuxcn-keyring && sudo pacman -S yaysudo pacman -S bluez bluez-utils sudo systemctl enable --now bluetoothsudo pacman -S alsa-utils pulseaudio pulseaudio-alsa pulseaudio-bluetoothIntel 核芯显卡
sudo pacman -S mesa lib32-mesa vulkan-intel lib32-vulkan-intel不建议安装 xf86-video-intel,而应使用 Xorg 的 modesetting 驱动(也就是什么都不用装的意思)
注意,只有 Intel HD 4000 及以上的核显才支持 vulkan。
不建议安装 xf86-video-intel,而应使用 Xorg 的 modesetting 驱动(也就是什么都不用装的意思)
注意,只有 Intel HD 4000 及以上的核显才支持 vulkan。
题外如果太久没更新 密钥环失效
sudo pacman -Sy archlinux-keyringpacman-key --refresh-keys更换LTS内核
pacman -S linux-lts linux-lts-headers
pacman -Rsdd linux
grub-mkconfig -o /boot/grub/grub.cfg开启BBR
echo "tcp_bbr" > /etc/modules-load.d/modules.conf
echo "net.core.default_qdisc=fq" > /etc/sysctl.d/bbr.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.d/bbr.conf
sysctl --system校验
sysctl net.ipv4.tcp_congestion_control安装cron定时任务
pacman -S cronie默认 editor 为 vi, 在 /etc/environment 下配置环境变量
EDITOR=nano清理系统日志文件 保留的最新日志文件大小为100M
journalctl --vacuum-size=100M设置系统日志只保留100M
nano /etc/systemd/journald.conf修改#SystemMaxUse=为SystemMaxUse=100M
重新加载 systemd-journald 服务以应用更改
systemctl restart systemd-journald
]]>Manjaro换源
sudo pacman-mirrors -c China添加 archlinuxcn 源,获得更多的包:
sudo nano /etc/pacman.conf[archlinuxcn]
SigLevel = Optional TrustAll
Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch## xTom (Hong Kong server) (Hong Kong) (ipv4, ipv6, http, https)
## Added: 2017-09-18
## Blocking users in mainland China
[archlinuxcn]
Server = https://mirrors.xtom.hk/archlinuxcn/$arch更新系统、软件
sudo pacman -Syyu下载 yay AUR 助手
sudo pacman -S yayyay安装报错
sudo pacman -Sy && sudo pacman -S archlinuxcn-keyringsudo rm -rf /etc/pacman.d/gnupg
sudo pacman-key --init
sudo pacman-key --populate安装 base-devel,yay 命令构建包时会使用到
sudo pacman -S base-devel输入法配置
yay -S fcitx5-im fcitx5-chinese-addons fcitx5-material-color fcitx5-pinyin-zhwikifcitx5-im fcitx5 输入法框架包
fcitx5-chinese-addons 中文输入法
fcitx5-material-color 皮肤美化包
fcitx5-pinyin-zhwiki 词库安装完成后编辑将下面 3 行代码加入到 /etc/environment 文件中,这样可以预防出现某些程序不能输入中文的情况发生
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
XMODIFIERS=@im=fcitxohmyzsh
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh更改默认 shell 为 zsh:
chsh -s /usr/bin/zsh
zsh下载插件:
自动补全
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
语法高亮
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
zsh-vi-mod
git clone https://github.com/jeffreytse/zsh-vi-mode $ZSH_CUSTOM/plugins/zsh-vi-mode安装 autojump,终端目录跳转神器:
git clone https://github.com/wting/autojump
cd autojump
./install.py
cd ..
rm -rf autojump打开 ~/.zshrc 找到 plugins 将它改成下面这样:
plugins=(
git
zsh-syntax-highlighting
zsh-autosuggestions
zsh-vi-mode
colored-man-pages
)在~/.zshrc尾部添加
[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.shChrome
yay -S google-chrome网易云音乐
sudo pacman -S netease-cloud-musicWPS
yay -S ttf-wps-fonts wps-office-mui-zh-cn wps-office-mime-cn wps-office-cnyay -S wps-office-fonts ttf-ms-fonts百度网盘
yay -S baidunetdisk迅雷
yay -S xunlei-bin 微信
yay -S deepin-wine-wechat微信运行时会显示:
程序 WeChatApp.exe 遇到严重问题需要关闭。我们对此造成的不便表示抱歉。
其实这个 BUG 不影响使用,但是看着心烦,解决办法是先运行如下命令:
/opt/apps/com.qq.weixin.deepin/files/run.sh winecfg然后选择函数库选项卡,新增函数库顶替的输入框中中输入 wechatapp.exe ,点击右侧添加,选择新建好的 wechatapp.exe,点击编辑,选择停用即可。
yay -S deepin-wine-qqTeamviewer
yay -S teamviewer火焰截图
sudo pacman -S flameshotTypora
Typora 最新版已经收费,可以在官网下载以前的版本并手动安装,下面是最后一个免费版本:
下载完成后手动安装:
sudo tar -xvf ~/Downloads/Typora-linux-x64-1.0.3.tar.gz -C /usr/local
sudo mv /usr/local/bin/Typora-linux-x64 /usr/local/typora添加可视化启动程序,在 ~/.local/share/applications 下新建以下文件,Typora 内部自己有 PNG 图片,所以不需要额外下载,直接复制粘贴以下内容即可:
vim ~/.local/share/applications/typora.desktop
[Desktop Entry]
Type=Application
Name=Typora
Exec=/usr/local/typora/Typora
Icon=/usr/local/typora/resources/assets/icon/[email protected]
Terminal=false
Categories=program;InstantMessagingPicgo
yay -S picgo-appimage如果可以直接安装就直接使用。我这里自动安装出现了问题,所以又需要手动安装了。
先到 picgo 的 github 中下载 AppImage 后缀的包,然后双击安装即可。
转换 deb 包
安装 debtab:
sudo pacman -S debtap更新 debtab:
sudo debtap -u下载好待转换的 deb 包,将其转换,以下步骤一路回车即可:
sudo debtap ~/Downloads/包名.deb安装转换后的包:
sudo pacman -U ~/Downloads/包名.pkg.tar.zst配置Git
配置 Git 用户名、密码、代理 :
git config --global user.name <用户名>
git config --global user.email <邮箱地址>
git config --global http.proxy socks5://127.0.0.1:7890
git config --global https.proxy socks5://127.0.0.1:7890添加 SSH:
ssh-keygen # 疯狂回车拷贝公钥 ~/.ssh/id_rsa.pub 中的内容,到 github 中添加 ssh keys 即可。
VMware-WorkStation
VMware-WorkStation包在AUR上可用,可以通过运行命令来安装。
yay -S vmware-workstation安装系统对应的linux-headers
sudo pacman -S linux-headers载入vmmon模块
sudo modprobe -a vmw_vmci vmmon自启动网络服务和USB
sudo systemctl enable vmware-networks.service vmware-usbarbitrator.servicesudo systemctl start vmware-networks.service vmware-usbarbitrator.service安装osc-url
下载 ocs-url:点我跳转
下载完成后手动安装:
sudo pacman -U ~/Downloads/ocs-url-3.1.0-1-x86_64.pkg.tar.xz
]]>