I edited the /etc/security/limits.conf file to limit the size of files that a user "student" can create:
@student hard fsize 3001
@student soft fsize 2001
Now when I login as a "student" and try to create a few files to see how big of a size I can create them I encounter this weird behaviour :
student@node1:~$ ulimit -f
2001
student@node1:~$ dd if=/dev/zero of=file1 bs=1KB count=2049
2049+0 records in
2049+0 records out
2049000 bytes (2.0 MB, 2.0 MiB) copied, 0.0127504 s, 161 MB/s
student@node1:~$ dd if=/dev/zero of=file2 bs=1KB count=2050
File size limit exceeded (core dumped)
I then check their sizes :
student@node1:~$ ls -l
-rw-rw-r-- 1 student student 2049000 Dec 4 16:56 file1
-rw-rw-r-- 1 student student 2049024 Dec 4 16:57 file2
Why am I allowed to create files this big ? In the dd command I can describe the max size as bs=1KB count=2049. Shouldn't it be bs=1KB count=2001 since I have put "2001" in /etc/security/limits.conf ?
The
ulimit
value appears to be in kibibytes (2001 x 1024 = 2049024 bytes) whereasbs=1KB
is kilobytes (2049 x 1000 = 2049000 bytes). Thedd
suffix for kibibytes is justK
(ork
) notKB
.So