I have the file ~/.xmodmap where i swap a few keys on my keyboard. This file was loaded properly on my previous Ubuntu desktop but since the upgrade to 12.04 it's no longer loaded when I login to my desktop.

What's the proper way to execute commands when we login to the desktop in ubuntu 12.04?

  • Try putting the xmodmap command in with the rest of your startup apps. Apr 18, 2012 at 8:11

3 Answers 3


search for "startup applications" in your dash. -Click on add -Name it and enter the command you want to execute -Click ok and restart to verify


Use "greeter-setup-script" and "session-setup-script" with Lightdm in /etc/lightdm/lightdm.conf.

The greeter-setup-script option runs the script (as root) before login.

greeter-setup-script = (Script to run when starting a greeter)

The session-setup script runs the script (as root) after login.

session-setup-script = (Script to run when starting a user session)
  • This answer is my favorite, but doesn't seem to work on Ubuntu Mate... saaad :(
    – user568021
    Apr 16, 2015 at 10:26

Actually there is a way to execute user specific commands during boot up time. The commands or scripts that we want to execute should be added to the script /etc/rc.local

The script /etc/rc.local will be similar to a shell script. Make sure it's exit status is 0 to avoid startup errors.

This /etc/rc.local script is executed at the end of each multiuser runlevel.


  • 2
    This answer is incorrect. rc.local is a shell script, and is executed outside of the X environment, and indeed as root, so it won't work for this requirement. Aug 28, 2012 at 12:28
  • @RobinGreen, In that case, what is the correct answer then?
    – Ram Murthy
    Jun 7, 2021 at 11:04
  • I guess either of the other answers on this page? Jun 7, 2021 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.