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

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


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


share|improve this question
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)
  emsg = "event not found";
  elen = 15;
  emsg = "bad word specifier";
  elen = 18;
  emsg = "substitution failed";
  elen = 19;
  emsg = "unrecognized history modifier";
  elen = 29;
  emsg = "no previous substitution";
  elen = 24;
  emsg = "unknown expansion error";
  elen = 23;

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


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.