Command is as below, which is executed on wind river linux manchine.

useradd vpatest -c Pav -g guest -G log -s /data/bin/cli.sh -p $6$cem^CM38$4YdQAPgu8EXNG3ecurYk4eN1sIiYNauBdHFRJew3l/Xa8PyOjACD1xNDhoocVwBzBUN9BlTXXJ/oiWHwV.fhL1

In the /etc/shadow file it is writing only

YdQAPgu8EXNG3ecurYk4eN1sIiYNauBdHFRJew3l/Xa8PyOjACD1xNDhoocVwBzBUN9BlTXXJ/oiWHwV.fhL1 and truncating $6$cem^CM38$4

Any way to avoid this and write the full password? I will get encrypted password and need to write as it is in the shadow file. Otherwise, is any other utilities that can be used?

  • can you use it inside ''? – SouravGhosh Dec 21 '17 at 10:08
  • well, $6 and $4 are positional parameters, and $cem is a valid variable, so they'll be expanded by the shell. Though ^ isn't a valid part of a variable name, so I can't see why the ^CM38 part would disappear. Put the string in single quotes to prevent the parameter expansion. – ilkkachu Dec 21 '17 at 10:21

Since your input string (password) contains characters that can be interpreted by the shell to have a special meaning (for ex. $), wrap the password string inside a pair of '', like

 useradd vpatest -c Pav -g guest -G log -s /data/bin/cli.sh -p '$6$cem^CM38$4YdQAPgu8EXNG3ecurYk4eN1sIiYNauBdHFRJew3l/Xa8PyOjACD1xNDhoocVwBzBUN9BlTXXJ/oiWHwV.fhL1'

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.