Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 am using a command to start a screen session and run a bash script for a user.

/bin/su username -c "/usr/bin/screen -dmS test bash -c '/home/username/; exec bash'"

When I boot, I am seeing the screen session appear for that user, but when I open it, I see a permission denied error.

I checked permissions on the file and it is: -rw-rw-r-- 1 username www-data 816 Feb 18 00:59

Anyone have a theory why I am seeing this error? I can run the script no problem when I am logged in as username.

share|improve this question is not executable. So you can run it by passing it as an argument to a shell, as in bash /home/username/, but you can't run it directly as a program like in your example command. Run chmod +x /home/username/ to make it executable.

If is doing things like setting environment variables, they only survive for the duration of the process. So if you run /home/username/; exec bash then the final interactive shell won't have the environment variables from that process. To keep the environment variables, set them in the parent bash process: source the script, instead of running it as a separate program.

/bin/su username -c "/usr/bin/screen -dmS test bash -c '. ~/; exec bash'"
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.