Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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'm trying to implement an automated root password change for our Linux boxes. I'm generating a hash in the script since users will be able to see the contents of the script.

I found that you can pass a hash with the usermod utility. However, I'm running into a variable substitution issue as seen below.


# usermod -p $1$0J8av/8N$LIKB2G56XJn2IXp0XzERo1 root

# grep root /etc/shadow
share|improve this question
up vote 4 down vote accepted

Surround the password on the usermod command with single quotes '' or escape the $ with '\$'

Like this

# usermod -p '$1$0J8av/8N$LIKB2G56XJn2IXp0XzERo1' root


# usermod -p \$1\$0J8av/8N\$LIKB2G56XJn2IXp0XzERo1 root
share|improve this answer
Thanks, the single quotes worked. I was trying double quotes. – kernelpanic Jan 4 '13 at 15:06
Double quotes, as you noticed, still allow for variable interpolation. Single quotes on the other hand, don't. – coredump Jan 4 '13 at 15:07

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.