Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What file should I modify to execute some instructions when any user logs in through gdm?

I tried /etc/bashrc but that is executed ony when starting bash (and each time an xterm is open). I'd like to execute something only once when the user logs in.

What I want to do is to "reset" some user preferences each time the user logs on (including the window manager), so the script should run before the WM is initialized.

share|improve this question
4  
Why do you want to annoy your users like that? –  Keith Aug 12 '11 at 8:12
add comment

3 Answers

up vote 6 down vote accepted

The solution that seems to work best for me is to edit /etc/gdm/PostLogin/Default. This is executed just after the user logs in with gdm. Just what I wanted.

share|improve this answer
add comment

On Debian and derivatives you can modify /etc/profile, don't think it is universal, though.

share|improve this answer
    
This is only for shell logins - and the OP pointed he was not interested in such solution. –  rozcietrzewiacz Aug 12 '11 at 7:48
1  
@rozcietrzewiacz: this also works for GDM logins, because it reads /etc/profile (see /etc/gdm/Xsession). There is not a general rule for all DMs, I think. –  enzotib Aug 12 '11 at 8:21
    
Hm... Maybe it is, I don't know - but did you check when else it is sourced? One can do some testing of the login setup of course, but then you should describe this approach more. –  rozcietrzewiacz Aug 12 '11 at 8:47
add comment

From the man page:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

When a login shell exits, bash reads and executes commands from the file ~/.bash_logout, if it exists.

When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc and ~/.bashrc.

For change the WM of your users: uninstall kdm/gdm/xdm/slim, setup the WM in ~/.xinitrc and run "startx" from your bash config.

share|improve this answer
add comment

Your Answer

 
discard

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.