For Linux and Shell scripting.

File size limit (ulimit)

Leave a comment

File size can be limited per user. If it’s limited to 1GB, you can’t create a file of size greater than 1GB. It will give you “File size limit exceeded” error.

To know what’s the present file size limit, use the command:
$ ulimit -a

It will show you:
file size               (blocks, -f) 1048576

If it’s unlimited, you can see like:
file size               (blocks, -f) unlimited

You should edit “/etc/security/limits.conf” if you want to change the limits.

Suppose, you want to set file size limit for the user mohammed to 1GB. Then, you can add the following entry to /etc/security/limits.conf (1GB=1048576KB)

mohammed       hard  fsize  1048576

You can verify changes using the command “dd if=/dev/zero of=test bs=1024M count=1”. This will create a file named “test” of size 1GB.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s