@@ -12,19 +12,29 @@ icon: material/puzzle
1212
1313下面就来介绍如何手动安装桌面环境。
1414
15- 以在 Ubuntu Server 18 .04.3 (未包含图形环境的系统) 上安装桌面环境为例。只需要执行以下步骤:
15+ 以在 Ubuntu Server 24 .04(未包含图形环境) 上安装桌面环境为例。只需要执行以下步骤:
1616
17- 安装 ` ubuntu-gnome- desktop ` 软件:
17+ 安装 ` ubuntu-desktop ` 软件:
1818
1919``` console
20- $ sudo apt install ubuntu-gnome- desktop
20+ $ sudo apt install ubuntu-desktop
2121```
2222
2323接下来的提示中按输入 Y 回车即安装。
2424
2525!!! tip "注意"
2626
27- 若安装非常缓慢,可以尝试更换国内的软件源。[科大源更换教程](https://mirrors.ustc.edu.cn/help/ubuntu.html)
27+ 若安装非常缓慢,可以尝试更换国内的软件源,参考[科大源更换教程](https://mirrors.ustc.edu.cn/help/ubuntu.html)。
28+
29+ !!! tip "减小安装大小"
30+
31+ 如果你觉得 `ubuntu-desktop` 安装的包过大,可以选择安装 `ubuntu-desktop-minimal`,它只包含最基本的 GNOME 桌面环境,安装包更小。
32+
33+ 如果你很熟悉桌面环境与软件包的关系,还可以添加 `--no-install-recommends` 选项来进一步减小安装大小,例如:
34+
35+ ```console
36+ $ sudo apt install --no-install-recommends ubuntu-desktop-minimal
37+ ```
2838
2939安装完成后输入:
3040
@@ -47,9 +57,11 @@ $ sudo reboot
4757 $ sudo reboot
4858 ```
4959
50- ## GNOME 相关
60+ ## 桌面环境个性化 {#desktop-personalization}
61+
62+ ### GNOME
5163
52- ### GNOME 桌面环境的个性化 {#gnome-personalization }
64+ #### GNOME 主题 {#gnome-themes }
5365
5466大部分桌面环境都支持主题的个性化。例如:窗口样式,按钮样式,Dock 样式,指针样式等等。
5567
@@ -102,15 +114,13 @@ $ gnome-tweaks
102114
103115GNOME 支持很多扩展,并且有一个专门用于扩展的网站:< https://extensions.gnome.org/ > 。
104116
105- 要使用 GNOME 扩展,我们要先安装 ` gnome-shell-extensions ` 。
117+ 要使用 GNOME 扩展,我们要先安装下面的软件包:
106118
107119``` console
108- $ sudo apt install gnome-shell-extensions
120+ $ sudo apt install gnome-shell-extensions gnome-shell-extension-prefs
109121```
110122
111- 接下来进入扩展插件的网站并选择其中一款扩展:
112-
113- Caffeine: 允许用户停用系统屏幕保护和自动休眠。
123+ 接下来进入扩展插件的网站并选择其中一款扩展:[ Caffeine: 允许用户停用系统屏幕保护和自动休眠。] ( https://extensions.gnome.org/extension/517/caffeine/ )
114124
115125![ Caffeine extension] ( images/caffeine.png )
116126
@@ -120,31 +130,26 @@ Caffeine: 允许用户停用系统屏幕保护和自动休眠。
120130$ gnome-shell --version
121131```
122132
123- 在插件网页中下载对应版本的压缩包并解压到一个文件夹。
124-
125- 这时我们打开文件夹里的 ` metadata.json ` 文件。
126-
127- 然后将文件夹的名字改为 ` metadata.json ` 中的 UUID:
133+ 在插件网页中下载对应版本的压缩包,然后:
128134
129- ![ Extension metadata] ( images/metadata.png )
130-
131- 132-
133- ![ Extension folder] ( images/caffeine-folder.png )
135+ ``` console
136+ $ # 假设下载的文件名为 caffeinepatapon.info.v58.shell-extension.zip
137+ $ gnome-extensions install ./caffeinepatapon.info.v58.shell-extension.zip
138+ ```
134139
135- 并将该文件夹放到 ` ~/.local/share/gnome-shell/extensions/ ` 中 。
140+ 扩展会被安装到 ` ~/.local/share/gnome-shell/extensions/ ` 目录下。这样安装的扩展只会在注销再登录之后才会展示,同时会被自动激活 。
136141
137- 打开 ` gnome-tweaks ` 。
142+ 也有图形界面可以管理扩展。 打开 ` gnome-extensions-app ` :
138143
139144``` console
140- $ gnome-tweaks
145+ $ gnome-extensions-app
141146```
142147
143- 在扩展一栏即可启用我们刚刚装的 caffeine 。
148+ 这里可以看到已经安装的扩展,点击开关即可启用或禁用扩展 。
144149
145150![ Enable GNOME extensions] ( images/gnome-extensions.png )
146151
147- !!! tip "提示 "
152+ !!! tip "其他安装方法 "
148153
149154 手动安装显然过于复杂,我们完全可以只使用浏览器来完成扩展插件的管理和安装。
150155
@@ -164,7 +169,15 @@ $ gnome-tweaks
164169
165170 
166171
167- ## Xfce 联网下载安装更多主题 {#xfce-themes}
172+ 同时也可以使用 `gnome-shell-extension-manager` 软件来管理扩展:
173+
174+ ```console
175+ $ sudo apt install gnome-shell-extension-manager
176+ ```
177+
178+ 这是一款[第三方开发](https://github.com/mjakeman/extension-manager)的 GNOME 扩展管理工具,功能更强大。
179+
180+ ### Xfce
168181
169182除了系统自带的外观样式和图标外,网络上有更多的主题提供下载。例如在 [ Xfce-look] ( https://www.xfce-look.org/ ) 上,就有上万个不同类型的主题。安装方法也十分简单。
170183
@@ -222,11 +235,22 @@ $ gnome-tweaks
222235$ echo $SHELL
223236```
224237
225- 检查目前我们正在用的是什么 Shell。Ubuntu 默认使用 Bash,在这里推荐一个更加强大的 Shell 工具——Z shell(Zsh)。
238+ 检查目前我们正在用的是什么 Shell。Ubuntu 默认使用 Bash,但是可以使用 ` chsh ` 命令来更换 Shell。
239+
240+ ``` console
241+ $ # 列出系统中可用的 shell
242+ $ chsh -l
243+ $ # 更换到 zsh
244+ $ chsh -s /bin/zsh
245+ $ # 更换到 fish
246+ $ chsh -s /bin/fish
247+ $ # 更换回 bash
248+ $ chsh -s /bin/bash
249+ ```
226250
227- #### Zsh
251+ ### Zsh 与 oh-my-zsh {#zsh-ohmyzsh}
228252
229- 首先通过 apt 安装 ` zsh ` :
253+ Z shell(Zsh)是一个功能强大的 shell。 首先通过 apt 安装 ` zsh ` :
230254
231255``` console
232256$ sudo apt install zsh
@@ -238,15 +262,7 @@ $ sudo apt install zsh
238262$ chsh -s /bin/zsh
239263```
240264
241- 重启后打开终端就会发现 shell 已经变成了 zsh。
242-
243- 第一次打开 zsh 会有首次使用提示,这里我们按 0 跳过。
244-
245- 接下来的提示中按 Y 回车即安装。
246-
247- 然而这时的 zsh 仍然是黑底白字,要让它变好看,我们需要对 zsh 进行配置。
248-
249- ##### oh-my-zsh
265+ 重启后打开终端就会发现 shell 已经变成了 zsh。然而这时的 zsh 仍然是黑底白字,要让它变好看,我们需要对 zsh 进行配置。
250266
251267oh-my-zsh 是一个管理 zsh 配置的框架,评价也非常好。
252268
@@ -276,77 +292,130 @@ $ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/t
276292具体主题可以在 [ oh-my-zsh 的项目 Wiki] ( https://github.com/ohmyzsh/ohmyzsh/wiki/Themes ) 中找到。
277293当然你也可以尝试自己做一个主题。
278294
295+ ### Fish {#fish}
296+
297+ Fish 是一个用户友好的命令行 shell,安装也非常简单:
298+
299+ ``` console
300+ $ sudo apt install fish
301+ ```
302+
303+ 将 fish 设定为默认 shell:
304+
305+ ``` console
306+ $ chsh -s /bin/fish
307+ ```
308+
309+ Fish 基本不需要配置,开箱即用。需要注意的是,** Fish 不兼容 POSIX 标准** ,因此 Bash 等 POSIX shell 下的脚本在 Fish 下是无法运行的。
310+
311+ ### Bash 的个性化 {#bash-personalization}
312+
313+ 即使不想更换 shell,我们也可以对 Bash 进行个性化配置。以下提供一种配置的选择,以供参考。
314+
315+ 首先使用 [ starship] ( https://starship.rs/ ) 来美化 Bash 的提示符:
316+
317+ ``` console
318+ $ curl -sS https://starship.rs/install.sh | sh
319+ ```
320+
321+ 然后在 ` ~/.bashrc ` 文件的末尾添加以下内容:
322+
323+ ``` shell
324+ eval " $( starship init bash) "
325+ ```
326+
327+ 可以使用以下命令添加(注意,` >> ` 是追加到文件末尾,因此这条命令只要执行一次即可):
328+
329+ ``` console
330+ $ echo ' eval "$(starship init bash)"' >> ~ /.bashrc
331+ ```
332+
333+ 重新打开一个终端就可以看到效果了。更进一步的修改请参考 [ starship 的配置文档] ( https://starship.rs/config/ ) 。
334+
335+ 之后我们配置按下 Ctrl + R 时搜索历史命令的功能。尽管 bash 已经内置了该功能,但是它的交互性非常差,难以使用,因此我们使用 [ fzf] ( https://junegunn.github.io/fzf/ ) 来增强该功能。
336+
337+ ``` console
338+ $ sudo apt install fzf
339+ ```
340+
341+ 之后同样在 ` ~/.bashrc ` 文件的末尾添加以下内容:
342+
343+ ``` shell
344+ eval " $( fzf --bash) "
345+ ```
346+
347+ 同样可以使用以下命令添加:
348+
349+ ``` console
350+ $ echo ' eval "$(fzf --bash)"' >> ~ /.bashrc
351+ ```
352+
353+ 重新打开一个终端,按下 Ctrl + R 即可使用该功能。
354+
279355## 其它的个性化 {#other-personalizations}
280356
281357上面内容都是外观上的个性化,更多地,Linux 系统的可客制化还体现在一些配置文件上。
282358
283- ### etc 目录
359+ ### MOTD 的配置 {#motd}
284360
285361` /etc ` 目录是包含几乎所有 Linux 系统配置的一个文件夹。
286362
287363!!! info "tips"
288364
289365 etc 是 "et cetera" 的简称,意思是 "and so on",在 Unix 初期人们实现 `etc` 文件夹就是为了保留配置文件,数据文件,套接字文件或其他文件用的。随着时间流逝,文件夹的含义已经更改,但是名字 etc 没有更改。现在 `/etc` 目录是所有配置文件的集中地,可以看作 Linux 系统的神经中枢。
290366
291- 下面介绍几个常用的配置文件:
367+ MOTD(Message Of The Day)是 Linux 系统登录时显示的一些信息。其配置就在 ` /etc ` 目录下。
292368
293- - ` /etc/fstab ` 系统磁盘挂载相关配置;
294- - ` /etc/bash.bashrc ` 启动 Bash 时读取的配置脚本;
295- - ` /etc/sudoers ` sudo 权限的配置;
296- - ` /etc/hosts ` 主机名与 IP 映射关系的配置。
369+ 当我们登录用户成功时:
297370
298- ??? example "示例"
299-
300- 当我们登录用户成功时:
371+ ``` console
372+ $ sudo login
373+ ```
301374
302- ```console
303- $ sudo login
304- ```
375+ 会提示以下信息:
305376
306- 会提示以下信息:
307-
308- ```text
309- Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 5.3.0-28-generic x86_64)
310- * Documentation: https://help.ubuntu.com
311- * Management: https://landscape.canonical.com
312- * Support: https://ubuntu.com/advantage
313- * Canonical Livepatch is available for installation.
314- - Reduce system reboots and improve kernel security. Activate at:
315- https://ubuntu.com/livepatch
316- 125 个可升级软件包。
317- 0 个安全更新。
318- Your Hardware Enablement Stack (HWE) is supported until April 2023.
319- *** 需要重启系统 ***
320- The programs included with the Ubuntu system are free software;
321- the exact distribution terms for each program are described in the
322- individual files in /usr/share/doc/*/copyright.
323-
324- Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
325- applicable law.
326- ```
377+ ``` text
378+ Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 5.3.0-28-generic x86_64)
379+ * Documentation: https://help.ubuntu.com
380+ * Management: https://landscape.canonical.com
381+ * Support: https://ubuntu.com/advantage
382+ * Canonical Livepatch is available for installation.
383+ - Reduce system reboots and improve kernel security. Activate at:
384+ https://ubuntu.com/livepatch
385+ 125 个可升级软件包。
386+ 0 个安全更新。
387+ Your Hardware Enablement Stack (HWE) is supported until April 2023.
388+ *** 需要重启系统 ***
389+ The programs included with the Ubuntu system are free software;
390+ the exact distribution terms for each program are described in the
391+ individual files in /usr/share/doc/*/copyright.
392+
393+ Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
394+ applicable law.
395+ ```
327396
328- Ubuntu 下这些提示信息都可以在 `/etc/update-motd.d/` 目录下修改, 登录后,将会在该目录依数字递增顺序执行该目录下的脚本。
397+ Ubuntu 下这些提示信息都可以在 ` /etc/update-motd.d/ ` 目录下修改, 登录后,将会在该目录依数字递增顺序执行该目录下的脚本。
329398
330- !!! info "提示"
399+ !!! info "提示"
331400
332- 有的 Linux 发行版的 MOTD (Message Of The Day) 配置在 `/etc/motd`
401+ 有的 Linux 发行版的 MOTD (Message Of The Day) 配置在 `/etc/motd`。
333402
334- 我们在 `/etc/update-motd.d/` 目录下新建一个文件 `99-test`,写入下面内容:
403+ 我们在 ` /etc/update-motd.d/ ` 目录下新建一个文件 ` 99-test ` ,写入下面内容:
335404
336- ```shell
337- #!/bin/sh
338- echo helloworld
339- ```
405+ ``` shell
406+ #! /bin/sh
407+ echo helloworld
408+ ```
340409
341- 然后:
410+ 然后:
342411
343- ```console
344- $ sudo chmod +x /etc/update-motd.d/99-test
345- ```
412+ ``` console
413+ $ sudo chmod +x /etc/update-motd.d/99-test
414+ ```
346415
347- 设置好权限,登录后就可以看到在末尾加上了我们在 `99-test` 文件中 echo 的内容。
416+ 设置好权限,登录后就可以看到在末尾加上了我们在 ` 99-test ` 文件中 echo 的内容。
348417
349- 当然如果你不希望显示上面的更新提示内容,也可以直接找到对应的文件删除或修改。
418+ 当然如果你不希望显示上面的更新提示内容,也可以直接找到对应的文件删除或修改。
350419
351420## 搭建简易的网站 {#website}
352421
0 commit comments