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
  1. Where should I put a bash script if I want it to be executed once during X startup as part of system bootup. For example, I want to start up VPN on my machine as root user once X starts up.

  2. When X initializes (lets say GDM in my case) or when a user logs in using a DM (desktop manager) is it considered a login shell?

  3. Also I would like to run programs as long as I am logged in using X. For example, I want to run Dropbox as long as I am logged in using Gnome.

share|improve this question

migrated from stackoverflow.com Jun 8 '12 at 14:49

This question came from our site for professional and enthusiast programmers.

For your question 1, should be in /etc/rc5.d. See this table for the various run levels – karthik Jun 8 '12 at 11:50
Any attempts to read manuals there? – poige Jun 9 '12 at 4:14

Anything you want to run when a user logs into an X session, you want to put in the .xinitrc or .xsession file in the user's $HOME.

This page has a pretty good explanation:


share|improve this answer

You should put them in .xinitrc . This is mine :

#Map Capslock to ESC
setxkbmap -option caps:escape &
feh --bg-scale /mnt/data/Dropbox/pic/character/samurai.png
#turn off beep sound
xset -b
#mouse speed
xset m 1/5
#keyboard repeat speed
xset r rate 200 30
xset +fp /usr/share/fonts/local
xset fp rehash
#urxvtd daemon
urxvtd -q -f -o &
#Disable touchpad tapping and scrolling when typing
syndaemon -t -i 2 &
#Hide cursor
unclutter -keystroke &
#Redshift - change your screen temp to reduce eyestrain
redshift &
# Dropbox
dropboxd &
#dwm status
while true
  xsetroot -name "nXqd"
    sleep 20s
done &
#Window manager
exec dwm
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.