LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 05-02-2008, 01:47 PM   #1
thejonmoore
LQ Newbie
 
Registered: Jul 2005
Location: Kentucky
Distribution: Debain, Slack, Fedora
Posts: 18

Rep: Reputation: 0
Create home directories for existing users..


I've got a RHEL system with about 1,500 users. Each of these users were created without home directories for various reasons. Is there a simple (.. or difficult?) way of creating home directories for these users?
 
Old 05-02-2008, 02:02 PM   #2
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,007

Rep: Reputation: 366Reputation: 366Reputation: 366Reputation: 366
I don't think a system with 1500 users, without home directories, is going to work very well, if at all.
Perhaps you can explain your setup a bit more clearly:
How is it set up?
Why was it set up that way?
What are the problems you are experiencing? (ROFLMAO)
 
Old 05-02-2008, 06:53 PM   #3
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Rep: Reputation: 45
Sure, you should be able to write a script to automate this using a combination of shell scripting and awk. You know, match the username field from /etc/passwd that have a UID above 500, and create that username into /home and apply usermod -d /home/username username

Last edited by Micro420; 05-02-2008 at 06:56 PM.
 
Old 05-02-2008, 07:13 PM   #4
BlueRidgeMark
LQ Newbie
 
Registered: Dec 2007
Posts: 16

Rep: Reputation: Disabled
Quote:
Originally Posted by thejonmoore View Post
I've got a RHEL system with about 1,500 users. Each of these users were created without home directories for various reasons. Is there a simple (.. or difficult?) way of creating home directories for these users?
Jon, I'm with micro. I'm sure this can be done via a script, and I can't think of any other way to automate it.


Do you have any exposure to scripting? It really can be powerful, and it's not hard to learn.
 
Old 05-03-2008, 01:30 AM   #5
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Rep: Reputation: 45
Here's a dirty script to get you started. I know it's not efficient (does it even work??), but the logic is there, sort of ...

Code:
#grab regular users with user id above 500 from /etc/passwd
awk -F: '$3 > 499' /etc/passwd > uid500+.txt

#extract username, create home directory, and apply home directory to user
for users in `awk -F: '{print $1}' uid500+.txt`
do
mkdir /home/$users
usermod -d /home/$users $users
end

Last edited by Micro420; 05-03-2008 at 01:33 AM.
 
Old 05-03-2008, 07:31 AM   #6
BlueRidgeMark
LQ Newbie
 
Registered: Dec 2007
Posts: 16

Rep: Reputation: Disabled
Quote:
Originally Posted by Micro420 View Post
Here's a dirty script to get you started. I know it's not efficient (does it even work??), but the logic is there, sort of ...
Cool. The nice thing about doing a one-time thing like this is, efficiency doesn't really matter much (within reason!). The only thing you really care about is, does it work?

With 1500 to work through, I'd want some kind of logging and I'd want to give some thought to possible error conditions...
 
Old 05-05-2008, 06:10 AM   #7
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Lenny/Squeeze/Wheezy/Sid
Posts: 3,975

Rep: Reputation: 476Reputation: 476Reputation: 476Reputation: 476Reputation: 476
The scripting is trivial but I am still looking forward to the answer of the OP how he has a system running with users in passwd but without any home directories.

BlueRidgeMark: I would suggest to pipe all output of all commands into a log file. It can be done by enclosing blocks of Bash script in a dummy if-fi statement, and redirect that into a file.

jlinkels
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FTP virtual users with different home directories remi Linux - Software 14 07-27-2009 11:20 AM
Home Directories and Non Local Users issue cuco76 Linux - Software 2 04-26-2007 03:32 PM
Users' home directories as symbolic links mschutte Linux - Software 4 04-11-2007 02:04 PM
How to bind users to their home directories? trees Linux - Security 6 09-16-2004 05:32 PM
root unable to create directories in /home? cpv204 Solaris / OpenSolaris 6 11-25-2003 10:33 AM


All times are GMT -5. The time now is 01:44 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration