That is a very insightful question!
If you change the home directory path using usermod -d to a location that doesn't exist (like you just did with /home/wayne), here is what happens:
- The System Doesn't Complain (Yet): The
usermodcommand itself will succeed and update the/etc/passwdfile. It assumes that you, as the administrator, will create the directory later. - Login Issues: If the user
jokertries to log in:- Terminal Login: They will see an error message like: "No directory, logging in with HOME=/".
- Defaulting to Root: Instead of starting in their home folder, they will be dropped into the root directory (
/). - Limited Functionality: Many things won't work correctly. They won't be able to save personal settings, and their shell prompt might look broken (e.g., just
$instead ofjoker@labex:~$) because their profile configuration files (like.bashrc) cannot be found.
- The Fix: As an administrator, if you change a path with
-d, you usually need to do one of two things:- Manually create the directory:
sudo mkdir /home/wayne && sudo chown joker:joker /home/wayne - OR (The better way) use the
-mflag along with-dto tell Linux to automatically create the new directory and move the user's files into it.
- Manually create the directory:
In this experiment, you modified the "phonebook entry" (the configuration), but you haven't built the "house" (the directory) yet!