If we have created a normal user User1, the default user's home directory for/home/user1, do experiment to prove can directly modify the/etc/passwd configuration file User1 home directory that field and change User1 home directory? (Hint: You can use the "CD ~" command to enter the current user home directory to verify the method)
[Email protected] ~]# Useradd user1
[[email protected] ~]# grep user1/etc/passwd
User1:x:502:503::/home/user1:/bin/bash
[Email protected] ~]# sed-i ' s#/home/user1#/tmp# '/etc/passwd
[[email protected] ~]# grep user1/etc/passwd
User1:x:502:503::/tmp:/bin/bash
[Email protected] ~]# Su-user1
-bash-3.2$ Echo $HOME
/tmp
-bash-3.2$ CD
-bash-3.2$ pwd
/tmp
Prove that you can change the user's home directory by changing the/etc/passwd
This article is from the "Sen Wang" blog, make sure to keep this source http://zhibeiwang.blog.51cto.com/7555525/1787779
Modify User1 's home directory directly