If the new directory specified with the -d flag in the usermod command does not exist, the following will occur:
-
No Automatic Creation: The
usermodcommand will not create the new home directory automatically. The command will succeed, but the user's home directory will be set to the specified path, which will be empty or non-existent. -
Potential Issues: If the new home directory does not exist, the user may encounter issues when trying to log in or access their home directory, as there will be no directory to access.
Recommended Action
To avoid these issues, you should:
-
Create the Directory: Manually create the new home directory before running the
usermodcommand. You can do this using:sudo mkdir /new/home/bob -
Use the
-mFlag: If you want to move the contents of the old home directory to the new one, use the-mflag along with-dto ensure the directory is created and the contents are moved:sudo usermod -d /new/home/bob -m bob
If you have more questions or need further clarification, feel free to ask!
