23

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?

5
  • 2
    how did you create the new user?
    – MattDMo
    Jan 6, 2014 at 21:50
  • 2
    that answer is not at all related to this question and does not help me.
    – ddd
    Jan 6, 2014 at 21:53
  • What command you used to create the user? Also add to your question the output of cat /etc/passwd.
    – Braiam
    Jan 6, 2014 at 21:54
  • adduser me, passwd me
    – ddd
    Jan 6, 2014 at 21:55
  • 2
    Please add the output of getent passwd $USER to your question Jan 6, 2014 at 21:56

2 Answers 2

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
9
  • 1
    when I do useradd -D me it just outputs list of arguments. I have ran userdel me before
    – ddd
    Jan 6, 2014 at 22:14
  • 1
    following this instruction did not successfully resolve the problem.
    – ddd
    Jan 6, 2014 at 23:45
  • 2
    @ddd but then tell what went wrong... edit your question and add the information...
    – Braiam
    Jan 6, 2014 at 23:46
  • 1
    @Braiam, I had similar issue and went through your instruction. The last line(cp /etc/skel/.* /home/me/) gives me error: 1. cp: -r not specified; omitting directory '/etc/skel/.' 2. cp: -r not specified; omitting directory '/etc/skel/..' any idea?
    – Shannon
    Jul 14, 2020 at 20:29
  • 1
    @Shannon The copy worked on the three hidden files (.profile, .bashrc, .bash_logout), and (properly) failed to copy the directories "." (chrrent directory) and ".." (parent directory). Every directory gets the . and .. automatically, so the command worked.
    – ubfan1
    Sep 3, 2022 at 21:18
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .