Debian 11 configuration optimization guide

Posted by beemzet on Fri, 04 Mar 2022 09:10:15 +0100

Original address: Debian 11 configuration optimization guide - WindSpiritIT

0x00 introduction

This article applies only to configuring Debian 11 Bullseye

The article includes both Gnome desktop and KDE desktop configurations, most of which are the same, and the differences are listed separately

The update of Gnome desktop related configuration lags behind and may not be updated again

The KDE and Gnome optimized configuration parts should be configured according to your personal preferences

In this article, debianuser is used instead of user name. Please pay attention to replacement when executing commands or copying configurations

For the software package / environment with version number involved in the article, the version number is replaced by xxx. Please install the latest version or the version you need according to the actual situation

The editing time of this article is too long from the practice time, and inaccurate contents may appear in the editing process. If you find any inconsistency with this article in your time process, please leave a message in the comment area as far as possible, and I will confirm the update as soon as possible

0x01 basic configuration

Most operations in this step need to be restarted, so do not judge the configuration of the application according to whether the application can be used normally after the configuration is completed

At the end of this step, all configurations are applied once

Rename the folder in / home directory in English

cd ~
mkdir Desktop Download Templates Public Documents Music Pictures Videos
rm -rf Public template video picture document download music desktop
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

Add users to sudoers

In this step, you need to switch to root first. There are two schemes

  1. Switch to the new tty

    Ctrl + Alt + F3 switch to the new terminal of the pure command line interface and log in as root for operation

    After that, use exit to exit the terminal and press Ctrl + Alt + F1/F2 to switch back to the user identity graphical interface

  2. Via SSH

    ssh root@localhost
    

    After that, use exit to exit the terminal

The following commands are executed as root

chmod +w /etc/sudoers
cat >> /etc/sudoers << EOF
debianuser ALL=(ALL:ALL) ALL
EOF
chmod -w /etc/sudoers
exit

The above commands are executed as root

Replace software source

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-free
deb 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-free

deb 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-free

deb 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-free
EOF
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade

Configure basic software package

sudo 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

Installed packages

Package namepurpose
vimTerminal text editor
wgetTerminal file download tool
curlTerminal URL tool
htopSystem monitoring and process management tools
gitVersion control tool
proxychains4Terminal agent
screenfetchDisplay system information at the terminal
tmuxTerminal Multiplexer
bash-completionbash automatic completion
fcitx5-rimeRim input method based on fcitx5
fcitx5-material-colorfcitx5 theme
chromiumChromium browser
zshTerminal interpreter
fonts-powerlinepowerline font
fzfTerminal fuzzy search tool
net-toolsNetwork configuration tool
openssh-serverOpenSSH server
firewalldfirewall
batMore powerful cat command

Uninstall useless packages

It mainly uninstalls some multilingual support and game packages, which can be skipped

KDE

sudo apt remove --purge ibus* xterm goldendict fcitx fcitx-* anthy anthy-* mozc-* mlterm* xiterm+thai mariadb-common
sudo apt autoremove --purge

Gnome

Note: during execution, please pay attention to whether there are system packages such as gnome in the software package to be uninstalled. If so, please try to uninstall one by one manually

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+thai
sudo apt autoremove --purge

Wireless network card driver

If your computer has a wireless network card and you find that the wireless network card cannot be used after installing the operating system, please try the following steps

sudo apt install firmware-iwlwifi
sudo modprobe -r iwlwifi
sudo modprobe iwlwifi

Nvidia graphics card driver

If you have a Nvidia video card on your computer and find that the video card cannot be used after installing the operating system, please try the following steps

sudo apt install nvidia-detect
sudo nvidia-detect

This step will detect which drivers should be installed according to the hardware. Please install the corresponding drivers according to the output, for example, prompt NVIDIA driver

sudo apt install nvidia-driver

tmux shortcut key

sudo tee /etc/tmux.conf <<-'EOF'
set -g prefix C-a
unbind C-b
bind C-a send-prefix
EOF

Install Clash for Windows

from GitHub - Fndroid/clash_for_windows_pkg Download, grab.CFW for. Windows-x.xx. x-x64-linux. tar. gz

Unzip it to / usr/local/cfw

tar zxvf Clash.for.Windows-0.19.5-x64-linux.tar.gz -C cfw --strip-components 1

Create ~ / local/share/applications/cfw.desktop is used to display desktop icons

