How do I add welcome message to Linux?
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.
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"