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 上禁用 ssh motd 歡迎消息。查看 模式 通過鍵入登錄到手冊頁 人命令:man motd
man login