25

I am using 12.04 on my server.

I created a new user using adduser me and passwd me and added it to sudo.

When I log in this is what I see.

Could not chdir to home directory /home/me: No such file or directory    
$

I type bash and it begins to look "normal"

$ bash
me@server:/$

How can I avoid typing bash every time I login?

Zanna
  • 72,312
ddd
  • 251

2 Answers2

31

adduser is too basic and doesn't set the defaults properly. It's recommended to use useradd whenever is possible. You can remove the new user and create it again with useradd -D me or repair it yourself:

sudo mkdir /home/me
sudo usermod --shell /bin/bash --home /home/me me
sudo chown -R me:me /home/me
cp /etc/skel/.* /home/me/

If you had used getent passwd me as Florian suggested you should have seen something like this:

sudo getent passwd me
boggus:x:1002:1002::/home/me:/bin/sh

And ls /home wouldn't shown the user directory as your error:

Could not chdir to home directory /home/me: No such file or directory
Braiam
  • 69,112
2

The fastest way to get this problem resolved is to delete the user and use this command to create the new user

useradd -m -d /home/me -s /bin/bash -G sudo me

This command creates a home directory and add bin/bash as the default shell for your new user. In addition it gives the new user sudo privileges.

J A
  • 21
  • 2