Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

At our computer department we need to run a script with user rights wenn the user logs in. Adding the script to .config/autostart is not an option since the script must not be disabled by the user.

The Problem with for example the session-setup-script directive in lightdm.conf is that the script is run by root. We would therefore need to determine what users is currently trying to login and su to that user. That seems tricky since multiple users could already be logged in on the very same machine.

Is there a proper to way to do this?

Thanks in advance

share|improve this question

There may be a neater way to do this in lightdm, but it should presumably be possible to edit the session files in /usr/share/xsessions. Replace the Exec line, eg Exec=gnome-session --session=ubuntu with the path to a wrapper script which calls your scripts and then starts the session.

This should be executed in the user's context and not be disableable.

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.