原文地址: Debian 11 配置优化指南 - WindSpiritIT
本文仅适用于配置 Debian 11 Bullseye
文中同时包含 Gnome 桌面和 KDE 桌面配置,其中大部分相同,不同之处分别列出
Gnome 桌面相关配置更新滞后,可能不再更新
KDE 及 Gnome 优化配置部分请根据个人喜好自行配置
文中使用 debianuser 代替用户名,执行命令或复制配置时请注意替换
文中涉及的带版本号的软件包/环境,版本号使用 xxx 代替,请根据实际情况安装最新版本或自己需要的版本
本文编辑整理时间距离实践时间相隔过长,编辑过程中可能出现不准确内容,如果在您的时间过程中发现与本文不符的情况,请尽量在评论区留言,我将尽快确认更新
该步骤中大部分操作需要重启,所以不要根据配置完成后应用是否能正常使用来判断配置应用情况
在该步骤末尾会重启一次应用所有配置
/home 目录下文件夹cd ~mkdir Desktop Download Templates Public Documents Music Pictures Videosrm -rf 公共 模板 视频 图片 文档 下载 音乐 桌面xdg-user-dirs-update --set DESKTOP ~/Desktopxdg-user-dirs-update --set DOWNLOAD ~/Downloadxdg-user-dirs-update --set TEMPLATES ~/Templatesxdg-user-dirs-update --set PUBLICSHARE ~/Publicxdg-user-dirs-update --set DOCUMENTS ~/Documentsxdg-user-dirs-update --set MUSIC ~/Musicxdg-user-dirs-update --set PICTURES ~/Picturesxdg-user-dirs-update --set VIDEOS ~/Videos该步骤需要先切换到 root 身份,有两个方案
切换到新的 tty
Ctrl + Alt + F3 切换到纯命令行界面的新终端,并以 root 身份登录进行操作
结束后使用 exit 退出终端,按 Ctrl + Alt + F1/F2 切换回用户身份图形界面
通过 SSH
ssh root@localhost结束后使用 exit 退出终端
以下命令在
root身份下执行
chmod +w /etc/sudoerscat >> /etc/sudoers << EOFdebianuser ALL=(ALL:ALL) ALLEOFchmod -w /etc/sudoersexit以上命令在
root身份下执行
sudo tee /etc/apt/sources.list <<-'EOF'deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-freedeb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-freedeb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-freedeb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-freeEOFsudo apt updatesudo apt upgradesudo apt dist-upgradesudo apt install vim wget curl htop git proxychains4 screenfetch tmux bash-completion fcitx5-rime chromium fcitx5-material-color zsh fonts-powerline fzf net-tools openssh-server firewalld bat chromium安装的软件包
| 包名 | 用途 |
|---|---|
| vim | 终端文本编辑器 |
| wget | 终端文件下载工具 |
| curl | 终端 URL 工具 |
| htop | 系统监控与进程管理工具 |
| git | 版本控制工具 |
| proxychains4 | 终端代理 |
| screenfetch | 在终端显示系统信息 |
| tmux | 终端复用器 |
| bash-completion | bash 自动补全 |
| fcitx5-rime | 基于 fcitx5 的 rime 输入法 |
| fcitx5-material-color | fcitx5 主题 |
| chromium | Chromium 浏览器 |
| zsh | 终端解释器 |
| fonts-powerline | powerline 字体 |
| fzf | 终端模糊搜索工具 |
| net-tools | 网络配置工具 |
| openssh-server | OpenSSH 服务器 |
| firewalld | 防火墙 |
| bat | 更强大的 cat 命令 |
主要卸载一些多语言支持和游戏包,可跳过
sudo apt remove --purge ibus* xterm goldendict fcitx fcitx-* anthy anthy-* mozc-* mlterm* xiterm+thai mariadb-commonsudo apt autoremove --purge注意:执行时请注意要卸载的软件包中是否存在类似 gnome 之类的系统包,如果存在请尝试手动一个一个卸载
sudo apt remove --purge ibus ibus-* xterm goldendict aisleriot evolution gnome-todo gnome-klotski gnome-tetravex gnome-chess gnome-maps gnome-mines gnome-taquin gnome-sudoku gnome-robots gnome-nibbles gnome-music gnome-mahjongg gnome-2048 hitori transmission-* quadrapassel lightsoff four-in-a-row tali swell-foop five-or-more iagno fcitx fcitx-* anthy anthy-* mozc-* mlterm mlterm-* xiterm+thaisudo apt autoremove --purge如果你的电脑存在无线网卡,并且在安装好操作系统之后发现无线网卡无法使用,请尝试如下步骤
sudo apt install firmware-iwlwifisudo modprobe -r iwlwifisudo modprobe iwlwifi如果你的电脑存在 Nvidia 显卡,并且在安装好操作系统之后发现显卡无法使用,请尝试如下步骤
sudo apt install nvidia-detectsudo nvidia-detect该步骤会根据硬件检测应该安装哪些驱动,请按照输出安装对应的驱动,例如提示 nvidia-driver
sudo apt install nvidia-driversudo tee /etc/tmux.conf <<-'EOF'set -g prefix C-aunbind C-bbind C-a send-prefixEOF从 GitHub - Fndroid/clash_for_windows_pkg 下载 CFW,注意下载 Clash.for.Windows-x.xx.x-x64-linux.tar.gz
将其解压到 /usr/local/cfw
tar zxvf Clash.for.Windows-0.19.5-x64-linux.tar.gz -C cfw --strip-components 1创建 ~/.local/share/applications/cfw.desktop 用于显示桌面图标
touch ~/.local/share/applications/cfw.desktoptee ~/.local/share/applications/cfw.desktop <<-'EOF'[Desktop Entry]Version=1.0Name=Clash For WindowsGenericName=Clash For WindowsComment=Clash For Windows for LinuxExec=/usr/local/cfw/cfwTerminal=falseType=ApplicationIcon=clashCategories=NetworkEOF仓库位于 GitHub - jarun/advcpmv,无需手动下载
wget http://ftp.gnu.org/gnu/coreutils/coreutils-9.0.tar.xztar Jxvf coreutils-9.0.tar.xzcd coreutils-9.0/wget https://raw.githubusercontent.com/jarun/advcpmv/master/advcpmv-0.9-9.0.patchpatch -p1 -i advcpmv-0.9-9.0.patch./configuremakesudo chmod +x ./src/cp ./src/mvsudo chown root. ./src/cp ./src/mvsudo mv ./src/cp /usr/local/bin/cpgsudo mv ./src/mv /usr/local/bin/mvg切换到 zsh
chsh -s /bin/zshsudo ln -s ~/.zshrc /root完成以上步骤后切换到 root 用户将自动为其配置 zsh, zinit 及 .zshrc 中配置的插件
sudo reboot下载 Google Chrome
下载 Microsoft Visual Studio Code
下载 JetBrains Toolbox App
下载 Go for Linux
下载 Nodejs LTS
sudo apt install ./google-chrome-stable_current_amd64.debsudo apt install ./code_xxx_amd64.debsudo apt remove --purge 'firefox-esr*'用于管理 JetBrains IDE
建议将 IDE 安装路径配置为 /usr/local/JetBrains
tar zxvf jetbrains-toolbox-xxx.tar.gz./jetbrains-toolbox-xxx/jetbrains-toolbox下载 GitHub - ja-netfilter/ja-netfilter,解压到 /usr/local/JetBrains/ja-netfilter
修改 config 中配置如下
[DNS]EQUAL,jetbrains.com[URL]PREFIX,https://account.jetbrains.com/lservice/rpc/validateKey.action[Result]EQUAL,120506319308405029943033101198259523557651500267734599270782782071425072541184605728867830395125412768750966448411447392137801711908001958831204692561738046570955709184538088569271703484602917023462976408329100293802371486063140115775311907530943821345005598057265747678100463689973450156515895355214983079672467769169324175533323801179755544364921063654340185317077965735659865485150734884110709760680757502730007505995422237875348017761382234951127263548660889969621730944377739766734765769747684457663965611896398862841334032542726392699785677440644859509166466497325071885386505404431787167239320957696896447925472784312642576835792921100239616617639216190447230487878404191838684279341834945197861631446454083984351911070798505031973496634229907567362853550735007045265430703581336189733180744888091740381912913980707537008943084904260746266383019688346709856215660232636334604552145129775009725685598798774376749830567219982166661918408832945395290223853748014160473876195098438959881711585152480525870219408398012002829112863175041709512032251930709608035158747101960447898838942705485214217426612863919268749874079707310181890737049603255938886865558759802593500502795018952114650332765839003032013708006750600413455628536259,65537,860106576952879101192782278876319243486072481962999610484027161162448933268423045647258145695082284265933019120714643752088997312766689988016808929265129401027490891810902278465065056686129972085119605237470899952751915070244375173428976413406363879128531449407795115913715863867259163957682164040613505040314747660800424242248055421184038777878268502955477482203711835548014501087778959157112423823275878824729132393281517778742463067583320091009916141454657614089600126948087954465055321987012989937065785013284988096504657892738536613208311013047138019418152103262155848541574327484510025594166239784429845180875774012229784878903603491426732347994359380330103328705981064044872334790365894924494923595382470094461546336020961505275530597716457288511366082299255537762891238136381924520749228412559219346777184174219999640906007205260040707839706131662149325151230558316068068139406816080119906833578907759960298749494098180107991752250725928647349597506532778539709852254478061194098069801549845163358315116260915270480057699929968468068015735162890213859113563672040630687357054902747438421559817252127187138838514773245413540030800888215961904267348727206110582505606182944023582459006406137831940959195566364811905585377246353->31872219281407242025505148642475109331663948030010491344733687844358944945421064967310388547820970408352359213697487269225694990179009814674781374751323403257628081559561462351695605167675284372388551941279783515209238245831229026662363729380633136520288327292047232179909791526492877475417113579821717193807584807644097527647305469671333646868883650312280989663788656507661713409911267085806708237966730821529702498972114194166091819277582149433578383639532136271637219758962252614390071122773223025154710411681628917523557526099053858210363406122853294409830276270946292893988830514538950951686480580886602618927728470029090747400687617046511462665469446846624685614084264191213318074804549715573780408305977947238915527798680393538207482620648181504876534152430149355791756374642327623133843473947861771150672096834149014464956451480803326284417202116346454345929350148770746553056995922154382822307758515805142704373984019252210715650875853634697920708113806880196144197384637328982263167395073688501517286678083973976140696077590122053014085412828620051470085033364773099146103525313018873319293728800442101520384088109603555959893639842091339193857485407672132882577840295039058621747654642202620767068924079813640067442975EQUAL,8028659553836119901593655311677865290672387540027895708985570867455842278776015838142490556122515317003830575671206217290165955723210315889275621408086645995280770696135307020454887097794294273869941097888549275028604248332746117479367032100139091095818169444690976206636597409322539276252570779516636180497560345090851316373570301807158645002654208816162902430571101092599540795501152368695431168224953320283502815852695423193526255836776240019085157444254721864134058745605280085897450952937893645487302683006269553010996013513395044612932182772364336368242146044741660443063207438830622376694839772096688572619877,65537,21052260334349247097390263197515551021430500095747078612475171670547647379514624742422155617118382403386162585789957995106937640909858927441120214136124618650916253946431099279059999234690271861285094667690686174087562943995337813383652323725628494261414287817117703355799303086256914782640807165021059760198249458510362432176960683009890989990086614909076853502936665842869163947730574085863127445475967466399017447434906719734480523659879746056728772390182338236187070557277461449143752467418310063647027554915213099799725713708651142505590086828211040619445941301844994775362846837122335522584661592447560060751169->986236757547332986472011617696226561292849812918563355472727826767720188564083584387121625107510786855734801053524719833194566624465665316622563244215340671405971599343902468620306327831715457360719532421388780770165778156818229863337344187575566725786793391480600129482653072861971002459947277805295727097226389568776499707662505334062639449916265137796823793276300221537201727072401742985542559596685092673521228140822200236743113743661549252453726123450722876929538747702356573783116197523966334991563351853851212597377279504828784687920949198341066450537230593608440475006386024448307924665012521692416658191在 .vmoptions 中写入
-javaagent:/usr/local/JetBrains/ja-netfilter/ja-netfilter.jar使用认证服务器授权
建议将 go 和 nodejs 分别安装到 /usr/local/go 和 /usr/local/nodejs 下
为 java 创建 /usr/local/java 目录,将各版本 jdk 统一解压到该目录下便于管理
sudo mkdir /usr/local/gosudo mkdir /usr/local/nodejssudo chown debianuser. -R /usr/local/gosudo chown debianuser. -R /usr/local/nodejstar zxvf Downloads/goxxxlinux-amd64.tar.gz -C /usr/local/go/ --strip-components=1tar Jxvf Downloads/node-v14.17.3-linux-x64.tar.xz -C /usr/local/nodejs/ --strip-components=1sudo tee /etc/zsh/zprofile <<-'EOF'export NODE_HOME='/usr/local/nodejs'export GOROOT='/usr/local/go'export GOPATH="$HOME/.go"export GOENV="$HOME/.config/go/env"export GOCACHE="$HOME/.cache/go-build"export JAVA_HOME='/usr/local/java/jdk-xxx'export PATH="$PATH:$NODE_HOME/bin"export PATH="$PATH:$GOROOT/bin"export PATH="$PATH:$JAVA_HOME/bin"EOFsource /etc/zsh/zprofile配置 Go Modules,Go 代理并切换 npm 源
go env -w GO111MODULE=ongo env -w GOPROXY=https://goproxy.cn,https://goproxy.io,directnpm config set registry https://registry.npmmirror.com/访问 MySQL Community Downloads 下载 APT 仓库管理包
由于 MySQL Workbench 依赖 Python 版本较高,MySQL 在 Debian 源中禁用了该包
访问 MySQL Product Archives 下载适用于 Ubuntu 18.04 的 8.0.22 安装包
sudo apt install ./Downloads/mysql-apt-config_xxx_all.debsudo apt updatesudo apt upgradesudo apt install mysql-serversudo systemctl start mysqlsudo systemctl enable mysqlsudo apt install ./Downloads/mysql-workbench-community_8.0.23-1ubuntu18.04_amd64.deb以下仅为推荐扩展,请根据自己的技术栈及个人喜好自行选择
Nordic darker KDENordic-darkerNordicBreeze 微风暗色Nordic Folders icon pack Mod双击打开文件和文件夹30 分钟0 秒Chili login theme for KDE PlasmaNordic-darker居中保留先前的搜索使用手动配置的代理服务器127.0.0.1 端口: 7890所有协议都使用同样的代理服务器30 分钟46最大化面板悬停任务时高亮窗口不分组来自当前屏幕显示秒24 小时制记住窗口大小140 列 30 行Nordic konsoleSarasa Term SC 10pt无限制访问 GNOME Shell Extensions 启用扩展
安装主题 GitHub - PapirusDevelopmentTeam/papirus-icon-theme
sudo sh -c "echo 'deb http://ppa.launchpad.net/papirus/papirus/ubuntu focal main' > /etc/apt/sources.list.d/papirus-ppa.list"sudo apt install dirmngrsudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com E58A9D36647CAE7Fsudo apt updatesudo apt install papirus-icon-theme127.0.0.1 7890127.0.0.1 7890127.0.0.1 789015 分钟30 分钟60 分钟休眠Terminalgnome-terminalCtrl + Alt + T轻拍以点击启用菜单快捷键140 列 30 行GNOME以亮色显示粗体字回滚限制笔记本电脑盖子关闭时挂起Adwaita-darkPapirus完全子像素顶部40 pxDesktop button4 px 6 px顶部指示器颜色 - 覆盖主题全部设置为白色为未取得焦点的程序使用不同方案全部设置为灰色覆盖面板主题背景不透明度60隔离工作区隔离显示器取消应用程序分组最大化最小化中间点击粘贴电池百分比日期秒.zshrc
CHANGE_LANG_NOGUI=true# apt install fonts-powerline# Download https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/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 installerif [[ ! -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"fisource '/etc/zsh/zprofile'source "$HOME/.local/share/zinit/zinit.git/zinit.zsh"autoload -Uz _zinit(( ${+_comps} )) && _comps[zinit]=_zinit### End of Zinit's installer chunkHISTFILE="$HOME/.zsh_history"HISTSIZE=10000SAVEHIST=10000setopt 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 fzfzinit ice depth='1' lucid wait='0' atload='_zsh_autosuggest_start'zinit light zsh-users/zsh-autosuggestionszinit ice depth='1' lucid wait='0'zinit light zsh-users/zsh-syntax-highlightingzinit ice depth='1'zinit light zsh-users/zsh-completionszinit ice depth='1'zinit light romkatv/powerlevel10kzinit ice lucid wait='0'zinit snippet OMZ::plugins/jsontools/jsontools.plugin.zshzinit ice lucid wait='0'zinit snippet OMZ::plugins/fzf/fzf.plugin.zshzinit ice lucid wait='0'zinit snippet OMZ::lib/completion.zshautoload -U compinit && compinit# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.if [ ${DISPLAY} ]; then [[ ! -f ~/.p10k.gui.zsh ]] || source ~/.p10k.gui.zshelse [[ ! -f ~/.p10k.terminal.zsh ]] || source ~/.p10k.terminal.zsh if [ ${CHANGE_LANG_NOGUI} ]; then export LC_ALL="en_US.UTF-8" fifialias ls='ls --color=auto'alias grep='grep --color=auto'alias ll='ls -lh'alias la='ls -A'alias l='ls -CF'alias cp='/usr/local/bin/cpg -g'alias mv='/usr/local/bin/mvg -g'alias cat='batcat --paging=never -p'Powerlevel10k 是 zsh 的主题,在 .zshrc 中我们声明了在桌面环境和终端环境下使用不同的 p10k 配置,即桌面环境使用图标更多更友好的终端主题配置,而在终端环境下使用更保守的终端主题配置以保证兼容性,以下为两个配置文件完整内容链接
p10k Config for GUI
p10k Config for Terminal