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 can do an su with su <username> and it asks for my password. Is there a password parameter for su such that i wont be prompted for a password?

e.g. su <username> -p <password>

share|improve this question
It seems the question fits perferctly to superuser: :-) – HongboZhu Oct 7 '13 at 12:59
i got it from superuser here,… – alvas Oct 7 '13 at 13:08

I belive, there is not and it would not be a good idea. Here's why:
If you write a password in a command like su <username> -p <password>, it would be stored in plain text in your bash history. This is certainly a huge security issue.

If you need to run commands with su (or sudo) in an automated way, write a shellscript containig the commands without su or sudo and run su <username>

share|improve this answer

If you want to execute some specific commands as a new user, use the following command:
sudo -u {username} {command to be executed as the new user}

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.