Search code examples
linuxsecurityfilesystemsdirectorylinode

How can I limit the max numbers of folders that user can create in linux


Since I have been told that if a user in my computer will create "infinite" number of folders / files (even empty) it can cause my computer to become much much slower (even stuck), I want to limit the maximum number of files/directories that user can create.

I'm afraid that one user will try to create a huge number of files and it will become a problem for all the other users, so it will be a security issue, How do I do that, how do I limit the max number of files/directories each user can create?


Solution

  • This is what quotas are designed for. You can use file system quotas to enforce limits, per user and/or per group for:

    • the amount of disk size space that can be used
    • the number of blocks that can be used
    • the number of inodes that can be created.

    The number of inodes will essentially limit the number of files and directories a user can create.

    There is extensive, very good quality documentation about how to configure file system quotas in many sources, which I suggest you read further: