Ubuntu24.04LTS配置及美化

重置root密码

1
2
3
sudo su root
passwd root
exit

换源(使用24.04版本的不必要, 使用24.10或其他Bleeding Edge的不建议)

换源前请看清楚版本, 这里以24.04为例

  • 方法一: 使用命令行
1
sudo nano /etc/apt/sources.list.d/ubuntu.sources

加入(或改为)以下内容

1
2
3
4
5
6
7
8
9
10
11
Types: deb
URIs: https://mirrors.ustc.edu.cn/ubuntu
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

Types: deb
URIs: https://mirrors.ustc.edu.cn/ubuntu
Suites: noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

然后刷新软件包

1
sudo apt update && sudo apt upgrade -y
  • 方法二: 使用Ubuntu自带软件

打开Software & Updates, 确保这四个软件仓库都选中了

接下来服务器选择Other, 选择China再点击Select Best Server选择最佳镜像站点

更新系统

1
sudo apt update && sudo apt upgrade -y

加速Snap(配置选项等待验证)

1
2
sudo snap install snap-store-proxy snap-store-proxy-client
sudo snap refresh

安装解码器和微软字体

1
sudo apt install ubuntu-restricted-addons ubuntu-restricted-extras -y

添加中文(和日语)语言包

安装语言包和输入法

打开Language Support, 添加所需语言, 重启即可

重启后, 去设置添加中文智能拼音, 开启云拼音和词典, 和Manjaro一样

对于日文输入法, 安装后重启, 在设置添加, 并编辑~/.config/mozc/ibus_config.textproto修改active_on_launchTrue

重启输入法

1
ibus write-cache; ibus restart

修复字形

1
sudo gnome-text-editor /etc/fonts/conf.d/64-language-selector-cjk-prefer.conf

修改为

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
<family>sans-serif</family>
<prefer>
<family>Noto Sans CJK SC</family> <!-- 简体中文 -->
<family>Noto Sans CJK TC</family> <!-- 繁体中文 -->
<family>Noto Sans CJK HK</family> <!-- 香港繁体中文 -->
<family>Noto Sans CJK KR</family> <!-- 韩文 -->
<family>Noto Sans CJK JP</family> <!-- 日文 -->
</prefer>
</alias>
<alias>
<family>serif</family>
<prefer>
<family>Noto Serif CJK SC</family> <!-- 简体中文 -->
<family>Noto Serif CJK TC</family> <!-- 繁体中文 -->
<family>Noto Serif CJK HK</family> <!-- 香港繁体中文 -->
<family>Noto Serif CJK KR</family> <!-- 韩文 -->
<family>Noto Serif CJK JP</family> <!-- 日文 -->
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>Noto Sans Mono CJK SC</family> <!-- 简体中文 -->
<family>Noto Sans Mono CJK TC</family> <!-- 繁体中文 -->
<family>Noto Sans Mono CJK HK</family> <!-- 香港繁体中文 -->
<family>Noto Sans Mono CJK KR</family> <!-- 韩文 -->
<family>Noto Sans Mono CJK JP</family> <!-- 日文 -->
</prefer>
</alias>
</fontconfig>
1
fc-cache -f -v

配置代理

安装拓展

1
2
sudo apt install -y chrome-gnome-shell gnome-shell-extensions gnome-shell-ubuntu-extensions $(apt search gnome-shell-extension- | grep "gnome-shell-extension-" | awk -F '/' '{ print $1 }')
sudo reboot

其他可以在浏览器安装

配置拓展, 设置, 优化等和Manjaro大同小异

需要注意的是, ubuntu-dockdash-to-dock只能开一个

1
sudo apt install gnome-tweaks

美化终端

安装编程字体

1
2
3
4
5
cd
wget https://ghproxy.cn/https://github.com/ryanoasis/nerd-fonts/releases/download/v3.2.1/FiraCode.zip
unzip FiraCode.zip -d ~/.local/share/fonts
rm FiraCode.zip
fc-cache -fv

然后在gnome-terminal改成FiraCodeNerd字体即可

安装zsh

1
2
3
4
sudo apt install zsh
touch ~/.zshrc
chsh -s /usr/bin/zsh
reboot

安装p10k(主题)

1
2
3
4
sudo apt install git
git clone --depth=1 https://ghproxy.cn/https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
zsh

然后回答完所有问题即可

配置zsh

安装插件

1
2
3
4
5
6
sudo apt install zsh-autosuggestions zsh-syntax-highlighting
echo 'source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh' >> ~/.zshrc
echo 'source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh' >> ~/.zshrc
sudo git clone https://github.com/zsh-users/zsh-history-substring-search.git /usr/share/zsh-history-substring-search
echo 'source /usr/share/zsh-history-substring-search/zsh-history-substring-search.zsh' >> ~/.zshrc
source ~/.zshrc

