Posts Tagged ‘limits.conf’

hey guys,

We all would have heard about forkbomb, a simple program which if executed, consumes your system resources until ur system crashes.  Shell script implementing fork bomb can be written in 11 characters.

!(){ !|!& };!

Where ! denotes the function name and !|! calls itself and pipes the output to the another call of  ! itself.

& makes the child to run back and it can never die and keep replicating until ur system crashes with the lack of resources.

; terminates the function.

! will inturn call the function ! aka fork().

Any users of ur system can run this command and make it crash. But still we have a way to secure our system from our users and groups. Thats by, restricting no of process an user can run at an instant.

We can specify this info in the file named limits.conf (/etc/security/limits.conf)

username hard nproc 200

groupname hard nproc 200

where nproc represents no of processes. Similarly we can limit no of logins and no of opened files for an user and so on..