homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

How do I do stuff on user creation?

 8:47 am on May 4, 2010 (gmt 0)

I'm fed up of manually setting up NFS shares :(

How would I go about, on creating a user, creating some extra subdirectories in their home directory (is there a skeleton template somewhere) and adding some entries to /etc/fstab (I assume this will take some scripting to append the new entries to the end, but how do I trigger it?)



 12:22 pm on May 4, 2010 (gmt 0)

The skeleton directory is usually /etc/skel - adduser can copy the contents of this directory when creating a user (note: I only know about Debian/Ubuntu, don't know if this is the same for other distros). For the rest, I guess you could write a bash shell script to automate everything.


 3:04 pm on May 4, 2010 (gmt 0)

/etc/skel is also the skeleton directory for the RedHat family Linux distributions. There is no integrated scripting in the adduser or useradd tools (on some systems adduser and useradd are different commands) where you can add the creation of mount points in the /etc/fstab directory. If you want to perform all actions in one pass, a container shell script is needed which calls the adduser program and some home made scripting to update the fstab file.


 3:10 pm on May 4, 2010 (gmt 0)

Thanks encyclo - that's the easy part then, and I'm using Ubuntu (although I might be reverting to Kubuntu again as I keep finding that the preferences I want to set have been omitted in Ubuntu).

Now, I can probably cobble together a script to append lines to fstab, but can anybody tell me how I trigger it on user creation?


 3:14 pm on May 4, 2010 (gmt 0)

Never mind, I've got a new approach. Write a script to handle the lot. Pass in username, uid and gid, then the script can create the group, add the user and do the appending to fstab... and I have to run even fewer commands to setup a user (which I need to do on the commandline anyway because easy-to-use *&^%* Ubuntu won't let me specify a uid (not that it always worked in previous versions of Kubuntu anyway!)).

<edit>Yay! I finally reached post 100!</yay>
<edit again>I must have been typing while you were posting lammert. Thanks for confirming what I suspected</edit_again>

Global Options:
 top home search open messages active posts  

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved