[转]ubuntu ssh登陆显示系统信息

Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-49-generic i686)
 
 * Documentation:  https://help.ubuntu.com/
 
  System information as of Fri May 22 05:07:32 PDT 2015
 
  System load:  0.98              Processes:           76
  Usage of /:   6.8% of 48.11GB   Users logged in:     1
  Memory usage: 12%               IP address for eth0: 192.168.78.248
  Swap usage:   0%
 
  Graph this data and manage this system at:
    https://landscape.canonical.com/
You have new mail.
Last login: Fri May 22 05:07:33 2015 from 192.168.78.212

显示登录的时间,显示当前进程数,IP,内存,硬盘等一些使用情况。不错的功能,还能知道上次登录的时间以及IP。但是到新的VPS上,发现只有显示:

Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-49-generic i686)
 
 * Documentation:  https://help.ubuntu.com/

原来是没有安装landscape.通过以下命令安装:

sudo apt-get install landscape-common

这里插入一个介绍一下landscape

这是:https://landscape.canonical.com/index.html landscape的官方网站

之后退出,并重新登录。即可达到显示登录系统信息的功能了。

其实这是ubuntu开机后,会生成一个文件:/run/motd.dynamic 而在登录后,会去cat该文件并显示出来。而这个文件的生成其实是执行了/etc/update-motd.d/ 内的几个文件。看一下有安装landscape后 /etc/update-motd.d/的内容:

-rwxr-xr-x 1 root root 1220  2月 20  2014 00-header
-rwxr-xr-x 1 root root 1358  2月 20  2014 10-help-text
lrwxrwxrwx 1 root root   46  5月 22 20:00 50-landscape-sysinfo -> /usr/share/landscape/landscape-sysinfo.wrapper
-rwxr-xr-x 1 root root  149  8月 22  2011 90-updates-available
-rwxr-xr-x 1 root root  299  4月 12  2014 91-release-upgrade
-rwxr-xr-x 1 root root  142  8月 22  2011 98-fsck-at-reboot
-rwxr-xr-x 1 root root  144  8月 22  2011 98-reboot-required

顺序执行了这几个文件。并将结果输出到/run/motd.dynamic

但是看我虚拟机上的ubuntu server版本的话,并没有90-updates-available 98-fsck-at-reboot 98-reboot-required 这三个文件。那这三个文件又是什么?这三其实有个功能,可以显示当前系统有多少包可以升级,有多少是安全更新等。这对于我这种有升级控的人很是需要。可以通过一下命令安装:

sudo apt-get install update-notifier-common

安装完成之后 登陆会提示以下信息

21 packages can be updated.
15 updates are security updates.

最后重新登陆 得到完整的登陆信息

Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-49-generic i686)
 
 * Documentation:  https://help.ubuntu.com/
 
  System information as of Fri May 22 05:44:24 PDT 2015
 
  System load:  0.66              Processes:           79
  Usage of /:   6.8% of 48.11GB   Users logged in:     0
  Memory usage: 7%                IP address for eth0: 192.168.78.248
  Swap usage:   0%
 
  Graph this data and manage this system at:
    https://landscape.canonical.com/
 
21 packages can be updated.
15 updates are security updates.
 
You have new mail.
Last login: Fri May 22 05:44:24 2015 from 192.168.78.212
root@ubuntu:~# 

此文部分修改

转载自:http://elkpi.com/topics/ubuntu-ssh-login-show-system-info.html

thanks elkpi 带来此好文