BSDwiki/ Recognize the difference between hard and soft limits and modify existing resource limits

Recognize the difference between hard and soft limits and modify existing resource limits

Author: name contact BSD flavour

Reviewer: name contact BSD flavour

Reviewer: name contact BSD flavour


Concept

Understand that resource limits are inherited by the shell as well as how to view their limits and change them both temporarily and permanently. In addition, understand the difference between soft and hard limits.

Introduction

limit: (in the csh(1) man page) limits the consumption by the current process and each process it creates to not individually exceed "maximum-use" and the specified "resource". (TODO: don't use man page verbatim)

limits: set or display process resource limits, either prints or sets kernel resource limits and may optionally set environment variables like env(1) and run a program with the selected resources. (TODO: don't use man page verbatim)

login.conf: login class capability database (/etc/login.conf, ~/.login_conf)

sysctl: get or set kernel state

View limits:

less /etc/login.conf or ~/.login_conf to see per user limits)

With limit (builtin): limit [-h] [resource [maximum-use]]

Resources include: cputime, filesize, datasize, stacksize, coredumpsize, memoryuse, heapsize, descriptors (or openfiles), concurrency (TODO ???), memorylocked, maxproc, sbsize

Maximum-use: default descriptor size is "k" or kilobytes (except cputime)

Change limits:

Temporarily:

Permanently: 1) set them in login.conf 2) set them with limits 3) set them with builtin limit 4) set them with sysctl

Understand the difference between hard and soft limits: Hard limits set a ceiling on the value of the soft limits. Only the super user may raise the hard limits, but a user may raise or lower the current limits with the legal range.

Examples

Practice Exercises

More information

limit(1), limits(1), login.conf(5); sysctl(8) on NetBSD