touch ~/.local/share/applications/cfw.desktop
tee ~/.local/share/applications/cfw.desktop <<-'EOF'
[Desktop Entry]
Version=1.0
Name=Clash For Windows
GenericName=Clash For Windows
Comment=Clash For Windows for Linux
Exec=/usr/local/cfw/cfw
Terminal=false
Type=Application
Icon=clash
Categories=Network
EOF

Configuring Advanced Copy

The warehouse is located in GitHub - jarun/advcpmv , no manual download required

wget http://ftp.gnu.org/gnu/coreutils/coreutils-9.0.tar.xz
tar Jxvf coreutils-9.0.tar.xz
cd coreutils-9.0/
wget https://raw.githubusercontent.com/jarun/advcpmv/master/advcpmv-0.9-9.0.patch
patch -p1 -i advcpmv-0.9-9.0.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

Configure ZSH

Switch to zsh

chsh -s /bin/zsh
sudo ln -s ~/.zshrc /root

After completing the above steps, switch to root and the user will automatically configure zsh, zinit and Plug ins configured in zshrc

restart

sudo reboot

0x02 install application

download Google Chrome

download Microsoft Visual Studio Code

download JetBrains Toolbox App

download Go for Linux

download Nodejs LTS

sudo apt install ./google-chrome-stable_current_amd64.deb
sudo apt install ./code_xxx_amd64.deb
sudo apt remove --purge 'firefox-esr*'

JetBrains Toolbox

IDE for managing JetBrains

It is recommended to configure the IDE installation path as / usr/local/JetBrains

tar zxvf jetbrains-toolbox-xxx.tar.gz
./jetbrains-toolbox-xxx/jetbrains-toolbox

download GitHub - ja-netfilter/ja-netfilter , unzip to / usr / local / JetBrains / JA Netfilter

Modify the configuration in config as follows

[DNS]
EQUAL,jetbrains.com
[URL]
PREFIX,https://account.jetbrains.com/lservice/rpc/validateKey.action
[Result]
EQUAL,120506319308405029943033101198259523557651500267734599270782782071425072541184605728867830395125412768750966448411447392137801711908001958831204692561738046570955709184538088569271703484602917023462976408329100293802371486063140115775311907530943821345005598057265747678100463689973450156515895355214983079672467769169324175533323801179755544364921063654340185317077965735659865485150734884110709760680757502730007505995422237875348017761382234951127263548660889969621730944377739766734765769747684457663965611896398862841334032542726392699785677440644859509166466497325071885386505404431787167239320957696896447925472784312642576835792921100239616617639216190447230487878404191838684279341834945197861631446454083984351911070798505031973496634229907567362853550735007045265430703581336189733180744888091740381912913980707537008943084904260746266383019688346709856215660232636334604552145129775009725685598798774376749830567219982166661918408832945395290223853748014160473876195098438959881711585152480525870219408398012002829112863175041709512032251930709608035158747101960447898838942705485214217426612863919268749874079707310181890737049603255938886865558759802593500502795018952114650332765839003032013708006750600413455628536259,65537,860106576952879101192782278876319243486072481962999610484027161162448933268423045647258145695082284265933019120714643752088997312766689988016808929265129401027490891810902278465065056686129972085119605237470899952751915070244375173428976413406363879128531449407795115913715863867259163957682164040613505040314747660800424242248055421184038777878268502955477482203711835548014501087778959157112423823275878824729132393281517778742463067583320091009916141454657614089600126948087954465055321987012989937065785013284988096504657892738536613208311013047138019418152103262155848541574327484510025594166239784429845180875774012229784878903603491426732347994359380330103328705981064044872334790365894924494923595382470094461546336020961505275530597716457288511366082299255537762891238136381924520749228412559219346777184174219999640906007205260040707839706131662149325151230558316068068139406816080119906833578907759960298749494098180107991752250725928647349597506532778539709852254478061194098069801549845163358315116260915270480057699929968468068015735162890213859113563672040630687357054902747438421559817252127187138838514773245413540030800888215961904267348727206110582505606182944023582459006406137831940959195566364811905585377246353->31872219281407242025505148642475109331663948030010491344733687844358944945421064967310388547820970408352359213697487269225694990179009814674781374751323403257628081559561462351695605167675284372388551941279783515209238245831229026662363729380633136520288327292047232179909791526492877475417113579821717193807584807644097527647305469671333646868883650312280989663788656507661713409911267085806708237966730821529702498972114194166091819277582149433578383639532136271637219758962252614390071122773223025154710411681628917523557526099053858210363406122853294409830276270946292893988830514538950951686480580886602618927728470029090747400687617046511462665469446846624685614084264191213318074804549715573780408305977947238915527798680393538207482620648181504876534152430149355791756374642327623133843473947861771150672096834149014464956451480803326284417202116346454345929350148770746553056995922154382822307758515805142704373984019252210715650875853634697920708113806880196144197384637328982263167395073688501517286678083973976140696077590122053014085412828620051470085033364773099146103525313018873319293728800442101520384088109603555959893639842091339193857485407672132882577840295039058621747654642202620767068924079813640067442975
EQUAL,8028659553836119901593655311677865290672387540027895708985570867455842278776015838142490556122515317003830575671206217290165955723210315889275621408086645995280770696135307020454887097794294273869941097888549275028604248332746117479367032100139091095818169444690976206636597409322539276252570779516636180497560345090851316373570301807158645002654208816162902430571101092599540795501152368695431168224953320283502815852695423193526255836776240019085157444254721864134058745605280085897450952937893645487302683006269553010996013513395044612932182772364336368242146044741660443063207438830622376694839772096688572619877,65537,21052260334349247097390263197515551021430500095747078612475171670547647379514624742422155617118382403386162585789957995106937640909858927441120214136124618650916253946431099279059999234690271861285094667690686174087562943995337813383652323725628494261414287817117703355799303086256914782640807165021059760198249458510362432176960683009890989990086614909076853502936665842869163947730574085863127445475967466399017447434906719734480523659879746056728772390182338236187070557277461449143752467418310063647027554915213099799725713708651142505590086828211040619445941301844994775362846837122335522584661592447560060751169->986236757547332986472011617696226561292849812918563355472727826767720188564083584387121625107510786855734801053524719833194566624465665316622563244215340671405971599343902468620306327831715457360719532421388780770165778156818229863337344187575566725786793391480600129482653072861971002459947277805295727097226389568776499707662505334062639449916265137796823793276300221537201727072401742985542559596685092673521228140822200236743113743661549252453726123450722876929538747702356573783116197523966334991563351853851212597377279504828784687920949198341066450537230593608440475006386024448307924665012521692416658191