额外配置

1
sudo apt install eza

把以下内容追加~/.zshrc文件的三个source后面

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
autoload -Uz run-help
(( ${+aliases[run-help]} )) && unalias run-help
alias help=run-help
autoload -Uz run-help-git run-help-ip run-help-openssl run-help-p4 run-help-sudo run-help-svk run-help-svn

autoload -Uz compinit promptinit
compinit
promptinit

HISTFILE=~/.zsh_history
HISTSIZE=1000
SAVEHIST=2000

TIMEFMT=$'\nreal\t%E\nuser\t%U\nsys\t%S\ncpu\t%P'

# Case-insensitive tab completion (match lower and upper case)
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}'
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'

# Use colors for completion listings (different colors for directories, files, etc.)
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"

# Enable rehash so new executables in the PATH are automatically found
zstyle ':completion:*' rehash true

# Enable menu selection (highlight options when navigating with tab)
zstyle ':completion:*' menu select

# Automatically accept exact matches in completion, even if partially typed
zstyle ':completion:*' accept-exact '*(N)'

# Enable caching for faster completion, and define the cache path
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache

# Add auto-description for completion items (shows additional information)
zstyle ':completion:*' auto-description 'specify: %d'

# Specify completion methods: first expand aliases, then complete commands
zstyle ':completion:*' completer _expand _complete

# Format the completion display with a message indicating what is being completed
zstyle ':completion:*' format 'Completing %d'

# Remove group names from completion listings
zstyle ':completion:*' group-name ''

# List prompt for showing how to navigate through completion options
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s

# Select prompt for scrolling through completion menu
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s

# Disable the use of older `compctl` completions (use new style completion)
zstyle ':completion:*' use-compctl false

# Enable verbose completion output
zstyle ':completion:*' verbose true

# Custom completion style for `kill` command, listing processes with detailed information
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'

# Set colors for the `kill` command completion (red color for process IDs)
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'

EDITOR=vim
alias c='clear'
alias nf='fastfetch'
alias pf='fastfetch'
alias ff='fastfetch'
alias ls='eza -a --icons'
alias ll='eza -al --icons'
alias lt='eza -a --tree --level=1 --icons'
alias shutdown='systemctl poweroff'
alias v='$EDITOR'
alias vim='$EDITOR'
alias wifi='nmtui'
alias Qtile='startx'
alias gs="git status"
alias ga="git add"
alias gc="git commit -m"
alias gp="git push"
alias gpl="git pull"
alias gst="git stash"
alias gsp="git stash; git pull"
alias gcheck="git checkout"
alias gcredential="git config credential.helper store"
alias update-grub='sudo grub-mkconfig -o /boot/grub/grub.cfg'
alias res1='xrandr --output DisplayPort-0 --mode 2560x1440 --rate 165'
alias res2='xrandr --output DisplayPort-0 --mode 1920x1080 --rate 165'
alias setkb='setxkbmap de;echo "Keyboard set back to de."'
alias cp="cp -i" # Confirm before overwriting something
alias df='df -h' # Human-readable sizes
alias free='free -m' # Show sizes in MB
alias gitu='git add . && git commit && git push'
alias history="history 0"
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias diff='diff --color=auto'
alias rm='rm -i'
alias ip='ip --color=auto'
alias la='ls -A'

setopt correct # Auto correct mistakes
setopt extendedglob # Extended globbing. Allows using regular expressions with *
setopt nocaseglob # Case insensitive globbing
setopt rcexpandparam # Array expension with parameters
setopt nocheckjobs # Don't warn about running processes when exiting
setopt numericglobsort # Sort filenames numerically when it makes sense
setopt nobeep # No beep
setopt appendhistory # Immediately append history instead of overwriting
setopt histignorealldups # If a new command is a duplicate, remove the older one
setopt autocd # if only directory path is entered, cd there.
setopt inc_append_history # save commands are added to the history immediately, otherwise only when shell exits.
setopt histignorespace # Don't save commands that start with space
setopt prompt_subst
setopt interactivecomments # allow comments in interactive mode
setopt magicequalsubst # enable filename expansion for arguments of the form ‘anything=expression’
setopt nonomatch # hide error message if there is no match for the pattern
setopt notify # report the status of background jobs immediately
setopt numericglobsort # sort filenames numerically when it makes sense
setopt promptsubst # enable command substitution in prompt
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
setopt hist_ignore_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space
setopt hist_verify # show command with history expansion to user before running it
#setopt share_history # share command history data

# Enable emacs key bindings
bindkey -e

