How to show the message "hello $username, today's date is $date" as soon as you login to Ubuntu.
Asked
Active
Viewed 7,467 times
12
-
1Do you want this to happen in text mode or to prompt a messagebox? – Misery Jun 22 '13 at 07:31
-
2http://stackoverflow.com/questions/7035/showing-a-message-box-from-a-bash-script-in-linux will help you if you're aware of shell scripts. – saji89 Jun 22 '13 at 07:39
-
Are you logging in via GUI or commandline? – saji89 Jun 22 '13 at 07:40
-
1Take a look at Writing shell scripts – Mitch Jun 22 '13 at 08:09
1 Answers
14
If you want to see the message when you open the terminal or after you are login in tty1-6, just put this line at the end of ~/.bashrc file (open it from terminal with gedit ~/.bashrc):
echo "Hello $USER, today's date is $(date +"%A, %d-%m-%y")"
If you want to see the message after you are login in GUI, do the following:
Create a new file
name_and_date.sh:gedit ~/bin/name_and_date.shIf you want to get a desktop notification, put next 2 lines inside:
#!/bin/bash notify-send "Hello" "Hello $USER, today's date is $(date +"%A, %d-%m-%y")"Alternatively, if you want a popup (message box) to show up, put next 2 lines inside:
#!/bin/bash zenity --info --title "Hello" --text "Hello $USER, today's date is $(date +"%A, %d-%m-%y")"Save the file and close it.
Make the file exacutable:
chmod +x ~/bin/name_and_date.sh- Search in Dash for Startup Applications, open it and click Add.
- Under name type "Show my name and date" or something you will recognise.
- Under command type:
/home/$USER/bin/name_and_date.sh(change$USERwith your user name). - Under comment (if you want), type a brief description.

Radu Rădeanu
- 169,590
-
That would be
~/.bashrcnot~/bashrc. Excellent tutorial for creating a startup application. – glenn jackman Jun 22 '13 at 15:34 -
@glennjackman Thanks for attention, I was hurried. I will correct now. – Radu Rădeanu Jun 22 '13 at 15:40
-
2I want to be picky: don't use the suffix
.shfor a [tag:bash] script, it's confusing! Otherwise good answer!+1. – gniourf_gniourf Jun 22 '13 at 15:51