LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-23-2012, 02:20 PM   #1
nerdy1
LQ Newbie
 
Registered: Dec 2012
Posts: 3

Rep: Reputation: Disabled
to change the home directory of a user by using usermod


i want to change the
linus(/home/linus)
to
linus(/home/linus/gnu/linux)

i tried the following commands to do it:
#useradd linus
#mkdir -pv /home/linus/gnu
#usermod -d /home/linus/gnu/linux -m linus

but its not creating the user in the specified location
after logging iinto the user and using the "pwd" command it shows "/"
directory instead of "/home/linus/gnu/linux"
 
Old 12-23-2012, 03:44 PM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,254

Rep: Reputation: 314Reputation: 314Reputation: 314Reputation: 314
Does directory "/home/linus/gnu/linux" exists and have "rx" permission for owner and owner is "linus"?
 
Old 12-23-2012, 03:59 PM   #3
nerdy1
LQ Newbie
 
Registered: Dec 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
The directory "/home/linus/gnu" exists and have the "rwx" permission. The ownership belongs to "linus".
 
Old 12-23-2012, 09:17 PM   #4
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
As you said, you want to change user's home from /home/linus to /home/linus/gnu/linux, which means /home/linus exists and is user's home directory. But when you switch to user it gives you "/", which is root's home directory.
So once check /etc/passwd file entry for the user linus, as:
Code:
grep linus /etc/passwd
And check what's mentioned there?
 
Old 12-24-2012, 02:37 AM   #5
nerdy1
LQ Newbie
 
Registered: Dec 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
"linus:x:1001:100::/home/linus:/bin/bash"

This is when the home directory is "/home/linus". And when i change the home directory by the "usermod" command to "/home/linus/gnu/linux" the "grep linus /etc/passwd" gives this output

"linus:x:1001:100::/home/linus/gnu/linux:/bin/bash".

and i get the "/" home directory in the user login after i have done this changes to the user. when my home directory is "/home/linus" i don't experience any problem but as soon as i change the home directory, the user's login shows "/" for "pwd" command

Last edited by nerdy1; 12-24-2012 at 03:03 AM.
 
Old 12-24-2012, 04:37 PM   #6
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,254

Rep: Reputation: 314Reputation: 314Reputation: 314Reputation: 314
Yes, but I ask about "/home/linus/gnu/linux", check also all parent directories if user linus has "x" permission for it. It need to traverse these directories. You can use "su linus" as root and check if you can do "cd /home/linus/gnu/linux".
 
Old 12-24-2012, 09:50 PM   #7
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
This seem some problem with user's profile. Somewhere
Code:
cd /
is set in user's shell initializations file, so when you switch to that user's account, then instead of /home/linus/gnu/linux, it loads "/" directory.
Once check:
Code:
grep "cd" .bashrc .profile
OR
grep "cd /" .bashrc .profile
(You will need to do some work to find out this entry). If you find any entry, just edit the corresponding file, and put a "#" against it to stop your shell reading it.
 
Old 12-25-2012, 09:25 AM   #8
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,254

Rep: Reputation: 314Reputation: 314Reputation: 314Reputation: 314
It could be, but more probably is that user linus cannot switch to his home directory. Then "/" is default.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
CHANGE HOME DIRECTORY USING usermod -dm crahuldba@gmail.com Linux - Newbie 5 11-01-2015 09:28 PM
[SOLVED] How can i change my HOME (/home/user) directory location to something else? QueenZ Linux - Newbie 6 08-05-2010 06:26 AM
How change a userīs home directory? Roxxor2 Linux - Newbie 3 08-29-2009 06:32 AM
change user home directory from command line cccc Debian 1 03-23-2006 05:07 PM
how to change a user's Home directory n1wil Linux - General 8 08-24-2002 03:22 PM


All times are GMT -5. The time now is 12:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration