Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

How do I add welcome message to Linux?

Writer Matthew Barrera

I want to add a welcome message (and change a greetings row) to Linux.

I added

echo "Hello"
PS1="\u $: "

to “.profile” file, but nothing happens after the reboot. Why?

1

4 Answers

In order to make this work, you need to understand the order and when each config file for shell is being sourced( aka loaded). ~/.profile is sourced at the time of logging in. It will be shown in TTY console perfectly fine - I personally have a message like that in my ~/.profile for when I go into TTY specifically. If you call a shell again from that session, it won't be sourced. Same thing in GUI. You log-in , the file is sourced only once.

My guess is that you are trying to show the message in the GUI terminal. When you log in into desktop your ~/.profile is already sourced, which also means it will not be sourced again in any terminal under that session, and message won't be shown. There's your problem.

The solution would be to place that message at the end of ~/.bashrc. That file is sourced when each interactive session is open, regardless of whether you are logging-in or not.

2

If you want to get a custom message when you log in via ssh, you need to put a text file in /etc/update-motd.d. Give it a name like 11-my-banner-message and make the permissions -rwxr-xr-x.

The file can look like this

#!/bin/sh
#
#
printf "\n"
printf " Howdy There!\n"

You can do so by simply adding a few lines in the ~/.bashrc file, which would make changes for only the current user for the default shell Bash. Check this out for the full explanation on showing custom-message/ASCII-art/random-one-liner as welcome to the linux terminal.

You can write your message freely in a separate file and add

echo "$(</path/to/file)"

in any of the files contained in /etc/update-motd.d

Pretty useful if your message contains " ' or ` chars. (for example in ascii art)

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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