每次我通过 SSH 进入我的 AWS Ubuntu 服务器时,我都会看到一条系统信息消息,显示负载、内存使用情况和可安装的包,如下所示:
Welcome to Ubuntu 12.04.3 LTS (GNU/Linux 3.2.0-51-virtual x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Sun Nov 10 18:06:43 EST 2013
System load: 0.08 Processes: 127
Usage of /: 4.9% of 98.43GB Users logged in: 1
Memory usage: 69% IP address for eth0: 10.236.136.233
Swap usage: 100%
Graph this data and manage this system at https://landscape.canonical.com/
13 packages can be updated.
0 updates are security updates.
Get cloud support with Ubuntu Advantage Cloud Guest
http://www.ubuntu.com/business/services/cloud
Use Juju to deploy your cloud instances and workloads.
https://juju.ubuntu.com/#cloud-precise
*** /dev/xvda1 will be checked for errors at next reboot ***
*** System restart required ***
我的问题是,该消息是如何创建的?我该如何配置它?
答案1
此登录消息是由 Ubuntu 的landscape
软件包创建的。就我个人而言,我认为它们非常烦人,因此,我已配置 ansible 以清除这些软件包并设置空白登录消息。
要做到这一点:
$ apt-get remove landscape-client landscape-common
$ rm -f /etc/motd && touch /etc/motd
这将创建一个空白的/etc/motd
。要设置自定义登录消息,请根据需要编辑该文件。
答案2
就我而言,我必须清除/etc/update-motd.d/51-cloudguest
,内容如下:
#!/bin/sh
#
# This file is written by the Ubuntu image build process, it is not
# managed by a package. If you want to avoid seeing this advertisement,
# then you can safely remove the file.
echo ""
echo " Get cloud support with Ubuntu Advantage Cloud Guest:"
echo " http://www.ubuntu.com/business/services/cloud"
echo ""
echo " Use Juju to deploy your cloud instances and workloads:"
echo " https://juju.ubuntu.com/#cloud-saucy"
答案3
虽然已经回答了,但我想添加一种不同的方法:由于我发现(许多)动态生成的信息非常有用,我宁愿不删除整个 motd 或卸载景观包,因为我不是每天都做这种管理工作。
Ubuntu 将动态 motd 存储在“/etc/update-motd.d/”文件夹中。因此,要禁用整个 motd,只需删除相应脚本的执行权限:
$ sudo chmod -x /etc/update-motd.d/*
或者根据每个脚本执行此操作,例如
$ sudo chmod -x /etc/update-motd.d/10-help-text
以便仅禁用单个部分(例如帮助文本)。您可以通过发出命令来恢复该部分chmod +x
。请参阅在 Ubuntu 上禁用动态 motd 和新闻...
您还可以缩小相当长的“系统信息”输出以满足您的需要,例如
System information as of Mon 27 Dec 2021 05:26:42 PM CET
IPv4 address for enp3s0: 192.168.0.10 Temperature: 36.0 C
通过向文件添加配置部分/etc/landscape/client.conf
:
[sysinfo]
sysinfo_plugins = Network, Temperature
landscape-sysinfo(1)
有关该配置的详细信息,请参阅手册页。
希望这可以帮助。