Fedora 环境搭建记录

6 min
WARNING

这是在 Fedora 42 KDE Plasma Desktop 上的配置记录,所有指令请参考官网最新版本。

更新系统包

sudo dnf update

dnf 换源

根据 https://mirrors.tuna.tsinghua.edu.cn/help/fedora/.

# backup
sudo mv /etc/yum.repos.d/fedora.repo /etc/yum.repos.d/fedora.repo.bak
sudo mv /etc/yum.repos.d/fedora-updates.repo /etc/yum.repos.d/fedora-updates.repo.bak
# modify
sed -e 's|^metalink=|#metalink=|g' \
    -e 's|^#baseurl=http://download.example/pub/fedora/linux|baseurl=https://mirrors.tuna.tsinghua.edu.cn/fedora|g' \
    -i.bak \
    /etc/yum.repos.d/fedora.repo \
    /etc/yum.repos.d/fedora-updates.repo

AppImage

使用 appimagelauncher 管理 AppImage 文件。

sudo dnf install appimagelauncher

Flatpak

根据 https://flatpak.org/setup/fedora 的提示进行配置。

flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo

然后下载 flatseal 管理权限(fedora 自带了 flatpak 应用权限管理,所以也可以不用装)

sudo dnf install flatseal

同步系统时间

timedatectl set-local-rtc 1 --adjust-system-clock

安装常用软件

(neo)vim

sudo dnf install vim
sudo dnf install neovim

当然顺便也要卸载 nano 啦:

sudo dnf remove nano

clash-verge

前往 https://clashverge.net/downloads/ 下载最新版本的 rpm 包。

sudo dnf install ./Clash.Verge_2.3.0_amd64.rpm

然后前往配置文件设置代理。我主要使用 https://38nthu.xyz/(可能现在无法访问)。以及 https://mojie.app、https://ikuuu.org/ 作为应急情况。之后前往系统设置,添加自启动项。

zsh

# install
sudo dnf install zsh

# set zsh as the default shell
chsh -s $(which zsh)

# verify after re-login
echo $SHELL

# install oh-my-zsh
sudo dnf install curl git
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# 安装 zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

然后设置 oh-my-zsh. 启用一些插件

plugins=(git zsh-autosuggestions z command-not-found colored-man-pages colorize conda-env copyfile copypath fzf python uv)

fcitx5

sudo dnf install fcitx5
sudo dnf remove ibus

查看当前会话使用的是 wayland 还是 xorg:

echo $XDG_SESSION_TYPE

对我而言是 wayland。 然后根据 https://fcitx-im.org/wiki/Using_Fcitx_5_on_Wayland 中的说明,将以下内容写入 ~/.profile~/.zshrc

export XMODIFIERS=@im=fcitx

然后修改文件 ~/.config/imsettings/xinputrc (实际上是 /etc/X11/xinit/xinput.d/xcompose.conf 的软链接),删除

GTK_IM_MODULE=xim
QT_IM_MODULE=xim

这两行(需要的话记得备份)

然后添加到自启动应用程序中。重启以查看是否生效。然后配置中文输入法

sudo dnf install fcitx5-rime
sudo dnf install fcitx5-chinese-addons

然后根据 https://github.com/iDvel/rime-ice 安装 rime-ice:

cd ~/.local/share/fcitx5/
mv rime rime.bak # backup, not neccesary
git clone https://github.com/iDvel/rime-ice --depth=1 rime

Git

git config --global set user.name xxx
git config --global set user.email xxx

当然我是保存了 ~/.gitconfig 文件,直接复制到家目录就行了

ssh

根据 https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent 设置连接 github 的 ssh key。

ssh-keygen -t ed25519 -C "2823324228@qq.com" # 保存至/home/kinnariya/.ssh/id_ed25519_github文件中
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519_github

然后去 https://github.com/settings/keys 添加公钥

cat ~/.ssh/id_ed25519_github.pub

测试连接

ssh -T git@github.com

自动启动 ssh-agent:向 ~/.zshrc 中加入

# ssh agent
# 启动 ssh-agent 并添加 ssh 密钥
if ! pgrep -u $USER ssh-agent > /dev/null; then
    eval "$(ssh-agent -s)"
