ubuntu ssh登录显示系统信息配置

之前是用aws的,使用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

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

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

ping@ping-kubuntu ~ % ll /etc/update-motd.d 
总用量 24
-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.

这两个包都安装完后,登录后的效果如下:

ping@ping-kubuntu ~ % ssh root@192.168.78.248
root@192.168.78.248's password: 
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:~# 

效果不错!哈哈哈

参考资料:

How to see the details which Ubuntu shows at the time of login anytime?

How to find the number of packages needing update from the command line?

Fixing Ubuntu MOTD and Landscape Related Login Delays

转载请注明: 转载自elkPi.com

本文链接地址: ubuntu ssh登录显示系统信息配置

1 Comment

  1. […] 原文链接地址: ubuntu ssh登录显示系统信息配置 […]

    回复

回复 UBUNTU SSH登录显示系统信息配置 – Rasper 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Scroll to top