How do I change the default home path in linux using command line?

Hello Experts,
I recently installed kubuntu. Wanted to change the path to home and used some graphical utility to do that. Everything went fine untill restart.
X wouldn't go up, because permissions issues with the new home.
How can I restore the default home path?

Thanks
vvvlad42Asked:
Who is Participating?
 
bayesianmindConnect With a Mentor Commented:
A little more detail on this:

The default home directory is stored in /etc/passwd as has been said.
The file is a big list of users, and each line looks like this:
username:x:UID:GID:comment:homedir:shell

So you want to modify the second to last entry, probably to set it back to /home/username. Be careful in /etc/passwd not mess up the file. An easy editor that will edit nicely is nano -w (make sure you use the -w). Vim also works but its complicated if you don't know how to use it already.
0
 
jcoombesCommented:
You could try modifying the home directory in the /etc/passwd file for your user.  In order to do this log on as this user (if you can) or root and then edit /etc/passwd within vi or a similar command line editor.

Cheers

JC
0
 
jcoombesCommented:
You should probably restart to be on the safe side after modifying the entry...
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
vvvlad42Author Commented:
bayesianmind:
Thanks.
Already found this, but it appears that I deleted the dir (accidently)
How can I create dir with appropriate ownership?
0
 
bayesianmindCommented:
mkdir /path/to/new/dir
chown -R user:usersgroup /path/to/new/dir
0
 
Kerem ERSOYPresidentCommented:
oh it is simple just copy over the skleton user directory to the new home and change owner such as this:

cp -R /etc/skel /newhome/user
chown -R user.group /newhome/user

That is it. In the first step you've created default user files and in the second step your user and group is the owner of the new directory recursively. the "-R" switchdoes this.

Cheers,
K.
0
 
Kerem ERSOYPresidentCommented:
But the correct way is to create it from the skeleton directory. This is what adduser does.
0
 
bayesianmindCommented:
KeremE, you are right, but usually this directory is empty anyway.
0
 
Kerem ERSOYPresidentCommented:
it should not be :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.