Yes Write in vmoptions

-javaagent:/usr/local/JetBrains/ja-netfilter/ja-netfilter.jar

use Authentication server to grant authorization

Go & NodeJS & Java

It is recommended to install go and nodejs under / usr/local/go and / usr/local/nodejs respectively

Create / usr/local/java directory for java, and unzip all versions of jdk to this directory for management

sudo mkdir /usr/local/go
sudo mkdir /usr/local/nodejs
sudo chown debianuser. -R /usr/local/go
sudo chown debianuser. -R /usr/local/nodejs
tar zxvf Downloads/goxxxlinux-amd64.tar.gz -C /usr/local/go/ --strip-components=1
tar Jxvf Downloads/node-v14.17.3-linux-x64.tar.xz -C /usr/local/nodejs/ --strip-components=1
sudo 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"
EOF
source /etc/zsh/zprofile

Configure Go Modules, Go agents and switch npm sources

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct
npm config set registry https://registry.npmmirror.com/

Install MySQL Server and MySQL Workbench

visit MySQL Community Downloads Download APT warehouse management package

Since MySQL Workbench relies on a higher Python version, MySQL has disabled this package in the Debian source

visit MySQL Product Archives Download the 8.0.22 installation package for Ubuntu 18.04

sudo apt install ./Downloads/mysql-apt-config_xxx_all.deb
sudo apt update
sudo apt upgrade
sudo apt install mysql-server
sudo systemctl start mysql
sudo systemctl enable mysql
sudo apt install ./Downloads/mysql-workbench-community_8.0.23-1ubuntu18.04_amd64.deb

Install VSCode extension

The following are only recommended extensions. Please choose according to your own technology stack and personal preferences

  • Chinese (Simplified) Language Pack for Visual Studio Code
  • Markdown All in One
  • Markdown Preview Enhanced
  • markdownlint
  • Remote Development
  • Todo Tree
  • ESLint
  • Python
  • C/C++

0x03 KDE Desktop Optimization

