Forrest logo
back to the usermod tool

usermod:tldr:22350

usermod: Change a user home directory.
$ sudo usermod --move-home --home ${path-to-new_home} ${username}
try on your machine

This command is used to modify the user's home directory and move its contents to a new location. Here's a breakdown of the command and its components:

  • sudo: This is a command in Unix-like operating systems that allows a user with the appropriate permissions to execute a command as the superuser (or another user). It stands for "superuser do".

  • usermod: This is a command used to modify user account information in Unix-like operating systems.

  • --move-home: This option instructs the usermod command to move the content of the user's home directory to a new location specified with --home.

  • --home ${path-to-new_home}: This option allows you to set the new home directory for the user. ${path-to-new_home} should be replaced with the desired path for the new home directory.

  • ${username}: This is the username of the user whose home directory you want to modify. ${username} should be replaced with the actual username.

By executing this command with the appropriate values for ${path-to-new_home} and ${username}, you will move the user's home directory and its contents to the specified new location.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the usermod tool