# Essential key bindings
bindkey '^[[7~' beginning-of-line # Home key
bindkey '^[[8~' end-of-line # End key
bindkey '^[[2~' overwrite-mode # Insert key
bindkey '^[[3~' delete-char # Delete key
bindkey '^[[C' forward-char # Right arrow key
bindkey '^[[D' backward-char # Left arrow key
bindkey '^[[5~' history-beginning-search-backward # Page Up key
bindkey '^[[6~' history-beginning-search-forward # Page Down key
bindkey '^[[1;5C' forward-word # Ctrl + Right arrow (forward word)
bindkey '^[[1;5D' backward-word # Ctrl + Left arrow (backward word)

# Simplified undo and word deletion
bindkey '^[[Z' undo # Shift + Tab undo
bindkey '^H' backward-kill-word # Ctrl + Backspace
bindkey '^U' backward-kill-line # Ctrl + U
bindkey '^[[3;5~' kill-word # Ctrl + Delete

# History search with up/down keys
bindkey '^[[A' history-substring-search-up # Up arrow
bindkey '^[[B' history-substring-search-down # Down arrow

# Use terminfo for portability (optional, for special cases)
typeset -g -A key
key[Home]="${terminfo[khome]}"
key[End]="${terminfo[kend]}"
key[Insert]="${terminfo[kich1]}"
key[Delete]="${terminfo[kdch1]}"
key[Up]="${terminfo[kcuu1]}"
key[Down]="${terminfo[kcud1]}"
key[Left]="${terminfo[kcub1]}"
key[Right]="${terminfo[kcuf1]}"
key[PageUp]="${terminfo[kpp]}"
key[PageDown]="${terminfo[knp]}"

# Use lesspipe for better handling of non-text files
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
ZSH_HIGHLIGHT_STYLES[default]=none
ZSH_HIGHLIGHT_STYLES[unknown-token]=underline
ZSH_HIGHLIGHT_STYLES[reserved-word]=fg=cyan,bold
ZSH_HIGHLIGHT_STYLES[suffix-alias]=fg=green,underline
ZSH_HIGHLIGHT_STYLES[global-alias]=fg=green,bold
ZSH_HIGHLIGHT_STYLES[precommand]=fg=green,underline
ZSH_HIGHLIGHT_STYLES[commandseparator]=fg=blue,bold
ZSH_HIGHLIGHT_STYLES[autodirectory]=fg=green,underline
ZSH_HIGHLIGHT_STYLES[path]=bold
ZSH_HIGHLIGHT_STYLES[path_pathseparator]=
ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]=
ZSH_HIGHLIGHT_STYLES[globbing]=fg=blue,bold
ZSH_HIGHLIGHT_STYLES[history-expansion]=fg=blue,bold
ZSH_HIGHLIGHT_STYLES[command-substitution]=none
ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]=fg=magenta,bold
ZSH_HIGHLIGHT_STYLES[process-substitution]=none
ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]=fg=magenta,bold
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=fg=green
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=fg=green
ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=none
ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]=fg=blue,bold
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]=fg=yellow
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=fg=yellow
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]=fg=yellow
ZSH_HIGHLIGHT_STYLES[rc-quote]=fg=magenta
ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]=fg=magenta,bold
ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]=fg=magenta,bold
ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]=fg=magenta,bold
ZSH_HIGHLIGHT_STYLES[assign]=none
ZSH_HIGHLIGHT_STYLES[redirection]=fg=blue,bold
ZSH_HIGHLIGHT_STYLES[comment]=fg=black,bold
ZSH_HIGHLIGHT_STYLES[named-fd]=none
ZSH_HIGHLIGHT_STYLES[numeric-fd]=none
ZSH_HIGHLIGHT_STYLES[arg0]=fg=cyan
ZSH_HIGHLIGHT_STYLES[bracket-error]=fg=red,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=fg=blue,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=fg=green,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-3]=fg=magenta,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-4]=fg=yellow,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-5]=fg=cyan,bold
ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]=standout

# Color man pages
export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline

再输入source ~/.zshrc即可

安装vscode

1
2
3
4
wget "https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64" -O code.deb
mv code.deb /tmp
cd /tmp
sudo apt install ./code.deb

修复鼠标指针、Qt主题问题

1
2
3
4
5
sudo snap install bibata-modern-ice-cursor # 示例鼠标指针主题
sudo apt install bibata-cursor-theme
# sudo apt install papirus-icon-theme bibata-cursor-theme orchis-gtk-theme && sudo snap install bibata-modern-ice-cursor bibata-all-cursor gtk-theme-orchis orchis-themes
ln --symbolic /snap/bibata-modern-ice-cursor/8/share/icons/Bibata-Modern-Ice ~/.local/share/icons/default
for plug in $(snap connections | grep gtk-common-themes:icon-themes | awk '{print $2}'); do sudo snap connect ${plug} bibata-all-cursor:icon-themes; done # 每次安装完snap应用都执行一下
1
2
echo 'QT_STYLE_OVERRIDE=kvantum' | sudo tee -a /etc/environment
sudo apt install qt6-style-kvantum qt6-style-kvantum-l10n qt6-style-kvantum-themes

