Solved

Limit file size allowed to be created at directory level

Posted on 2004-10-11
20
231 Views
Last Modified: 2013-12-06
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
0
Comment
Question by:Barry Cunney
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 4
  • 3
  • +1
20 Comments
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 12277718
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
 
LVL 2

Expert Comment

by:Troxalias
ID: 12284256
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
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12285021
Hi Troxalias,
This is AIX Version 5.2.0.0


Cheers


B Cunney
0
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
LVL 17

Author Comment

by:Barry Cunney
ID: 12285061
Hi Troxalias,
uname on AIX seems to be a command to display machine information??
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12285063
                    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
 
LVL 2

Expert Comment

by:Troxalias
ID: 12285065
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
 
LVL 2

Expert Comment

by:Troxalias
ID: 12285074
Oh, Sorry!!!!!! Wrong command! I meant, ulimit !!! Replace uname with ulimit ;-)
Sorry again, very bad headache today!
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12285101
No worries Troxalias - bad headaches are allowed - we all have 'bad headache' days - I got mine out of the way yesterday  
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12285136
Can this command be used to set a limit  on size files that can be created in a specific directory?
0
 
LVL 2

Expert Comment

by:Troxalias
ID: 12285732
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
 
LVL 14

Accepted Solution

by:
chris_calabrese earned 25 total points
ID: 12286540
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
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12286759
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 12302425
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
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12306255
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 12311653
> 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
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12317187
Hi ahoffmann,

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


Cheers
0
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 25 total points
ID: 12317722
you need quota or acls, as already said
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12531312
Hi jmcg,
That is fine - happy to split the points between the 2 guys, Chris and ahoffman


Cheers


B Cunney
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question