Solved

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

Posted on 2007-11-14
9
3,053 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 500 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
 

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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
Fine Tune your automatic Updates for Ubuntu / Debian
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

932 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now