15
5
How do I get a script to execute automatically when I log in? Not when the machine starts up, and not for all users, but only when I (or any specific user with the script) login via the GNOME UI.
From reading elsewhere I thought it was .bash_profile
in my home directory, but for me it has no effect. When I manually execute it in a terminal window by typing ~/.bash_profile
it works, but it won't run automatically when I log in.
I'm running Ubuntu 11.04. The file permission on my .bash_profile is -rwx------
. No .bash_profile existed in my home directory before I created it today.
I seem to remember older versions of Linux having a .profile
file for each user, but that doesn't work either.
How is it done? Do I need to configure something else to get the .bash_profile to work? Or does the per-user login script need to be in some other file?
http://askubuntu.com/questions/48321/how-do-i-start-applications-automatically-on-login – Ciro Santilli 新疆改造中心法轮功六四事件 – 2015-11-23T18:58:49.130
.bash_profile, .profile and .bashrc (Which is the one actually used by ubuntu) are loaded each time you open a bash terminal. So actually I'm not sure they will be loaded if you just login into GDM. – Juan Sebastian Totero – 2011-06-20T00:19:56.837
Do you mean when you log in to the GUI, or to the shell? – Flimzy – 2011-06-20T04:03:16.677
bash loads them when you start a new shell, so they will only get loaded when you open a terminal window or log into a virtual terminal, not when you log into Gnome (GDM). – shiftycow – 2011-06-20T04:24:32.400
@Flimzy - I mean when I log into the GNOME GUI, not the text-based shell. – Mike Rowave – 2011-06-20T15:07:20.343
Posting your Ubuntu version might help. In Ubuntu 10.10 .bashrc "works for me (TM)." – Vlueboy – 2011-06-20T03:39:49.100
I'm using Ubuntu 11.04, as I mentioned in the original question. – Mike Rowave – 2011-06-20T15:06:37.707
Oops. Sorry. You're not far off from my setup and I've also run into this. You can test putting an alias command alias mydir="ls -l" and logging out and back in. If mydir doesn't work, keep trying it with the "usual suspect" bash profile files that we've mentioned. Then, add your shell script to that file. Back in Solaris 2001 I only had .profile – Vlueboy – 2011-06-21T17:36:21.547
addition to @Vlueboy: For me, .bashrc runs whenever I open a terminal window (12.04) – Brad Hekman – 2012-07-24T13:58:31.117