-
Notifications
You must be signed in to change notification settings - Fork 5
Creating a custom motd on Debian Jessie
A couple of hours in the evening, a couple of hours in the afternoon, and a few questions on IRC later, I have a custom motd (message of the day). I'm taking the time to write this article just for the sheer fact that this process took way longer than expected, and because I want to have something to reference if I ever have to do this again.
cheers π»
Chris
So, if I remember correctly, Debian 8 (Jessie) was the first major version of Debian to introduce systemd (let's not go down the systemd love / hate rabbit π hole), shall we.
Doing a quick google search for debian motd will more than likely put this article in the top of your results. Now, informative as that article is, I find it lacking some information to complete the custom motd on a Debian 8 (Jessie) box. I'll try and fill the gaps where that article leaves off.
For starters, my Debian 8 box is a digital ocean droplet, and not a Raspberry Pi.
The first thing I noticed is that motd
is now a service provided by systemd. If one tries to run the below command,
systemctl start motd
you're more than likely not going to get that far because the motd
service is in a masked state. Before you can even enable the motd
service, you're going to want to "unmask" the service. If you're thinking you can just run the below command,
systemd unmask motd
that won't get you very far, either. π After going back to the googler and refining my searches, I came across this nice answer. If you don't want to go down the link rabbit π hole (can't say that I don't blame you) I have transposed what that answer states. If the systemd service is linked to /dev/null
, then run the below commands:
file /lib/systemd/system/motd.service
They should return:
/lib/systemd/system/motd.service: symbolic link to /dev/null
You're going to want to delete:
sudo rm /lib/systemd/system/motd.service
Since you changed a unit file, you need to run this:
sudo systemctl daemon-reload
Now check the status:
systemctl status motd
It should now be green and running :) The service has no systemd unit file, but systemd happily uses the script for it in /etc/init.d instead.
For my particular use case, I ssh into this box 99% of the time, so I wanted to have the motd
displayed when I log in with my standard user account on the box. If I remember correctly, you're going to want to edit the file:
sudo nvim /etc/pam.d/sshd
and make sure you have the below line in there:
session optional pam_motd.so motd=/etc/motd
Next, I made the /etc/motd
file a symlink to /var/run/motd
with the below command:
sudo ln -sf /var/run/motd /etc/motd
With that set up, I was able to place custom shell script files within /etc/update-motd.d
with a filename of 02-header
and 50-footer
. Next, make sure all the scripts are executable within the above mentioned directory by running the below command:
sudo chmod +x /etc/update-motd.d/*
**Note: If you don't want a particular script to run from within this directory, simply remove the executable bit from the file with the below command:
sudo chmod -x /etc/update-motd.d/51-test
Now you should be all set up to see your custom motd
displayed on your next login to this particular box. For for my particular use case, I have two caveats.
- I use ππ (fish-shell)
- I want to display "motd" that is greater than 64KB in size.
Well the peeps on IRC frowned upon the idea of making a motd
greater than 64KB and suggested that I run a custom script from within /etc/profile.d
, which would lead to the script running every time I login to the box. However, since I'm running fish shell as my default shell, these scripts will not run because the scripts placed within /etc/profile.d
are specific to BASH π¨.
I ended up creating an /etc/environment
and putting the below line within it:
SHELL=/usr/bin/fish
From reading the fish documentation, one can edit the global fish shell configuration file located within
/etc/fish/
by running the below command:
sudo nvim /etc/fish/config.fish
and placing the single line within it:
/home/$USER/.cargo/bin/termpix --true-color /etc/environment.d/cable.jpg
Pheww, take a deep breath, pat yourself on the back, and if everything goes well, you should see something like the below. Obviously your mileage π will vary depending on what you put in your scripts, but for my particular use case, I see something like the following in my terminal now:
If you find any of this info helpful on your journey π click that π βοΈ star button. It sure makes me feel warm and fuzzy π» on the inside.
-
Linux and macOS Operation Notes
- β macOS Op Notes
- π§ Linux Op Notes
- Vim & Neovim Notes
- git Notes
- π fish shell Notes
- ECMAScript Tooling
- π₯§ Raspberry Pi Notes
- asdf version manager Notes
- Bind9 Notes
- Creating a custom motd on Debian Jessie
- ECMAScript Tooling
- Email client Notes
- Email Server Setup Notes Postfix & Dovecot
- Emoji side quest
- fish shell Notes
- π₯ π€ git it got it good Notes
- git Notes
- Graphics and Image Processing Notes
- GUI text editor Notes
- π»π§ Homebrew and Linuxbrew formula Notes
- Linux and macOS Administration Notes
- Linux and macOS Troubleshooting Notes
- MacBook Pro Late 2013 Notes
- Vim & Neovim Notes
- Video Production Notes
- Python Notes
- radare Notes
- Raspberry Pi Notes
- Terminal Emulators
- Tmux Notes
- Web Browser Notes
- Weechat Notes
- Microsoft Windows Notes