fi
ssh-add -l &>/dev/null || ssh-add ~/.ssh/id_ed25519_github &>/dev/null

TLP

sudo dnf install tlp
flatpak install tlpui # 图形界面,方便设置

Google Chrome & edge

Chrome 前往官网下载。登录后自动同步历史、插件等。

然后 Edge(根据 https://discussion.fedoraproject.org/t/install-edge/67186/4):

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo dnf config-manager addrepo --from-repofile='https://packages.microsoft.com/yumrepos/edge/config.repo'
sudo dnf update --refresh
sudo dnf install microsoft-edge-stable

然后卸载 Firefox:

sudo dnf remove firefox

Folo

前往 https://github.com/RSSNext/Folo/releases 安装。

QQ、微信

可以选择 flatpak,也可以就用官网的(如果不care扫盘的风险的话)

微信在 wayland 下无法输入中文,可以通过修改环境变量来修补:将 /usr/share/applications/wechat.desktop 中的

Exec=/usr/bin/wechat %U

修改为

Exec=env QT_IM_MODULE=fcitx /usr/bin/wechat %U

即可

Telegram

sudo dnf install telegram

vscode & cursor

vscode 前往官网下载 rpm 包:https://code.visualstudio.com/

cursor 前往官网下载 appimage 格式:https://www.cursor.com/

obsidian

flatpak install obsidian

onedrive

使用 onedriver https://github.com/jstaf/onedriver

sudo dnf copr enable jstaf/onedriver
sudo dnf install onedriver

yazi

根据 Installation | Yazi

sudo dnf copr enable lihaohong/yazi
sudo dnf install yazi

然后向 .zshrc 中加入

function yy() {
	local tmp="$(mktemp -t "yazi-cwd.XXXXXX")"
	yazi "$@" --cwd-file="$tmp"
	if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
		builtin cd -- "$cwd"
	fi
	rm -f -- "$tmp"
}

飞书

前往官网下载 下载飞书 App 及桌面客户端 - 飞书官网。也可以直接使用网页版。

Google docs

先卸载 libreoffice:

sudo dnf remove libreoffice*

然后去 https://docs.google.com/ 进行文档编写。

WPS

去官网 https://linux.wps.cn/ 下载。

腾讯会议

flatpak install wemeet

其他

sudo dnf install fastfetch fzf tldr

# lazygit, https://copr.fedorainfracloud.org/coprs/atim/lazygit/
sudo dnf copr enable atim/lazygit
sudo dnf install lazygit

# uv, https://github.com/astral-sh/uv
curl -LsSf https://astral.sh/uv/install.sh | sh

系统快捷键设置

前往 Settings > Keyboard > Shortcuts 进行设置。

美化

我没做美化,因为觉得原皮挺好看的

也是经典壁纸了哈哈
也是经典壁纸了哈哈

环境配置

Python

根据官网信息 Installing Miniconda - Anaconda 安装 miniconda

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash ~/Miniconda3-latest-Linux-x86_64.sh

然后设置 pip 源:

# 设置为清华源
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
# 设置代理
pip config set global.proxy https://127.0.1:7890

设置 conda 源:

channels:
  - defaults
  - conda-forge
  - nodefaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  deepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/
channel_priority: flexible

然后安装 wandb(其他工具包同理,都可以用 uv 来装):

uv tool install wandb
# 登录
wandb login

安装 CUDA(安装前记得备份系统):

sudo dnf install xorg-x11-drv-nvidia-cuda

然后重启电脑,进入终端,输入 nvidia-smi 检验是否安装成功。

rust

sudo dnf install cargo

博客

sudo dnf install node npm pnpm yarn

LaTex

我采用 medium 安装,包含了常用的宏包。

# sudo dnf install texlive-scheme-basic
sudo dnf install texlive-scheme-medium
# sudo dnf install texlive-scheme-full

发现中文有报错

File `ctex.sty' not found.LaTeX

于是安装 ctex 宏包:

sudo dnf install texlive-ctex

清理软件包

为了方便,直接去软件商店手动卸载不需要的软件包。

sudo dnf clean all
sudo dnf autoremove