D你知道嗎?您可以使用特定文件來關閉 Linux 或 Unix 上的橫幅。 當您使用 ssh 或其他方式登錄時,您會在屏幕上看到很多信息。這是我的 FreeBSD 主登錄的樣子:
第一個是 /etc/motd,第二個是從 ~/.profile 文件調用的 neofetch 的輸出。 當我使用 ssh 命令登錄時,Ubuntu Linux 框中也會出現一些內容。
[email protected]'s password:
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-73-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Saturday 15 May 2021 03:18:53 AM IST
System load: 1.01
Usage of /: 42.3% of 815.83GB
Memory usage: 30%
Swap usage: 0%
Temperature: 58.0 C
Processes: 650
Users logged in: 1
IPv4 address for br0: 192.168.2.25
IPv4 address for lxdbr0: 10.83.200.1
IPv6 address for lxdbr0: fd42:87d0:ec52:7d50::1
IPv4 address for mum-wg0: 10.8.0.2
IPv6 address for mum-wg0: fd9d:bc11:4021::2
IPv4 address for virbr0: 192.168.122.1
3 devices have a firmware upgrade available.
Run `fwupdmgr get-upgrades` for more information.
1 update can be applied immediately.
To see these additional updates run: apt list --upgradable
Last login: Sat May 15 03:18:33 2021 from 127.0.0.1
不要害怕。有一種簡單的方法可以隱藏這些信息。
如何使用 .hushlogin 在 Linux 或 Unix 上關閉登錄橫幅
首先,在您的登錄目錄 ($HOME) 中創建一個名為 ~/.hushlogin 的新空文件。 在 Linux 或 Unix shell 提示符下,鍵入以下 touch 命令:touch ~/.hushlogin
而已。接下來,嘗試使用 ssh 命令登錄。ssh [email protected]
什麼是 motd 和 ~ / .hushlogin 文件?
MOTD 是 Message of the Day 的首字母縮寫詞。
/etc/motd 文件通常在用戶登錄後通過 login 或 ssh 顯示。在為會話設置 shell 之前顯示內容。傳統上,系統管理員使用此文件來提供系統範圍的公告。例如,我們將 RAID 陣列替換為用於內核升級的重啟框。 以下是使用 cat 命令顯示它的方法:cat /etc/motd
個人用戶可以通過在他們的主目錄中創建一個名為 .hushlogin 的文件來禁止該文件。 創建 /etc/motd 的概念是因為它需要的磁盤空間比向所有用戶發送郵件要少得多。
使用 .hushlogin 文件關閉 Linux 或 Unix 上的登錄橫幅
touch ~/.hushlogin #OR# touch $HOME/.hushlogin #BASH# >$HOME/.hushlogin
演示
這是一個簡單的視頻:
全部的
了解如何在 Linux、macOS、* BSD 和類 Unix 系統上關閉登錄橫幅。 只需在 $HOME 目錄中創建一個文件。橫幅 /etc/motd 包含有關係統的基本信息,尤其是停機時間。 當我創建 ~ / .hushlogin 文件時,我沒有看到這樣的消息。然而, 其他命令 或 cat 命令:more /etc/motd
# freebsd specific #
cat /etc/motd.template
cat /etc/motd*
# Ubuntu #
ls -l /etc/update-motd.d
請注意,Ubuntu Linux 使用 update-motd 文件,這是一個動態 MOTD 生成工具。有關更多信息,請參閱如何在 Ubuntu Linux 上禁用 sshmotd 歡迎消息。查看 模式 通過鍵入以下內容登錄到手冊頁: 手動命令:man motd
man login