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

I want to run this command every time I log in (or every time I start up, if that doesn't work): xmodmap -e 'keysym Delete = Menu' -e 'keysym Menu = Delete'

I've tried many things. I put the command in System > Preferences > Startup Applications. I put it in a .sh file, marked it chmod +x and put that file in System > Preferences > Startup Applications. I put the script in /etc/init.d. I put the commands in ~/.profile. Nothing seems to work.

Finally, I put this in my ~/.profile:

touch test1
xmodmap -e 'keysym Delete = Menu' -e 'keysym Menu = Delete'
touch test2

Both test1 and test2 get created, but the keys are still not remapped. If I just copy/paste the command and run it manually, it works fine. But it won't run on login. Any ideas?

share|improve this question
don't post the same question on multiple Stack Exchange sites (unless the question is on-topic on both sites and you've waited a long time and not had any good answer on the first site; but then include a link to the original question). – Gilles Sep 6 '10 at 21:32
@Gilles: Is that the official policy? It seems like if it is on-topic on both sites, then both sites can benefit from it. But if this has already been discussed and decided, I will be careful in the future. – Matthew Pirocchi Sep 18 '10 at 19:48
I thought there was an official FAQ entry about this, but I can't find it. I've asked on meta. – Gilles Sep 19 '10 at 13:19
up vote 2 down vote accepted

Depending on your distribution a ~/.xsession is executed (shell script) when logging into X. Or the ~/.Xmodmap is sourced by a xmodmap process.

~/.profile is only executed by a login shell (with or without X), thus it is not the right place

share|improve this answer

Put it in ~/.Xmodmap. Some distro look for ~/.Xmodmap instead of ~/.xmodmaprc. It works for me on Fedora 16.

share|improve this answer

Put it in ~/.xsessionrc and make sure that /etc/X11/Xsession.options contains allow-user-xsession.

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.