Monday, November 10, 2008

Changing the home directory of Linux user

How do you modify a user's home directory in Unix/Linux?
1. Login as a user with sudo privileges.
2. Enter this command:
sudo nano /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 jack is set to /home/jack in this file:jack:x:1000:1000:Jack,,,:/home/jack:/bin/bash

But I want him to use a home directory of /home/whatever. So I just change the above line to:jack:x:1000:1000:Jack,,,:/home/whatever:/bin/bash

Now when the user jack logs in, his home directory would be /home/whatever.