Good morning guys. My mid semester exams are finished and the End semester exams will start from the next week. In the meantime I am here to discuss another cool trick with you. You may know that we can easily create a mischievous script which can recursively generate new processes and eat up all the System resources within few minutes. For example-

:( ){ : |:& }; :

This shell script can take an unprotected Linux machine down by consuming all the resources. Now we’ll discuss how we can eliminate such possibilities quite easily in our Linux machine.

In RHEL there is a file called /etc/security/limits.conf which will assist us in this case. Using this file we can restrict the number of processes a User or Group can generate. So just open this file and you will see examples about how you can use this file.

Configuring /etc/securtiy/limits.conf In Red Hat Enterprise LinuxNow you can read it and use it easily. To restrict a user you can write-

  • viny  soft   nproc   150
  • viny hard nproc 200

Now the user viny can create maximum 200 processes and will get a warning on creating 150 processes. To use it for a group you’ll have to use @groupname and rest of the syntax will remain same. You can also restrict CPU time max Priority or File size through this file. So guys have a look at this file and enjoy.

Advertisements