Skip to content

Commit 1107814

Browse files
committed
Ch02: Don't encourage users to change config they don't know
1 parent a8973b8 commit 1107814

File tree

1 file changed

+39
-46
lines changed

1 file changed

+39
-46
lines changed

docs/Ch02/supplement.md

Lines changed: 39 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -356,73 +356,66 @@ $ echo 'eval "$(fzf --bash)"' >> ~/.bashrc
356356

357357
上面内容都是外观上的个性化,更多地,Linux 系统的可客制化还体现在一些配置文件上。
358358

359-
### etc 目录
359+
### MOTD 的配置 {#motd}
360360

361361
`/etc` 目录是包含几乎所有 Linux 系统配置的一个文件夹。
362362

363363
!!! info "tips"
364364

365365
etc 是 "et cetera" 的简称,意思是 "and so on",在 Unix 初期人们实现 `etc` 文件夹就是为了保留配置文件,数据文件,套接字文件或其他文件用的。随着时间流逝,文件夹的含义已经更改,但是名字 etc 没有更改。现在 `/etc` 目录是所有配置文件的集中地,可以看作 Linux 系统的神经中枢。
366366

367-
下面介绍几个常用的配置文件:
367+
MOTD(Message Of The Day)是 Linux 系统登录时显示的一些信息。其配置就在 `/etc` 目录下。
368368

369-
- `/etc/fstab` 系统磁盘挂载相关配置;
370-
- `/etc/bash.bashrc` 启动 Bash 时读取的配置脚本;
371-
- `/etc/sudoers` sudo 权限的配置;
372-
- `/etc/hosts` 主机名与 IP 映射关系的配置。
369+
当我们登录用户成功时:
373370

374-
??? example "示例"
371+
```console
372+
$ sudo login
373+
```
375374

376-
当我们登录用户成功时
375+
会提示以下信息
377376

378-
```console
379-
$ sudo login
380-
```
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.
381392
382-
会提示以下信息:
383-
384-
```text
385-
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 5.3.0-28-generic x86_64)
386-
* Documentation: https://help.ubuntu.com
387-
* Management: https://landscape.canonical.com
388-
* Support: https://ubuntu.com/advantage
389-
* Canonical Livepatch is available for installation.
390-
- Reduce system reboots and improve kernel security. Activate at:
391-
https://ubuntu.com/livepatch
392-
125 个可升级软件包。
393-
0 个安全更新。
394-
Your Hardware Enablement Stack (HWE) is supported until April 2023.
395-
*** 需要重启系统 ***
396-
The programs included with the Ubuntu system are free software;
397-
the exact distribution terms for each program are described in the
398-
individual files in /usr/share/doc/*/copyright.
399-
400-
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
401-
applicable law.
402-
```
393+
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
394+
applicable law.
395+
```
403396

404-
Ubuntu 下这些提示信息都可以在 `/etc/update-motd.d/` 目录下修改, 登录后,将会在该目录依数字递增顺序执行该目录下的脚本。
397+
Ubuntu 下这些提示信息都可以在 `/etc/update-motd.d/` 目录下修改, 登录后,将会在该目录依数字递增顺序执行该目录下的脚本。
405398

406-
!!! info "提示"
399+
!!! info "提示"
407400

408-
有的 Linux 发行版的 MOTD (Message Of The Day) 配置在 `/etc/motd`
401+
有的 Linux 发行版的 MOTD (Message Of The Day) 配置在 `/etc/motd`
409402

410-
我们在 `/etc/update-motd.d/` 目录下新建一个文件 `99-test`,写入下面内容:
403+
我们在 `/etc/update-motd.d/` 目录下新建一个文件 `99-test`,写入下面内容:
411404

412-
```shell
413-
#!/bin/sh
414-
echo helloworld
415-
```
405+
```shell
406+
#!/bin/sh
407+
echo helloworld
408+
```
416409

417-
然后:
410+
然后:
418411

419-
```console
420-
$ sudo chmod +x /etc/update-motd.d/99-test
421-
```
412+
```console
413+
$ sudo chmod +x /etc/update-motd.d/99-test
414+
```
422415

423-
设置好权限,登录后就可以看到在末尾加上了我们在 `99-test` 文件中 echo 的内容。
416+
设置好权限,登录后就可以看到在末尾加上了我们在 `99-test` 文件中 echo 的内容。
424417

425-
当然如果你不希望显示上面的更新提示内容,也可以直接找到对应的文件删除或修改。
418+
当然如果你不希望显示上面的更新提示内容,也可以直接找到对应的文件删除或修改。
426419

427420
## 搭建简易的网站 {#website}
428421

0 commit comments

Comments
 (0)