/home/user: change directory failed error
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.
ErraticFox
Updated on September 18, 2022Comments
-
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
thenpasswd 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 about 10 yearsAh, thank you! Is it actually vital to do groups?
-
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, likeaudio
. Start simple and add if the need arises. You can check current group membership with either of the commandsgroups
orid
-
Stephen Kitt almost 5 yearsIn this specific instance, it has nothing to do with SELinux; the home directory didn’t exist at all.
-
Andy Mikhaylenko about 3 yearsThank you, this was exactly my case.
-
Admin almost 2 yearsYou saved my day. Thank you!