What does `usermod -m` do?

QuestionsQuestions8 SkillsProDec, 22 2025
0115

The -m flag (short for move-home) is almost always used together with the -d flag. Its job is to physically move the contents of the user's current home directory to the new location.

Here is the breakdown of why it's important:

1. The Problem without -m

If you only run sudo usermod -d /home/wayne joker, the system updates its records, but:

  • The folder /home/wayne might not exist.
  • All of joker's files stay behind in the old folder (/home/joker).
  • When joker logs in, they might get an error because their "new" home directory is missing.

2. The Solution with -m

When you run sudo usermod -d /home/wayne -m joker:

  • Update: It changes the path in /etc/passwd.
  • Move: It takes all the files, folders, and hidden settings from the old directory and moves them to the new one.
  • Rename: If the destination doesn't exist, it renames the old directory to the new name.

Summary

  • usermod -d: Changes the label (the path listed in the system).
  • usermod -m: Moves the actual data to match that new label.

In a professional environment, you usually use them together:

sudo usermod -m -d /home/new_directory username

0 Comments

no data
Be the first to share your comment!