hellohitto!と出力したい!

出したい物

前提

ubuntu 22.04

wsl

仕組み、やってみた

仕組み

/etc/update-motd.d/* をいい感じに変更する

※もっと難しそうな仕組みだった

hitto@hitto-note:/etc/update-motd.d$ ls -al
drwxr-xr-x  3 root root 4096 Apr  5 07:54 .
drwxr-xr-x 76 root root 4096 Apr 19 13:43 ..
-rwxr-xr-x  1 root root 1228 Apr  1 13:55 00-header
-rwxr-xr-x  1 root root 1159 Apr  1 13:55 10-help-text
-rwxr-xr-x  1 root root 5029 Apr  2 01:03 50-motd-news
-rwxr-xr-x  1 root root  296 Dec  1 02:00 91-contract-ua-esm-status
-rwxr-xr-x  1 root root  558 Aug  2  2023 91-release-upgrade
-rwxr-xr-x  1 root root  165 Feb 19  2021 92-unattended-upgrades

これを上から実行しているみたい

やってみた

vim 20-hitto-message
#!/bin/bash

cat << "EOF"
 _            _  _          _      _  _    _             _
| |__    ___ | || |  ___   | |__  (_)| |_ | |_   ___    / \
| '_ \  / _ \| || | / _ \  | '_ \ | || __|| __| / _ \  /  /
| | | ||  __/| || || (_) | | | | || || |_ | |_ | (_) |/\_/
|_| |_| \___||_||_| \___/  |_| |_||_| \__| \__| \___/ \/

EOF
hitto@hitto-note:/etc/update-motd.d$ ls -al
drwxr-xr-x  3 root root 4096 Apr  5 07:54 .
drwxr-xr-x 76 root root 4096 Apr 19 13:43 ..
-rwxr-xr-x  1 root root 1228 Apr  1 13:55 00-header
-rwxr-xr-x  1 root root 1159 Apr  1 13:55 10-help-text
-rwxr-xr-x  1 root root  326 Apr  1 14:06 20-hitto-message
-rwxr-xr-x  1 root root 5029 Apr  2 01:03 50-motd-news
-rwxr-xr-x  1 root root  296 Dec  1 02:00 91-contract-ua-esm-status
-rwxr-xr-x  1 root root  558 Aug  2  2023 91-release-upgrade
-rwxr-xr-x  1 root root  165 Feb 19  2021 92-unattended-upgrades

osによって仕組み違ったりするらしい。気が向いたらもっと調べる。

参考

第755回 UbuntuにおけるMOTDの仕組みのすべて | gihyo.jp

Ubuntu Manpage: update-motd - dynamic MOTD generation

← Go home