Ask Your Question

execute shell script at login

asked 2013-11-03 08:54:47 -0600

nks gravatar image

updated 2014-09-27 20:39:51 -0600

mether gravatar image

I want to execute a shell script whenever i login to my account.

The shell script should show the date and username in the terminal.

how to do this???

please help me

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-11-03 10:04:27 -0600

Hi: If that's all you need you can simply add a line to your .bash_profile

echo -e "The date = "$(date)"\nThe user = "$(id)


echo -e "The date = "`date`"\nThe user = "`id`

Assuming you're using bash as default interpreter.

Kind regards

edit flag offensive delete link more



Get the aliases and functions

if [ -f ~/.bashrc ]; then . ~/.bashrc fi

User specific environment and startup programs


export PATH echo -e "The date = "date"\nThe user = "id but did not work

nks gravatar imagenks ( 2013-11-03 10:24:17 -0600 )edit

Hi: the "echo" needs to be on a separate line. And in order to test it you need to start a new session, for instance going to another tty with alt+ctrl+f2, or ssh-ing to your own machine. Kind regards

casep gravatar imagecasep ( 2013-11-03 14:28:37 -0600 )edit

answered 2013-11-03 13:07:16 -0600

Marc lml gravatar image

Alternatively you could create a bash-script and start it at logon with Startup Applications Preferences. You can start this GUI tool with the following command.


The content of the bash-script could be something like this.

# print date
# print name
# wait for input

Don't forget to make the script executable!

chmod 755 /somewhere/
edit flag offensive delete link more

Question Tools


Asked: 2013-11-03 08:54:47 -0600

Seen: 6,669 times

Last updated: Nov 03 '13