How to change your home directory in linux/unix
Option - 1
How do you modify a user's home directory in Unix/Linux?
1. Login as a user with sudo privileges.
2. Enter this command:
vim /etc/passwd
3. Nano text editor opens up. Locate the username you would like to change the home directory of (the last added user is in the end), and just enter whatever directory you would like. For example, the home directory for the user vijay is set to /home/vijay in this file:
vijay:x:1000:1000:vijay,,,:/home/vijay:/bin/bash
But I want him to use a home directory of /home/whatever. So I just change the above line to:
vijay:x:1000:1000:vijay,,,:/home/whatever:/bin/bash
Now when the user vijay logs in, his home directory would be /home/whatever.
Option - 2
"m" is to move the files and content from the old home directory to the new. So the correct scripts is:
sudo usermod -md /my/new/home userid;
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.