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?

  • Maybe pipe your input to lolcat? I know its far from what you want, but a little color doesn't kill. :) – Tony Lancer Dec 23 '16 at 17:13
  • You can't paste emojis in your terminal? O.o Then open .bashrc with gedit or something. – muru Dec 23 '16 at 17:20
  • (the "show message at login" part should be a separate question) – muru Dec 23 '16 at 17:24
  • @muru, done. question de-duplicatified. – Kaz Wolfe Dec 23 '16 at 17:25
  • 4
    Possible duplicate of How can display a message on terminal when open it – Sergiy Kolodyazhnyy Dec 30 '16 at 23:22
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.

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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.