?
Solved

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

Posted on 2007-11-14
9
Medium Priority
?
3,125 Views
Last Modified: 2013-12-16
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
0
Comment
Question by:vvvlad42
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 4

Expert Comment

by:jcoombes
ID: 20282235
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
 
LVL 4

Expert Comment

by:jcoombes
ID: 20282241
You should probably restart to be on the safe side after modifying the entry...
0
 
LVL 3

Accepted Solution

by:
bayesianmind earned 1500 total points
ID: 20282319
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:vvvlad42
ID: 20282507
bayesianmind:
Thanks.
Already found this, but it appears that I deleted the dir (accidently)
How can I create dir with appropriate ownership?
0
 
LVL 3

Expert Comment

by:bayesianmind
ID: 20282545
mkdir /path/to/new/dir
chown -R user:usersgroup /path/to/new/dir
0
 
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 20282575
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
 
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 20282734
But the correct way is to create it from the skeleton directory. This is what adduser does.
0
 
LVL 3

Expert Comment

by:bayesianmind
ID: 20282769
KeremE, you are right, but usually this directory is empty anyway.
0
 
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 20285645
it should not be :)
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses
Course of the Month15 days, 15 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question