Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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?
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)
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:
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
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.
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:
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
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...
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.