Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

when I try to add line inside /etc/shadow:

echo -e "admin234:!!:0:0:99999:7:::" >> /etc/shadow

         1    2 3

The console show this message:

-bash: 0: unrecognized history modifier

or

-bash: :14790: bad word specifier (when change 3  to :14790: )

Help?

share|improve this question

3 Answers 3

up vote 4 down vote accepted

Yeah the !s are being interpreted by bash. Switch your "s to ' and it should be fine.

share|improve this answer

@Beginners, might want to ask the purpose of attempting to edit the /etc/shadow by hand in this manner, in other words, what is the desired outcome that you wish to achieve?

As for understanding the whole history of the errors you are receiving, depending on your knowledge and understanding of C, there is a wealth of informative documentation at the source archive. If you search specifically for the errors you are receiving, you will find them, and see that they relate to errors you are seeing:

static char *
hist_error(s, start, current, errtype)
      char *s;
      int start, current, errtype;
{
   char *temp;
   const char *emsg;
   int ll, elen;

  ll = current - start;

  switch (errtype)
{
case EVENT_NOT_FOUND:
  emsg = "event not found";
  elen = 15;
  break;
case BAD_WORD_SPEC:
  emsg = "bad word specifier";
  elen = 18;
  break;
case SUBST_FAILED:
  emsg = "substitution failed";
  elen = 19;
  break;
case BAD_MODIFIER:
  emsg = "unrecognized history modifier";
  elen = 29;
  break;
case NO_PREV_SUBST:
  emsg = "no previous substitution";
  elen = 24;
  break;
default:
  emsg = "unknown expansion error";
  elen = 23;
  break;
}

There may be an easier way to achieve the ends you desire, which is why I ask what that may be. If the ends are known, then the path is likely much traveled by many before, and an answer easier to deliver to assist you. ;)

Also, in reviewing the command, did not notice usage of the sudo convention, which would be necessary to complete any administrative function successfully. Remember that certain functions will not work without the correct privileges consumed at the time of execution.

HTH. Have a nice day. :)

share|improve this answer

History expansion only affects interactive shells when history expansion is enabled (which it is by default). You can disable history expansion by running set +H. I never use history expansion myself, so I put set +H in ~/.bashrc.

As for editing /etc/shadow manually, I'd advice against it. If you want to add users from the commandline, use adduser or newusers.

man 8 adduser
man 8 newusers
share|improve this answer

Your Answer

 
discard

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.