2011年7月12日 星期二

編輯登入訊息檔 (Ubuntu Server)

以下操作必須在 Ubuntu Server 系統中操作

登入前訊息顯示
$ cat /etc/issue
Ubuntu 10.04.1 LTS \n \l            #  由此訊息也可以知道所使用 Ubuntu 的版本

登入後訊息顯示
$ cat /etc/motd
Linux oncloud9 2.6.32-21-generic-pae #32-Ubuntu SMP Fri Apr 16 09:39:35 UTC 2010 i686 GNU/Linux
Ubuntu 10.04.1 LTS

Welcome to Ubuntu!
 * Documentation:  https://help.ubuntu.com/

Your CPU appears to be lacking expected security protections.
Please check your BIOS settings, or for more information, run:
  /usr/bin/check-bios-nx --verbose

  System information as of Mon Aug  9 23:28:00 CST 2010

  System load:  0.45              Processes:           91
  Usage of /:   3.0% of 47.81GB   Users logged in:     1
  Memory usage: 7%                IP address for lo:   127.0.0.1
  Swap usage:   0%                IP address for eth0: 192.168.56.128

  Graph this data and manage this system at https://landscape.canonical.com/

[註] Message of the Day (motd)

/etc/motd 這個檔案內容, 是由 /etc/update-motd.d/ 目錄中的所有程式所產生的, 你自己也可以在此目錄, 增加程式來顯示自己的資訊

顯示 /etc/update-motd.d/ 目錄內容
這目錄中的程式, 是在 登入前 會被執行
$ ls -al /etc/update-motd.d/
總計 36
drwxr-xr-x  2 root root 4096 2010-08-04 17:06 .
drwxr-xr-x 88 root root 4096 2010-08-05 22:46 ..
-rwxr-xr-x  1 root root   57 2010-04-23 17:45 00-header
-rwxr-xr-x  1 root root  248 2010-04-23 17:45 10-help-text
-rwxr-xr-x  1 root root   65 2010-04-14 04:45 20-cpu-checker
lrwxrwxrwx  1 root root   46 2010-08-04 17:06 50-landscape-sysinfo -> /usr/share/landscape/landscape-sysinfo.wrapper
-rwxr-xr-x  1 root root   71 2010-04-14 04:45 90-updates-available
-rwxr-xr-x  1 root root   61 2010-04-24 03:13 91-release-upgrade
-rwxr-xr-x  1 root root   69 2010-04-14 04:45 98-reboot-required
-rwxr-xr-x  1 root root  261 2010-04-23 17:45 99-footer

顯示 00-header 程式內容
$ cat /etc/update-motd.d/00-header
#!/bin/sh

uname -a
printf "%s\n" "$(lsb_release -s -d)"

顯示 50-landscape-sysinfo 程式內容
$ cat /etc/update-motd.d/50-landscape-sysinfo
#!/bin/sh
echo
echo -n "  System information as of "
/bin/date
echo
/usr/bin/landscape-sysinfo

直接執行 /etc/update-motd.d/50-landscape-sysinfo 程式, 顯示如下 :
$ /etc/update-motd.d/50-landscape-sysinfo

  System information as of 四  8月  5 23:04:56 CST 2010

  System load:  0.0               Processes:           72
  Usage of /:   2.7% of 47.81GB   Users logged in:     1
  Memory usage: 6%                IP address for lo:   127.0.0.1
  Swap usage:   0%                IP address for eth0: 192.168.56.128

  Graph this data and manage this system at https://landscape.canonical.com/

自製訊息程式
$ cd /etc/update-motd.d
$ sudo nano 99-zhi
#!/bin/bash
echo hi

$ sudo chmod +x 99-zhi
$ sudo reboot
 
取消登入後的訊息顯示

在你的家目錄產生以下檔案 :
$ touch .hushlogin

沒有留言:

張貼留言