Shell Startup Scripts
Hacking Ubuntu to Improve Performance: Finding Process Startups
/etc/profile
#Used by every login shell, system-wide.
$HOME/.bash_profile
#Used on a per-user basis. Each user can have a personalized login script.
/etc/bash.bashrc
#Every interactive shell runs this system-wide configuration script.
$HOME/.bashrc
#Every interactive shell runs this user-specific configuration script.
/etc/bash.logout
#If you create it, this system-wide script is executed every time a user logs out.
$HOME/.bash_logout
#User-specific script that is used during logout.
All of these startup options can become very confusing. For example, if you want to automatically start Firefox on login, then you can add it to /etc/X11/Xsession, /etc/X11/gdm/Xsession, /etc/X11/gdm/PostSession/Default, /etc/X11/Xsession.d/99start_firefox, $HOME/.xsession, $HOME/.gnomerc, or use the graphical Gnome Session editor to add a startup applications. The main question to ask is, "who will want this?"
Inspecting Desktop Scripts
Beyond user-level shell scripts, the graphical desktop can also run scripts. First, X-Windows runs. This starts up applications by running the script /etc/X11/xinit/xinitrc, /etc/X11/Xsession, and /etc/X11/xinit/xserverrc. Each of these scripts set environment variables and can run applications. There are also startup scripts in /etc/X11/Xsession.d/ that are started after a user logs in, and individual users can have a $HOME/.xsession script for running applications at startup.
After X-Windows, the desktop starts. Under Ubuntu, this is Gnome. Gnome runs lots of applications that, in turn, can run many more applications. The main places to look for automatically running Gnome processes are in the /etc/X11/gdm/ directory, in the file $HOME/.gnomerc, and under System>Preferences>Sessions. The /etc/X11/gdm directory contains system-wide startup scripts.
- Everyone running X-Windows?—Use /etc/X11/Xsession or place the startup script under /etc/X11/Xsession.d/.
- Just you running X-Windows?—Use $HOME/.xsession.
- Everyone running Gnome?—Use /etc/X11/gdm/PostSession/Default. This will work for Gnome users, but not KDE or other desktops. KDE, XDM, and other desktops have their own configuration directories and files.
- Just you running Gnome?—Use $HOME/.gnomerc or the graphical session editor.
Note: These are not all of the possible startup hooks. There are plenty of places where code can be told to start running. If you are trying to find where an application starts, look here first or use ps and start tracking down parent processes. Most graphical processes use configuration files and any of those files could potentially run applications.
Read more...