I did this in Ubuntu Natty (11.04):
sudo useradd -m user_a
and next:
sudo adduser -m user_b
Of course I put password on both of them, let's say "123456" (weak one, I know :) ). And then, if I did:
su - user_aI got:
$Just plain dollar sign. "Uhm, what's wrong?".
But, if I did:
su - user_bI got:
user_b@localhost $
Grrrr.... I quickly concluded that something is different in their bash initialization. So a quick:
sudo diff -Naur /home/user_a/ /home/user_b/should pin point the difference if there are any, right away. But I was wrong. They were exactly identical.
Then I decided to take a peek at /etc/passwd. No strong reason though, just plain curiousity:
grep -E 'user_a|user_b' /etc/passwdthe result:
user_a:..........:/bin/sh[The passwd entries are shortened to focus on the important fields only]
user_b:..........:/bin/bash
Great! We found it! "But wait, isn't that /bin/sh a symbolic link to /bin/bash?". Well yes, at least sometimes ago. But recently, at least on latest releases of Ubuntu and its derivatives, /bin/sh is now pointing to "dash".
Dash is a "bash" alike shell but with smaller file size and fewer capability, which result to incompabilities with Bash in many aspects. So, no wonder that ".bashrc" didn't initialize the shell prompt along with other thing (enabling Tab completion, IIRC) correctly.
Therefore, to fix the useradd behaviour, simply use:
sudo useradd -s /bin/bash user_a
Another case closed, folks :)
PS: It's really a wonder how much you can do with grep and diff, if you know where to look ..... :D
NB:
regards,
Mulyadi Santosa
2 comments:
very nice information..
i like it.
Very nice article. Thanks for sharing.
Post a Comment