Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to write bash shell script in Ubuntu 11.10 Linux distro, that will get executed automatically on logging into the system. But I am not able to figure out that what to write in script that by it will get automatically executed on logging in.

share|improve this question

If you want it to be global, modify


or add a script to


If you want it to be user-specific, modify

share|improve this answer

Just add the bash script to the Startup applications.

In the command field, enter

bash /full/path/to/bash/script.sh/
share|improve this answer
How do you add "bash /.../script.sh" to the Startup applications from the command line? – aleb Feb 1 '13 at 20:02
@aleb Who said anything about adding to Startup app from command line? I am just describing the way to do it using the GUI. If you want to try using command line, add a .desktop file in /home/$USER/.config/autostart. – jokerdino Feb 2 '13 at 10:00

If you want to be more bash specific you can also write you code in ~/.bash_profile or ~/.bash_login.

And you can source any script therein for example:

if [ -f ~/.bashrc ]; then
   source ~/.bashrc
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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