Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-31-2005, 07:39 PM   #1
Registered: Aug 2004
Distribution: Mandrake 10.1/Slackware 10.0
Posts: 154

Rep: Reputation: 30
I want to automatically run a program when a user logs on their account

I know how to use rc.local, but what about automatically running something in the X environment when the user first logs in?
Old 01-31-2005, 07:45 PM   #2
LQ Guru
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 235Reputation: 235Reputation: 235
Are you wanting this to be an X program or from a console or terminal?

Creating a .bash_login usually works for either way.
Old 01-31-2005, 07:48 PM   #3
Registered: Jan 2005
Distribution: Gentoo
Posts: 111

Rep: Reputation: 16
isn't that what .xinitrc is for? I may be misunderstanding your question, but in general when the X window system starts up, it checks for the .xinitrc file in the user's home directory. It will then execute what is in that. For instance, I have this:
xscreensaver &
xpenguins -n 36 &
which will execute the xscreensaver (starting it up), then xpenguins (giving me a bunch of crazy penguins running around everywhere ) and then finally starting my window-manager (enlightenment).

-- the dudeman
Old 01-31-2005, 07:55 PM   #4
Registered: Aug 2004
Distribution: Mandrake 10.1/Slackware 10.0
Posts: 154

Original Poster
Rep: Reputation: 30
I think we're on the same page, linuxluser, but I don't see that hidden file in my home directory. What next?
Old 01-31-2005, 11:52 PM   #5
LQ Newbie
Registered: Apr 2004
Location: Manitoba
Distribution: Mandrake 9.2 & 9.1
Posts: 12

Rep: Reputation: 0
Missing .xinitrc

I have the same problem, I never had a .xinitrc file in my home directory. I added one to run some commands to remap my mouse wheel so it will scroll properly, but the .xinitrc file never gets parsed (as far as I can tell). The .xinitrc file is shown below:

# (c) 2000-2002 MandrakeSoft
# $Id: xinitrc-xinitrc,v 1.2 2002/09/10 05:53:43 flepied Exp $

# Set a background here because it's not done anymore
# in Xsesion for non root users
if [ "`whoami`" != root ]; then
xsetroot -solid "#21449C"

# the following was added by CJW 2005-01-24 for wheel mouse support
/usr/X11R6/bin/xmodmap -e "pointer = 1 2 3 6 7 4 5"
BINARY=$(which imwheel)
$BINARY -k -p -b "67"
# end addition 2005-01-24

exec /etc/X11/Xsession $*

If I run the "/usr/X11R6/bin/xmodmap -e "pointer = 1 2 3 6 7 4 5"" in a shell everything works fine.

Note that I'm running Mandrake 9.2 and KDE with a graphical logon screen.

If anyone has any thoughts as to why .xinitrc doesn't get parsed, please let me know!

Old 02-01-2005, 11:57 AM   #6
Registered: Dec 2002
Distribution: Debian
Posts: 154

Rep: Reputation: 30
If I run the "/usr/X11R6/bin/xmodmap -e "pointer = 1 2 3 6 7 4 5"" in a shell everything works fine.
same for me I have to run xmodmap after I login. it isn't getting executed from the xinitrc file.
Old 02-01-2005, 08:20 PM   #7
Registered: Jan 2005
Distribution: Gentoo
Posts: 111

Rep: Reputation: 16
If you don't have .xinitrc then you can make it. The man pages (of startx) indicate that when the .xinitrc file exists, the session exits. You need to have everything run in the background except for the last command. That's why I had an ampersand on the end of every line except the last (which loads my window manager). If you don't, you can get a blank screen or a program unexpectantly exiting or something weird like that.

Sorry if I was unclear about that.

-- the dudeman

Last edited by linuxLuser; 02-01-2005 at 08:31 PM.
Old 02-01-2005, 08:55 PM   #8
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Graphical login managers (such as xdm, kdm, gdm) will
use the configuration file:


startx uses:


Try a
mv .xinitrc .xsession



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
run program after user logs in kinasz Linux - General 2 09-22-2004 03:47 AM
how to get citrix automatically started up when a user logs in. sjel Linux - Newbie 2 09-06-2004 08:40 AM
Automatically run root program. Hammett Linux - Software 4 05-16-2004 12:45 PM
Program runs when a user logs in mindstormsguy Linux - Software 2 03-31-2004 05:01 PM
Getting vncserver to run automatically when user logs in indespair Linux - Networking 2 10-26-2003 02:37 AM

All times are GMT -5. The time now is 04:22 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration