Koozali.org: home of the SME Server

Managing user directories

Gavin

Managing user directories
« on: May 24, 2001, 02:03:32 PM »
Hi,
I was hoping someone out there could help me as i'm new to this. I was wondering how you can manage a users workspace.The problem I have is once I create a user with his/her own work space I can't see how much space they are taking up on the server when they start using it.

Thanks in advance,

Gavin

Nathan Fowler

Re: Managing user directories
« Reply #1 on: May 24, 2001, 11:06:57 PM »
Gavin, login to the E-Smith system.

From the console prompt type
du -h --max-depth 1 /home/e-smith/files/users |more

This gives you a list of all your users, the space each one is taking, and the total space used.

Hope this helped
Nathan Fowler

Allen Rapini

Re: Managing user directories
« Reply #2 on: May 25, 2001, 07:31:54 PM »
Very nice Nathan. It works for ibays too with the substitution for ibays instead of home...

Thanks

Allen

Nathan Fowler

Re: Managing user directories
« Reply #3 on: May 25, 2001, 07:44:33 PM »
Thanks, glad you found it useful :)  You can always take that a step further and schedule a cron job execute every 15 minutes to:

du -h --max-depth 1 /home/e-smith/files/users > /home/e-smith/files/primary/html/useraudit.html

chmod 777 /home/e-smith/files/primary/useraudit.html


You could then access this information any time you wanted from the main website.  Obviously this simple script could be adapted to provide more features/checking, like the inclusion of Ibays.

Thanks,
Nathan Fowler

sidney

Re: Managing user directories
« Reply #4 on: May 25, 2001, 10:48:46 PM »
This is some good information!

Could you tell me more about scripts
and how to schedule this script ?

do you execute it from the useraudit.html web page or does it run it's own and show the results on that web page.

if you have any more good tips like list please share.


Thanks

Kirrily Robert

Re: Managing user directories
« Reply #5 on: May 25, 2001, 10:54:11 PM »
Nathan Fowler wrote:
>
> Thanks, glad you found it useful :)  You can always take that
> a step further and schedule a cron job execute every 15
> minutes to:
>
> du -h --max-depth 1 /home/e-smith/files/users >
> /home/e-smith/files/primary/html/useraudit.html
>
> chmod 777 /home/e-smith/files/primary/useraudit.html

Whoa, wait a minute -- you don't want to chmod 777, that'll make the file writable by everyone on the system.  A much better thing is to "chmod 644 /home/e-smith/files/primary/useraudit.html" which will make it readable by anyone but only writable by the owner.

Placing this HTML file in the primary web directory is also a security risk... anyone who wants to can see it.  I'd suggest creating a special i-bay for system administration purposes,
and making it readable only by the Admin group.  That will prevent people seeing who has accounts on your system and other potentially private information.
 
K.

Kirrily Robert

Re: Managing user directories
« Reply #6 on: May 25, 2001, 11:03:32 PM »
sidney wrote:
>
> This is some good information!
>
> Could you tell me more about scripts
> and how to schedule this script ?

This isn't actually a script, it's just a simple command.  A script is a file which contains a number of commands which are executed one after the other, or possibly in response to certain conditions.  When scripts start to get more complex, they become computer programs, and can be decidedly non-trivial to write and maintain!

Nathan's suggested that the command should run regularly by the "cron" system.  The cron system (it's a short name for "chronological", i.e. time-related) is used on Linux and other Unix systems to schedule tasks to run regularly.  For instance, it's used by our tape backup system to schedule backups daily, and by our mail fetching routines to check mail at the specified intervals (if you use ETRN/multidrop).

Any good book on Unix system administration should explain the cron system for you.  
 
> do you execute it from the useraudit.html web page or does it
> run it's own and show the results on that web page.

It runs on its own, and the output (which you'd normally see on the screen when you run the command from the command line) are instead directed to the web page.

Nathan's got the output going to an HTML file, but I don't think that will work.  It would be much better to redirect it to useraudit.txt so the web browser you use to view it will know it's a plain text file, not a prettified HTML file with all the tags and so forth.  If you call the file useraudit.html your web browser will probably display the whole thing as one long line all strung together, rather than each user on her own line.

This topic's getting pretty technical for the General Discussion forum, though, and is probably better suited to the developer mailing list.

K.

Nathan Fowler

Re: Managing user directories
« Reply #7 on: May 26, 2001, 12:05:25 AM »
Kirrily is exact right about everything said, including security and what not.  Sometimes I forget that not everyone is a security conscious as I am.

You could make a simple BASH script to pretty up the output if you wanted.  There isn't too big of a security risk by publishing your user id's to the public if you have taken extra steps to secure your system.

If you're intestered in Cron (Vixie Cron) there are several FAQ's out there.  Keep in mind security, in my case having a file with RWXD for everyone doesn't matter, only I have access to the system.  In you case it may.

That really should be taken to heart about anything post here, first and foremost always use your head.  Just because it's a great solution for one person doesn't mean that it can be one for you.  I'd hate to have several insecure E-Smith boxes floating around because of something I suggested.

Take the time to do the extra research.  There are several documents on BASH scripting.  It's really easy once you get the hang of it and it is almost a necessity for any good admin.

And now that I've got ya'll brain churning go out and conquer!

Nathan Fowler