5

With Christmas around the corner, I'd like to make my system's prompt (for every user) a bit more festive and cheery.

Namely, I'd like to attach a Happy Holidays! (or similar) message post-login for every user on the system (on terminal login, SSH or locally). I'd assume this is a simple echo command, but I'm not sure where the appropriate place to put this command is in such a way that it would affect everyone. For obvious reasons, I'd rather not modify everyone's .bashrc. So, where is that?

Kaz Wolfe
  • 34,122
  • 21
  • 114
  • 172

3 Answers3

4

Linux can do this using the /etc/motd system, or any system that extends that (namely, update-motd).

Given this information, it's possible to add a simple shell script to /etc/update-motd.d/40-holiday:

#!/bin/bash
echo Happy holidays from your local sysadmin!

Upon marking this as runnable (sudo chmod a+x /etc/update-motd.d/40-holiday), the MOTD can be forcefully updated using the command update-motd (as root).

Any subsequent logins will use the new (expanded) MOTD, finally bringing some holiday cheer to anybody who has to log on to a server on Christmas day.

Note that this method depends on the update-motd package, which should be pre-installed. But if it's not, sudo apt install update-motd.

Kaz Wolfe
  • 34,122
  • 21
  • 114
  • 172
1

I'd like to inject a christmas tree emoji () into my own PS1 prompt somehow

Try using \u1f384 and reference https://unix.stackexchange.com/questions/25903/awesome-symbols-and-characters-in-a-bash-prompt for common pitfalls.

I'd also like to attach a "Happy Holidays!" message to every user's shell (at login only).

I would suggest changing the motd banner, if I understand what you want correctly. I don't remember off the top of my head how it's done best in Ubuntu, but if you want to be lazy you could modify one of the files in /etc/update-motd.d/, such as 98-reboot-required and throw an echo "Happy Holidays!"; at the end.

Iskar
  • 113
1

If you are using SSH and motd, don't forget to update sshd_config.

Change: PrintMotd no to: PrintMotd yes

And restart the ssh server to apply the changes.

fugitive
  • 1,246