Ubuntu

Ubuntu18.04 ログイン時に表示されるメッセージを止める

今日、急にログイン時に表示されるメッセージが気になり始めた。
motd(message of the day)の見直し。

広告


 

現在表示されているメッセージ

現在、ログイン時に表示されるメッセージはこれ。

Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-58-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

System information as of Sat Aug 24 04:05:25 JST 2019

System load: 0.0 Processes: 155
Usage of /: 25.2% of 15.68GB Users logged in: 1
Memory usage: 42% IP address for ens160: 172.16.2.1
Swap usage: 0% IP address for ppp0: nnn.nnn.nnn.nnn

* Keen to learn Istio? It's included in the single-package MicroK8s.

https://snapcraft.io/microk8s

* Canonical Livepatch is available for installation.
- Reduce system reboots and improve kernel security. Activate at:
https://ubuntu.com/livepatch

0 packages can be updated.
0 updates are security updates.

 

①~③を消してみる。

 

ヘルプ文

あってもいいけど、毎回表示させなくてもいいかな…と。

 * Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

 

これは、以下のスクリプトで固定表示されているので、表示前にexitさせる。

/etc/update-motd.d/10-help-text

!/bin/sh
#
# 10-help-text - print the help text associated with the distro
# Copyright (C) 2009-2010 Canonical Ltd.

exit
printf "\n"
printf " * Documentation: https://help.ubuntu.com\n"
printf " * Management: https://landscape.canonical.com\n"
printf " * Support: https://ubuntu.com/advantage\n"

 

 

ニュース

運用が安定するとあまり調べごとをしなくなるので、ニュースが表示されること自体は有用なのかもしれない。でも、今日のオレは消してしまおうという気になった。

 * Keen to learn Istio? It's included in the single-package MicroK8s.

https://snapcraft.io/microk8s

 

これは、/etc/update-motd.d/50-motd-news というスクリプトで表示されており、情報は https://motd.ubuntu.com から持ってきていた。表示を無効化するには以下のファイルを変更する。
Github / Disable (or better utilize) the Ubuntu 18.04 MOTD news feature #930
デビアンな生活 / motd、余計なお節介を短く

/etc/default/motd-news

# Enable/disable the dynamic MOTD news service
# This is a useful way to provide dynamic, informative
# information pertinent to the users and administrators
# of the local system
#ENABLED=1
ENABLED=0

# Configure the source of dynamic MOTD news
# White space separated list of 0 to many news services
# For security reasons, these must be https
# and have a valid certificate
# Canonical runs a service at motd.ubuntu.com, and you
# can easily run one too
URLS="https://motd.ubuntu.com"

# Specify the time in seconds, you're willing to wait for
# dynamic MOTD news
# Note that news messages are fetched in the background by
# a systemd timer, so this should never block boot or login
WAIT=5

 

 

ライブパッチのお知らせ

ルーターやこのサイトのように、常に動かしておきたい(止めたくない)サーバーを運用しているならば、本来は導入しておきたくなる Canonical Livepatch Service。
Gihyo.jp / 第443回 再起動なしにカーネルを更新する「Canonical Livepatch Service」
ガジェット好きの日記 / 【Ubuntu18.04】新機能 LivePatchについて

しかし、どうせ使っているのは家族・親族ぐらいだし、適当に再起動なんかもしてるので無効化しようと思う。

 * Canonical Livepatch is available for installation.
- Reduce system reboots and improve kernel security. Activate at:
https://ubuntu.com/livepatch

 

これは、/etc/update-motd.d/80-livepatch というスクリプトで表示されている。中を見てみると、LivePatch が disabled (not available) の状態になっていれば、メッセージは表示されない模様。

確認にどんなコマンドが使われているのか読み取ると、こんな感じ。

$ cat /var/cache/ubuntu-advantage-tools/ubuntu-advantage-status.cache
esm: disabled (not available)
fips: disabled (not available)
livepatch: disabled

 

disabled だけど not available ではないからメッセージが表示されているようだ。Ubuntu18.04 LTS を使わせてもらっているので、LivePatch 対応プラットフォームではある。これが19.04とかだと、きっと(not available)になるのだろう。

こうなると、最小限の変更で表示を止めるには、以下の通り処理を始める前に止めてしまうしかなさそうだった。

/etc/update-motd.d/80-livepatch

#!/bin/sh
exit
UA=${UA:-"/usr/bin/ubuntu-advantage"}
UA_STATUS_CACHE=${UA_STATUS_CACHE:-"/var/cache/ubuntu-advantage-tools/ubuntu-advantage-status.cache"}

 

 

結果

以上3つの変更で、以下の通りとなった。

Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-58-generic x86_64)

System information as of Sat Aug 24 04:50:25 JST 2019

System load: 0.0 Processes: 155
Usage of /: 25.2% of 15.68GB Users logged in: 1
Memory usage: 41% IP address for ens160: 172.16.2.1
Swap usage: 0% IP address for ppp0: nnn.nnn.nnn.nnn

0 packages can be updated.
0 updates are security updates.

 

 

やったこと

無駄かもしれない…と思いつつ、LivePatch をインストールして、disable にしたら (not available) にならないかなぁと試してみた。
Narrow Escape / Ubuntu 16.04: Canonical Livepatch Serviceでカーネルライブパッチを適用する

$ sudo snap install canonical-livepatch
canonical-livepatch 9.4.1 from Canonical? installed
$ sudo snap
$ sudo canonical-livepatch disable
$ cat /var/cache/ubuntu-advantage-tools/ubuntu-advantage-status.cache
esm: disabled (not available)
fips: disabled (not available)
livepatch: disabled

 

やっぱり表示は変わらなかったので、これは「利用できる環境だけれども無効化されているよ」という判断で表示されているメッセージなのだろうと考えて、表示スクリプトを変更することにした。
StackExchange / Livepatch not working in 19.04?

 

広告

コメントはこちらから お気軽にどうぞ ~ 投稿に関するご意見・感想・他