Limit file size allowed to be created at directory level

Hi Guys,
Is there a way one can limit the file size one can create at directory level
Example: I don't want people/processes to be able to create files larger than 5MB in usr/home/admin   directory.


Any advice appreciated


Cheers


B Cunney
LVL 17
Barry CunneyAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
chris_calabreseConnect With a Mentor Commented:
Ulimit sets the limit on a given process plus its children. It can be put in /etc/profile and similar places to put a limit on the size of a file a given user can create, but it is global and doesn't apply to any particular directory or filesystem.

The closest you can likely get is to make the directory in question its own filesystem and then set quotas on that filesystem. This won't limit the size of an individual file, but it will limit the total file space per user in that filesystem.
0
 
chris_calabreseCommented:
You can't limit the size of individual files, but you can limit the total disk space used by a given user in a given filesystem by using disk quotas. See the quota man-page and the various pages it points to on your system.
0
 
TroxaliasCommented:
You don't mention which OS you are usingbut probably " uname -f " will do the job.
For example uname -f 10000 will set the limit you want. Be careful that when setting file size limit the number specified referres to 512 byte blocks.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Barry CunneyAuthor Commented:
Hi Troxalias,
This is AIX Version 5.2.0.0


Cheers


B Cunney
0
 
Barry CunneyAuthor Commented:
Hi Troxalias,
uname on AIX seems to be a command to display machine information??
0
 
Barry CunneyAuthor Commented:
                    Commands Reference, Volume 5, s - u

uname Command

Purpose

Displays the name of the current operating system.

Syntax

uname [ -a | -x | -SName ] | [ -l ] [ -L ] [ -m ] [ -M ] [ -n ] [ -p ] [ -r ] [
-s ] [ -TName ] [ -u ] [ -v ]

Description

The uname command writes to standard output the name of the operating system
that you are using.
0
 
TroxaliasCommented:
Hi B Cunney,

Not familiar with AIX. However in both Solaris and HP-UX this works. Give a try on a user shell. It is completely harmless! Check your settings with uname -a .
0
 
TroxaliasCommented:
Oh, Sorry!!!!!! Wrong command! I meant, ulimit !!! Replace uname with ulimit ;-)
Sorry again, very bad headache today!
0
 
Barry CunneyAuthor Commented:
No worries Troxalias - bad headaches are allowed - we all have 'bad headache' days - I got mine out of the way yesterday  
0
 
Barry CunneyAuthor Commented:
Can this command be used to set a limit  on size files that can be created in a specific directory?
0
 
TroxaliasCommented:
hmmm... i have never tried it, but i don't think that it would be possible... As fas as i am concerned you cannot do it with this command. It is a somehow user-oriented command...
0
 
Barry CunneyAuthor Commented:
Thanks for the feedback
...but I was hoping there was some way to restrict the size of file that could be created in a specified directory
0
 
ahoffmannCommented:
ulimit will do the trick as long as the users cannot get out their shell, for example with cron (there you have to take care for ulimit settings again).

  ulimit -H -f 5000000

in /etc/profile, or

  limit -h filesize 5000000

in /etc/csh.cshrc (and /etc/csh.login)

# both suggestions assuming standard sh, bash, ksh, pdksh, ash, csh, tcsh, tsh, zsh, lsh, etc. etc. setup
0
 
Barry CunneyAuthor Commented:
Hi Ahoffmann,
but how do I set this up so it only relates to one specific directiory - maybe I am misunderstanding you.

I only want this to be applied to a single directory - usr/home/admin
I just want to set something up so as no user can create a file of larger than 5MB in a single directory, namely usr/home/admin.

??
0
 
ahoffmannCommented:
> but how do I set this up so it only relates to one specific directiory
impossible with limit/ulimit, see comments above. You need quota for that, or ACLs.

> ..  so as no user can create a file of larger than 5MB in a single directory ..
not precise enough:
  do you mean that *each* user  cannot create *any* file > 5MB anywhere
or
  *each* user cannot create *any* file > 5MB in /usr/home/admin

 
0
 
Barry CunneyAuthor Commented:
Hi ahoffmann,

*each* user cannot create *any* file > 5MB in /usr/home/admin


Cheers
0
 
ahoffmannConnect With a Mentor Commented:
you need quota or acls, as already said
0
 
Barry CunneyAuthor Commented:
Hi jmcg,
That is fine - happy to split the points between the 2 guys, Chris and ahoffman


Cheers


B Cunney
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.