This question already has an answer here:

My current understanding is that commands added to these two files are run every time a new terminal is open. Is that correct? Because in a lot of places I see suggestions to put there commands I want to be executed at login, but if they get executed every time I open a new terminal, then I do not want that. Can you help me understand how they work? Also what is the difference between them?

If I understand them correctly, then where can I put commands that I want to be executed only on login, but not every time a new terminal is opened? I know that I can do that from the GUI for "startup applications", but I am interested in doing this in a file, if possible.

marked as duplicate by Pilot6, muru, Eric Carvalho, Community Feb 29 '16 at 14:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • For launching some GUI based apps use "startup applications". Thsta the correct way. If you wish to run some daemon or script after reboot - use cron: crontab -e and add @reboot your_command or /path/to/script.sh – Ivan Temchenko Feb 28 '16 at 15:57
  • for some good info on this and how it works: man bash and skim to "Invocation". – Rinzwind Feb 28 '16 at 17:39
  • Thing is that I have created several chrome desktop apps that run in separate windows by choosing "More tools > Add to desktop" from chrome, and I can run them by clicking the shortcut on the desktop. I want to run some of them on startup and I have tried adding these commands to "startup applications", but I have a weird problem - only one of them can be in startup applications at a time - when I add another one it overwrites the previous one. I can add other applications just fine. I am guessing that this has something to do with the fact that they are all instances of chrome? – user3556519 Feb 28 '16 at 18:46

To put it (very) simple: ~/.profile is sourced when you log in, while ~/.bashrc is sourced when you open a terminal window.

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