How to change your home directory in linux/unix
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.
Related post for changing home directory in Mac OS X can be found here.
12 comments:
It is much easier to do the following in "vi". try this..
In the command shell type:
# vi passwd
then edit the specific user.
thanks! your post helped me
I think I would leave /etc/passwd alone and use the command
#usermod -d /path/homedir
or if you want to move the stuff from the old /home/user then
#usermod -dm /path/homedir
It's in the man page for usermod.
oops left out something
it should be
#usermod -d /path/homedir login
Works in Red Hat and Fedora. Probably other flavors too.
Guys, you've forgoten the flag "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;
Note: don't use "sudo" if you are logged as root.
best regards
Its a very good question.It help to us.
For Change Working Directory.
cd / go to the root directory
cd go to your login (home) directory
cd ~username go to username's login (home) directory
not allowed in the Bourne shell
cd ~username/directory go to username's indicated directory
cd .. go up one directory level from here
cd ../.. go up two directory levels from here
cd /full/path/name/from/root change directory to absolute path named
note the leading slash
cd path/from/current/directory change directory to path relative to here.
note there is no leading slash
You should check this link and you get more information
Thanks...Your post helped me to do what i wanted badly
usermod won't let me change my home directory because it keeps saying I am logged in.
@topytopper Just log in with another user and then run the command.
You can use this command to see what users are defined on the system:
awk -F: '{ print $1 }' /etc/passwd
If you don't have another account you may need to create one before you can change the home directory?
Someone cmiiw
Thank you very much, your article was very usefull!
There may be noticeably a bundle to find out about this. I assume you made certain nice factors in features also. bovada casino
Post a Comment