Change Default Home Directory for User in Centos

Everytime users created, it will keep per line inside /etc/passwd.
The line has the following characteristics:
1. It begins with the username.
2. There is an x for the password field indicating that the system is using shadow passwords.
3. A UID greater than 499 is created. (Under Red Hat Enterprise Linux/CentOS, UIDs and GIDs below 500 are reserved for system use.)
4. A GID greater than 499 is created.
5. The optional GECOS information is left blank.
6. The home directory
7. The default shell is set to /bin/bash.

Open /etc/passwd with VI :
#vi /etc/passwd

Find username that you want to change its default home directory, press i (for insert in VI) then retype a new home directory. DO NOT CHANGE OTHER INFORMATION, just home directory (e.g /home/username/). Then press wq! (for write and quit in VI)

You can set a home directory when you created user by adding -d to useradd , e.g useradd -d

One Comment to “Change Default Home Directory for User in Centos”

  1. Felipe Alvarez 18 June 2008 at 5:08 pm #

    You forgot to press “Esc” (important) before typing “:wq!” (with a colon)


Leave a Reply