6

There is a script (more like a command) which I would like to be executed on a per user-login basis. I've heard of init.d scripts but those require root permissions and are not per-user customizable (AFAIK). Simply put, I am looking for something along the lines of .bashrc which would be executed only once per user login.

To detail a bit about the scenario, I currently use a Ubuntu guest OS on a Windows host (emulation courtesy of VirtualBox). Every time I login to my guest OS, I need a mount command to be executed which would mount my shared folders to a common directory in the user's home directory.

Gareth
  • 19,080
sasuke
  • 473

4 Answers4

5

The standard place for commands to run when you log in is ~/.profile. There are some environments where this file is skipped when you log in directly in graphics mode, but with Ubuntu 10.04, ~/.profile is read by gdm, kdm, lxdm and xdm login scripts (in addition to when you log in on a text console or over ssh).

If you have a ~/.bash_profile, your ~/.profile will sometimes be skipped. It is best to put only the following two lines in your ~/.bash_profile:

. ~/.profile
. ~/.bashrc

Then put login-time actions in ~/.profile and shell customizations in ~/.bashrc.

1

Maybe I didn't grasp all the subtleties, but I think that you can do that if you are using ubuntu, I guess that you could just write a script for each user (or a script with different rules depending on 'whoami') and, if they are using gnome (as it's default for Ubuntu), add that script to startup applications.

celebdor
  • 946
1

you can try the different options here: http://library.gnome.org/admin/gdm/stable/configuration.html.en , you probably want the PostLogin option

1

Linux cron (written by Paul Vixie, so called Vixie cron) has the meta keyword @reboot, which will start things as the crontab owner upon reboot. See http://www.cyberciti.biz/faq/linux-execute-cron-job-after-system-reboot/

Rich Homolka
  • 32,350