System settings

  • appearance
    • Global theme
      • Get a new global theme: Nordic darker KDE
    • Plasma style: Nordic darker
    • Application style
      • Window decoration: Nordic
    • Color: Breeze dark
    • Icon
      • Get new icon theme: Nordic Folders icon pack Mod
  • work area
    • Workspace behavior
      • Routine behavior
        • Click behavior: double click to open files and folders
      • Lock screen
        • Auto lock screen: if idle for 30 minutes
        • How long does it take to unlock the screen with a password: 0 seconds
    • Powering on
      • Login screen (SDDM)
        • Get new login screen: Chili login theme for KDE Plasma
      • Welcome screen: Nordic darker
    • search
      • KRunner
        • Position on screen: Center
        • Turn off keep previous searches
  • network
    • Network settings
      • agent
        • Select a proxy server that is configured manually
        • HTTP proxy: 127.0.0.1 port: 7890
        • Open all protocols using the same proxy server
  • Hardware
    • Power management
      • energy conservation
        • Screen energy saving: wait 30 minutes before turning off

Panel configuration

  • Panel height: 46
  • Add margins on both sides of the task manager
  • More options
    • Open the maximize panel
  • Icon Task Manager
    • appearance
      • Highlight window when hovering task is opened
    • behavior
      • Grouping: no grouping
      • Show only tasks: open from the current screen
  • Digital clock
    • appearance
      • Turn on display for seconds
      • Time display: 24-hour system

Konsol configuration

  • routine
    • Close remember window size
  • Configuration scheme
    • routine
      • Initial terminal size: 140 columns and 30 rows
    • appearance
      • Color scheme and font
        • Get new: Nordic konsol
      • Font: Sarasa Term SC 10pt
    • roll
      • Rollback: Unlimited

0x04 Gnome desktop optimization

Install Gnome extensions

visit GNOME Shell Extensions Enable extension

  • Alternatetab
  • AppIndicator and KStatusNotifierItem Support
  • Dash to panel
  • User themes

Install theme 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 dirmngr
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com E58A9D36647CAE7F
sudo apt update
sudo apt install papirus-icon-theme

Gnome system settings

  • network
    • Network agent
      • Manual
        • HTTP proxy: 127.0.0.1 7890
        • HTTPS proxy: 127.0.0.1 7890
        • Socks host: 127.0.0.1 7890
  • Power Supply
    • Rest screen: 15 minutes
    • Auto suspend
      • Delay when using battery: 30 minutes
      • Plugged in delay: 60 minutes
      • Power button behavior: sleep
  • Keyboard shortcuts
    • add to
      • Name: Terminal
      • Command: Gnome terminal
      • Shortcut keys: Ctrl + Alt + T
  • Mouse and touchpad: open tap to click

Gnome terminal settings

  • Profile preferences
    • General shortcut key: enable close
    • Unnamed
      • text
        • Terminal starting size 140 columns and 30 rows
      • colour
        • palette
          • Built in solution: GNOME
          • Turns on bold text in bright colors
      • Scrolling: turn off rollback restrictions

Gnome optimized configuration

  • General: close the laptop and hang when the cover is closed
  • appearance
    • Application: adwaita dark
    • Icon: Papirus
  • typeface
    • Fine tuning: complete
    • Antialiasing: subpixels
  • extend
    • Dash to Panel
      • position
        • Panel screen position: Top
        • Panel thickness: 40 px
        • Close Desktop button
      • style
        • Application icon edge blank: 4 px 6 px
        • Running indicator position: Top
        • Run indicator style options
          • Turn on indicator color - override theme
            • Set all to white
          • Open and use different schemes for programs that do not get focus
            • Set all to gray
        • Open overlay panel theme background opacity
          • Panel background opacity 60
      • behavior
        • Open quarantine workspace
        • Turn on the isolation display
        • Open ungroup application
  • Window title bar
    • Turn on maximize
    • Open minimize
  • Keyboard and mouse: close the middle click Paste
  • Top bar
    • Percentage of battery on
    • Opening date
    • Open seconds

0x05 ZSH configuration reference

.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 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/.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
   [[ ! -f ~/.p10k.terminal.zsh ]] || source ~/.p10k.terminal.zsh
   if [ ${CHANGE_LANG_NOGUI} ]; then
       export LC_ALL="en_US.UTF-8"
   fi
fi

alias 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 configuration

Powerlevel 10K is the theme of zsh In zshrc, we declare that different p10k configurations are used in desktop environment and terminal environment, that is, more and more friendly terminal theme configurations are used in desktop environment, while more conservative terminal theme configurations are used in terminal environment to ensure compatibility. The following is the complete content link of the two configuration files

p10k Config for GUI

p10k Config for Terminal

Topics: Linux debian