Solved

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

Posted on 2007-11-14
9
3,052 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

16 Experts available now in Live!

Get 1:1 Help Now