LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 06-22-2012, 07:51 AM   #1
kalangeamit
LQ Newbie
 
Registered: Jun 2012
Posts: 1

Rep: Reputation: Disabled
Change User Default Home Directoy


Hi Folks,
I am amit. New to linux. persuing for RHCE.
as we can change default home directory of user by using command :

#useradd -d /Home/Sales/s1 -m s1

But before firing this command, i will have to create "Sales" Directory in /home.
Can i create sales directory with s1 while creating user. i mean by using -p (which is used to add child directories) option or somehow ??


Regards,
Amit K.
 
Old 06-22-2012, 09:05 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
First - case is important in UNIX/Linux. /Home/Sales is different than /home/sales, /home/Sales and /Home/sales. It is not against the rules but would be unusual to have the base home directory (filesystem ideally) be /Home - it is typically /home. Also by convention users are usually lower case so it should really be /home/sales/s1 NOT /Home/Sales/s1.

Secondly - useradd -m creates the home directory but assumes the parents of the home already exist so you have to use mkdir to create /home/sales (or /Home/Sales if you want to do it despite above). The mkdir -p creates all intermediate directories. So if /home already existed doing "mkdir /home/sales" would be sufficient. If home DID not already exist you'd do "mkdir -p /home/sales" which would make both /home and its subdirectory sales. Using -p doesn't hurt anything if /home already exists so you can do so - I'm just noting that it isn't necessary.

You do NOT have to do "mkdir -p /home/sales/s1" because AFTER you do the "mkdir -p /home/sales" your "useradd -m" for s1 user will create s1's home directory under /home/sales and make s1 the owner of /home/sales/s1. There is no reason s1 should be owner of /home/sales itself. For the record mkdir allows you to set the permissions on directories it creates but not the ownership/group. You can change owner group of any file (including directories) with the chmod command.
 
  


Reply



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 default Apache webpage to a user home page Ericxx Linux - Server 9 08-11-2010 05:22 AM
[SOLVED] How can i change my HOME (/home/user) directory location to something else? QueenZ Linux - Newbie 6 08-05-2010 06:26 AM
Create user add file with default password and force user to change it? Morgandy Linux - Newbie 3 02-02-2010 05:06 PM
Change Default Home Directory with LDAP and Automount greslore Linux - General 3 06-23-2009 03:32 PM
setting default files for /home/user Strixy Linux - Software 7 07-16-2005 02:22 AM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 10:43 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
Open Source Consulting | Domain Registration