然后打开kvantum-manager设置主题即可

最终的/etc/environment文件可能长这样

1
2
3
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/yoimiya/Downloads/clion-2024.2.3/bin:/home/yoimiya/Downloads/RustRover-2024.2.4/bin:/home/yoimiya/.local/bin:"

QT_STYLE_OVERRIDE=kvantum

强制使用x11, 则使用env QT_QPA_PLATFORM=xcb python3 main.py
Qt应用程序可用选项举例./PythagoreanTriple -style=adwaita qt6ct -style=kvantum env QT_SCALE_FACTOR=1.25 kate env QT_FONT_DPI=96 kate
Qt应用程序其他选项QT_AUTO_SCREEN_SCALE_FACTOR=1 QT_SCALE_FACTOR=1.5
Java应用程序缩放问题java -jar -Dglass.gtk.uiScale=150% xxx.jar

开启可变刷新率(VRR)

1
2
gsettings set org.gnome.mutter experimental-features "['variable-refresh-rate', 'kms-modifiers', 'autoclose-xwayland']"
sudo reboot

文件极速查找工具

1
2
3
4
sudo apt install plocate
sudo updatedb
# sudo updatedb -U /path
locate something

图形化软件包管理器

1
sudo apt install synaptic

更新系统

1
echo 'alias update="sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y && sudo apt autoclean -y && sudo snap refresh"' >> ~/.zshrc

磁盘空间查看器

1
2
sudo apt install filelight
sudo apt install qml-module-qtquick-shapes

修复NTFS磁盘无法挂载

1
2
sudo lsblk
sudo ntfsfix --clear-dirty /dev/nvme0n1p4

把桌面换成KDE

1
sudo apt install kubuntu-desktop

然后自行卸载安装输入法

增大vm.max_map_count以提升游戏体验

1
echo 'vm.max_map_count = 2147483642' | sudo tee /etc/sysctl.d/80-gamecompatibility.conf

玩原神(参考b站up@GTX4090TI)

1
2
sudo apt install wine winetricks 
winetricks # 安装字体、dxvk、vkd3d、vcrun2022等组件

屏蔽hosts

1
sudo vim /etc/hosts

加入以下内容

1
2
3
4
5
6
7
8
9
1.1.1.1 log-upload-os.mihoyo.com
1.1.1.1 overseauspider.yuanshen.com
1.1.1.1 log-upload.mihoyo.com
1.1.1.1 uspider.yuanshen.com
1.1.1.1 dispatchcnglobal.yuanshen.com
1.1.1.1 ys-log-upload.mihoyo.com
1.1.1.1 apm-log-upload.mihoyo.com
1.1.1.1 ad-log-upload.mihoyo.com
1.1.1.1 devlog-log-upload.mihoyo.com

写脚本

1
WINEARCH="win64" bash -c "wine '/media/yoimiya/Data/Program Files/Genshin Impact/Genshin Impact Game/YuanShen.exe' --  -window-mode exclusive -platform_type CLOUD_THIRD_PARTY_PC"

玩星铁

安装配置wine和上面相同

下载补丁

修改hosts

1
sudo vim /etc/hosts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Honkai Impact 3rd analytics servers (glb/sea/tw/kr/jp):
0.0.0.0 log-upload-os.hoyoverse.com
0.0.0.0 sg-public-data-api.hoyoverse.com
0.0.0.0 dump.gamesafe.qq.com

# Honkai Impact 3rd analytics servers (cn):
0.0.0.0 log-upload.mihoyo.com
0.0.0.0 public-data-api.mihoyo.com
0.0.0.0 dump.gamesafe.qq.com


# Honkai Star Rail analytics servers (os)
0.0.0.0 log-upload-os.hoyoverse.com
0.0.0.0 sg-public-data-api.hoyoverse.com

# Honkai Star Rail analytics servers (cn)
0.0.0.0 log-upload.mihoyo.com
0.0.0.0 public-data-api.mihoyo.com

写脚本

1
WINEARCH="win64" bash -c "wine 'path/to/patch.exe' '/media/yoimiya/Data/Program Files/Star Rail/Game/StarRail.exe' --  -window-mode exclusive "

补充说明

  • 音视频、图像格式转换,压缩,处理sudo apt install ffmpeg imagemagick

  • 网页视频下载器

    1
    sudo apt install yt-dlp

    可以使用脚本传入选项

    1
    2
    #! /bin/sh
    yt-dlp --cookies-from-browser firefox "$@"
  • matlab内存不足
    输入命令sudo echo > /etc/security/limits.d/systemd.conf "* hard nofile 65536"


Ubuntu24.04LTS配置及美化
https://rukkhadevata123.github.io/2024/10/13/ubuntu/
作者
Dawn Chirps
发布于
2024年10月13日
许可协议