What happens if the new directory doesn't exist?

QuestionsQuestions8 SkillsProDec, 22 2025
0101

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:

  1. The System Doesn't Complain (Yet): The usermod command itself will succeed and update the /etc/passwd file. It assumes that you, as the administrator, will create the directory later.
  2. Login Issues: If the user joker tries 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 of joker@labex:~$) because their profile configuration files (like .bashrc) cannot be found.
  3. 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 -m flag along with -d to tell Linux to automatically create the new directory and move the user's files into it.

In this experiment, you modified the "phonebook entry" (the configuration), but you haven't built the "house" (the directory) yet!

0 Comments

no data
Be the first to share your comment!