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?

Zanna
  • 70,465
ddd
  • 231
  • 1
  • 2
  • 5

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
  • 67,791
  • 32
  • 179
  • 269
  • however at the last step I get cp: cannot stat/etc/skel/*': No such file or directory` what does this do? – ddd Jan 06 '14 at 22:06
  • 1
    when I do useradd -D me it just outputs list of arguments. I have ran userdel me before – ddd Jan 06 '14 at 22:14
  • Please, edit your question and add the output of apt-cache policy passwd. – Braiam Jan 06 '14 at 22:15
  • @ddd also, you sure is user then add not add then user? Please use copy paste to be sure. – Braiam Jan 06 '14 at 22:16
  • 1
    following this instruction did not successfully resolve the problem. – ddd Jan 06 '14 at 23:45
  • 2
    @ddd but then tell what went wrong... edit your question and add the information... – Braiam Jan 06 '14 at 23:46
  • @ddd you missed the '.'. What you needed to do was cp /etc/skel/.* /home/me/ not cp /etc/skel/* /home/me/ – Egwor Nov 07 '19 at 12:24
  • 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 '20 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 03 '22 at 21:18
1

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
  • 11