开发者的 Debian 12 KDE 配置优化指南
本文仅适用于配置 Debian 12 Bookworm
文中包含 KDE Plasma X11 桌面配置
文中使用 debianuser
代替用户名,执行命令或复制配置时请注意替换
文中涉及的带版本号的软件包/环境,版本号使用 xxx
代替,请根据实际情况安装最新版本或自己需要的版本
本文编辑整理时间距离实践时间相隔过长,编辑过程中可能出现不准确内容,如果在您的时间过程中发现与本文不符的情况,请尽量在评论区留言,我将尽快确认更新
该步骤中大部分操作需要重启,所以不要根据配置完成后的应用运行状态来判断配置是否成功
在该步骤末尾会重启一次应用所有配置
/home
目录下文件夹cd ~
mkdir Desktop Download Templates Public Documents Music Pictures Videos
rm -rf 公共 模板 视频 图片 文档 下载 音乐 桌面
xdg-user-dirs-update --set DESKTOP ~/Desktop
xdg-user-dirs-update --set DOWNLOAD ~/Download
xdg-user-dirs-update --set TEMPLATES ~/Templates
xdg-user-dirs-update --set PUBLICSHARE ~/Public
xdg-user-dirs-update --set DOCUMENTS ~/Documents
xdg-user-dirs-update --set MUSIC ~/Music
xdg-user-dirs-update --set PICTURES ~/Pictures
xdg-user-dirs-update --set VIDEOS ~/Videos
该步骤需要先切换到 root
身份
Ctrl + Alt + F3
切换到纯命令行界面的新终端,并以 root
身份登录进行操作
结束后使用 exit
退出终端,按 Ctrl + Alt + F1/F2
切换回用户身份图形界面
根据桌面环境及发行版本不同,快捷键可能有差异,但大多都是 Ctrl + Alt + F1-F12
以下命令在
root
身份下执行
chmod +w /etc/sudoers
cat >> /etc/sudoers << EOF
debianuser ALL=(ALL:ALL) ALL
EOF
chmod -w /etc/sudoers
exit
以上命令在
root
身份下执行
sudo tee /etc/apt/sources.list <<-'EOF'
deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free non-free-firmware
# deb-src http://mirrors.ustc.edu.cn/debian stable main contrib non-free non-free-firmware
deb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free non-free-firmware
# deb-src http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free non-free-firmware
deb http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free non-free-firmware
# deb-src http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free non-free-firmware
# deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
EOF
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
sudo tee /etc/apt/sources.list.d/docker-ce.list <<-'EOF'
deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.ustc.edu.cn/docker-ce/linux/debian bookworm stable
EOF
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo apt install vim wget curl htop git proxychains4 screenfetch tmux bash-completion fcitx5-rime chromium fcitx5 zsh fonts-powerline fzf net-tools openssh-server firewalld bat
主要卸载一些多语言支持和游戏包,可跳过
注意:卸载包时请注意同时卸载了哪些依赖,防止出现依赖问题导致卸载掉整个桌面环境
sudo apt remove --purge ibus* goldendict
sudo apt autoremove --purge
如果你的电脑存在无线网卡,并且在安装好操作系统之后发现无线网卡无法使用,请尝试如下步骤
sudo apt install firmware-iwlwifi
sudo modprobe -r iwlwifi
sudo modprobe iwlwifi
如果你的电脑存在 Nvidia 显卡,并且在安装好操作系统之后发现显卡无法使用,请尝试如下步骤
sudo apt install nvidia-detect
sudo nvidia-detect
该步骤会根据硬件检测应该安装哪些驱动,请按照输出安装对应的驱动,例如提示 nvidia-driver
sudo apt install nvidia-driver
sudo tee /etc/tmux.conf <<-'EOF'
set -g prefix C-a
unbind C-b
bind C-a send-prefix
EOF
切换到 zsh
chsh -s /bin/zsh
# If you have a specific zshrc
sudo cp ~/.zshrc /root
完成以上步骤后切换到 root
用户将自动为其配置 zsh, zinit 及 .zshrc
中配置的插件
自行配置 p10k 主题前请先按照 0x05 其他优化配置 正确配置字体
sudo reboot
下载 Google Chrome
下载 Microsoft Visual Studio Code
下载 JetBrains Toolbox App
下载 Go for Linux
下载 nvm
sudo apt install ./google-chrome-stable_current_amd64.deb
sudo apt install ./code_xxx_amd64.deb
sudo apt remove --purge 'firefox-esr*'
用于管理 JetBrains IDE
tar zxvf jetbrains-toolbox-xxx.tar.gz
./jetbrains-toolbox-xxx/jetbrains-toolbox
访问 jetbra.in/s,网站使用 IPFS 存储,跳转到 JETBRA.IN CHECKER | IPFS
,在列表中选择任意可用节点访问即可
下载页面顶部的 jetbra.zip
,按照 README 说明配置即可
建议将 go 和 nvm 分别安装到 /usr/local/go
和 /usr/local/nvm
下
为 java 创建 /usr/local/java
目录,将各版本 jdk 统一解压到该目录下便于管理
mkdir $HOME/.local/go
mkdir $HOME/.local/nvm
tar zxvf Downloads/goxxxlinux-amd64.tar.gz -C $HOME/.local/go/ --strip-components=1
chmod +x nvm_install.sh
NVM_DIR="$HOME/.local/nvm" ./nvm_install.sh
tee $HOME/.profile <<-'EOF'
source /etc/profile
export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node
export GOROOT="$HOME/.local/go"
export JAVA_HOME="$HOME/.local/java/jdk-xxx"
export PATH="$PATH:$GOROOT/bin"
export PATH="$PATH:$JAVA_HOME/bin"
EOF
配置 Go Modules,Go 代理并切换 npm 源
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct
nvm install --lts
nvm alias default lts/*
npm config set registry https://registry.npmmirror.com/
以下仅为推荐扩展,请根据自己的技术栈及个人喜好自行选择
Fluent kde theme
Fluent gtk theme
Fluent
Fluent
Fluent
Fluent
Fluent
选中
30
分钟0
秒不要记住
无操作
无操作
MediumDefault
MediumDefault
启动为空会话
浏览器历史记录
网络搜索关键词
在桌面按下任意按键时激活
记住过去的搜索
重新打开时保留上次搜索
活动感知
30
分钟挂起会话
无操作
46
不分组
当前屏幕的任务
显示秒
24 小时制
主工具栏
会话工具栏
记住窗口大小
Default
默认配置方案
140
列 30
行Nordic konsole
无限制
本文环境下广泛使用 Hack Nerd Font
显示图标,使用 Sarasa Term SC
作为等宽字体
创建 /etc/fonts/local.conf
配置字体优先级如下
DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
<family>seriffamily>
<prefer>
<family>Sarasa Term SCfamily>
<family>Hack Nerd Fontfamily>
prefer>
alias>
<alias>
<family>sans-seriffamily>
<prefer>
<family>Sarasa Term SCfamily>
<family>Hack Nerd Fontfamily>
prefer>
alias>
<alias>
<family>monospacefamily>
<prefer>
<family>Sarasa Term SCfamily>
<family>Hack Nerd Fontfamily>
prefer>
alias>
fontconfig>
.zshrc
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# apt install fonts-powerline
# Download https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.2/Hack.zip
# Extract the files and copy all font files to user font folder like ~/.local/share/fonts
# fc-cache -f -v
### Added by Zinit's installer
if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then
print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit"
command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \
print -P "%F{33} %F{34}Installation successful.%f%b" || \
print -P "%F{160} The clone has failed.%f%b"
fi
source /etc/zsh/zprofile
source $HOME/.profile
source "$HOME/.local/share/zinit/zinit.git/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
### End of Zinit's installer chunk
HISTFILE="$HOME/.zsh_history"
HISTSIZE=10000
SAVEHIST=10000
setopt BANG_HIST # Treat the '!' character specially during expansion.
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
setopt HIST_VERIFY # Don't execute immediately upon history expansion.
setopt HIST_BEEP # Beep when accessing nonexistent history.
# apt install fzf
zinit ice depth='1' lucid wait='0' atload='_zsh_autosuggest_start'
zinit light zsh-users/zsh-autosuggestions
zinit ice depth='1' lucid wait='0'
zinit light zsh-users/zsh-syntax-highlighting
zinit ice depth='1'
zinit light zsh-users/zsh-completions
zinit ice depth='1'
zinit light romkatv/powerlevel10k
zinit ice lucid wait='0'
zinit snippet OMZ::plugins/jsontools/jsontools.plugin.zsh
zinit ice lucid wait='0'
zinit snippet OMZ::plugins/fzf/fzf.plugin.zsh
zinit ice lucid wait='0'
zinit snippet OMZ::lib/completion.zsh
autoload -U compinit && compinit
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
if [ ${DISPLAY} ]; then
[[ ! -f ~/.p10k.gui.zsh ]] || source ~/.p10k.gui.zsh
else
export LANG=en_US.UTF-8
[[ ! -f ~/.p10k.terminal.zsh ]] || source ~/.p10k.terminal.zsh
fi
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias ll='ls -lh'
alias la='ls -A'
alias l='ls -CF'
# advcpmv Site: https://github.com/jarun/advcpmv
# ===== advcpmv Step Start =====
# ===== from source code
# wget http://ftp.gnu.org/gnu/coreutils/coreutils-9.4.tar.xz
# tar Jxvf coreutils-9.4.tar.xz
# cd coreutils-9.4/
# wget https://raw.githubusercontent.com/jarun/advcpmv/master/advcpmv-0.9-9.4.patch
# patch -p1 -i advcpmv-0.9-9.4.patch
# ./configure
# make
# sudo chmod +x ./src/cp ./src/mv
# sudo chown root. ./src/cp ./src/mv
# sudo mv ./src/cp /usr/local/bin/cpg
# sudo mv ./src/mv /usr/local/bin/mvg
# ===== advcpmv Step Finish =====
alias cp='/usr/local/bin/cpg -g'
alias mv='/usr/local/bin/mvg -g'
# bat Site: https://github.com/sharkdp/bat
# ===== bat Step Start =====
# ===== from github
# Download release from https://github.com/sharkdp/bat/releases
# apt install ./bat-musl_x.xx.x_amd64.deb
# ===== bat Step Finish =====
alias cat='batcat --paging=never -p'
Powerlevel10k 是 zsh 的主题,在 .zshrc
中我们声明了在桌面环境和终端环境下使用不同的 p10k 配置,即桌面环境使用图标更多更友好的终端主题配置,而在终端环境下使用更保守的终端主题配置以保证兼容性,执行 p10k configure
来生成配置文件