Change Default User Home Directory While Adding a New User:


You can add user using regular useradd command with  -d option:

#useradd –d /tmp/home/admin admin
#passwd admin

How Do I Change Existing User's Home Directory?

You need to use the usermod command to set the user's new login directory. The syntax is as follows:
#usermod -m -d /path_to_new_home_directory userName
Where,
1.       -d dirnanme : Path to new login (home) directory.

2.       -m : The contents of the current home directory will be moved to the new home directory, which is created if it does not already exist.

No comments:

Post a Comment