/home/user: change directory failed error

17,713

Solution 1

You need to tell useradd to create your home directory:

useradd -m fox

You might also want to add options for group(s) -g -G, login-shell -s etc.

But don't worry - you can create your homedir now (as root using sudo or su):

# mkdir /home/fox
# chown fox:fox /home/fox

See Arch Linux Documentation - User Management

Solution 2

It's actually a SELinux issue. Not sure about Arch Linux's configuration but I encountered it when replacing my home directory with another (i.e. restoring it from a backup). You can check it yourselves with

ls -lZ /home

That prints out SELinux labels. Your home directory should have the user_home_dir_t label. The fix is straightforward:

restorecon -R /home

A longer discussion can be found in the Fedora forums.

Share:
17,713
ErraticFox
Author by

ErraticFox

Updated on September 18, 2022

Comments

  • ErraticFox
    ErraticFox over 1 year

    I just installed Arch reading from the Beginners' Guide on the Arch Wiki. Once I rebooted Arch, I logged into root then I added my own personal account: useradd fox then passwd fox and set my password for the account. Once I logged in with fox I was prompted with the error --fox: /home/fox: change directory failed: No such file or directory. Logging in with home = "/".

    Why I'm receiving this error and how I can fix it?

  • ErraticFox
    ErraticFox about 10 years
    Ah, thank you! Is it actually vital to do groups?
  • grebneke
    grebneke about 10 years
    @ErraticFox - No, I think the default for Arch is to create a group with the same name as the user, so your group is now most likely fox. For some applications it is necessary to add extra groups, like audio. Start simple and add if the need arises. You can check current group membership with either of the commands groups or id
  • Stephen Kitt
    Stephen Kitt almost 5 years
    In this specific instance, it has nothing to do with SELinux; the home directory didn’t exist at all.
  • Andy Mikhaylenko
    Andy Mikhaylenko about 3 years
    Thank you, this was exactly my case.
  • Admin
    Admin almost 2 years
    You saved my day. Thank you!