背景
/etc/motdを編集すれば、Linuxのログインメッセージを変更できる。
しかし、Amazon Linuxでは、OSを再起動するとシステムが書き換えてしまう。
その解決方法。
解決方法その一
誰が更新しているのか?
/etc/motdはシンボリックリンクで、実体は/var/lib/update-motd/motd。
ls -la /etc/motd
lrwxrwxrwx 1 root root 25 5月 9 20:03 2013 /etc/motd -> /var/lib/update-motd/motd
このファイルの更新しているのが、以下のスクリプト達。
$ ls -la /etc/update-motd.d
合計 20
drwxr-xr-x 2 root root 4096 11月 5 09:01 2013 .
drwxr-xr-x 76 root root 4096 11月 5 09:02 2013 ..
-rwxr-xr-x 1 root root 220 10月 16 22:51 2013 30-banner
-rwxr-xr-x 1 root root 441 10月 16 22:51 2013 70-available-updates
-rwxr-xr-x 1 root root 2103 10月 16 22:51 2013 75-system-update
各スクリプトをみると、30-bannerを編集することでログインメーセージをカスタマイズ可能なことが判る。
解決方法そのニ
/etc/update-motd.d/*は編集したくない、という場合はこちら。
/etc/bashrcで独自のメッセージを流すようにしてやれば良い。
$ diff /etc/bashrc.old /etc/bashrc
43a44,50
>
> if [ -f /etc/motd.d/custom ]; then
> echo
> cat /etc/motd.d/custom;
> echo
> fi
85a93
>