ulimit: command not found

The ulimit command allows users to view or reduce their limits for the current shell. Only the root user can increase restrictions above the specified hard limit The limits set also apply to any child process of the shell. The shell man page provides more information about usage of the ulimit command, an excerpt from the bash man page is below:

ulimit [-HSTabcdefilmnpqrstuvx [limit]]
      Provides control over the resources available to the shell and to processes started by it, on systems that allow such control. 
      Options are interpreted as follows:
      -a     All current limits are reported
      -b     The maximum socket buffer size
      -c     The maximum size of core files created
      -d     The maximum size of a process’s data segment
      -e     The maximum scheduling priority ("nice")
      -f     The maximum size of files written by the shell and its children
      -i     The maximum number of pending signals
      -l     The maximum size that may be locked into memory
      -m     The maximum resident set size (many systems do not honor this limit)
      -n     The maximum number of open file descriptors (most systems do not allow this value to be set)
      -p     The pipe size in 512-byte blocks (this may not be set)
      -q     The maximum number of bytes in POSIX message queues
      -r     The maximum real-time scheduling priority
      -s     The maximum stack size
      -t     The maximum amount of cpu time in seconds
      -u     The maximum number of processes available to a single user
      -v     The maximum amount of virtual memory available to the shell
      -x     The maximum number of file locks
      -T     The maximum number of thread

The syntax of the ulimit command is:

# ulimit [options] [limit]

Users rarely use the ulimit command to limit their own account, so the options for this command are not as important as understanding what the output displays. Additionally, some of the limits are very rarely used. The commonly used limits are described in the following table:

Limit Description
fsize Maximum file size allowed in memory
cpu Maximum CPU time allowed
nproc Maximum number of concurrently running processes
maxlogins Maximum number of concurrent logins

For example, to set a limit for the maximum number of open file descriptors:

# ulimit -n 512

You can display all of the current limits by issuing:

# ulimit -a

If you encounter below error while running the ulimit command:

ulimit: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
OS X brew install bash
Debian apt-get install bash
Ubuntu apt-get install bash
Alpine apk add bash
Arch Linux pacman -S bash
Kali Linux apt-get install bash
CentOS yum install bash
Fedora dnf install bash
Raspbian apt-get install bash

ulimit Command Examples

1. Get the properties of all the user limits:

# ulimit -a

2. Get hard limit for the number of simultaneously opened files:

# ulimit -H -n

3. Get soft limit for the number of simultaneously opened files:

# ulimit -S -n

4. Set max per-user process limit:

# ulimit -u 30

5. Set the core dump size limit to n 512-byte blocks:

# ulimit –c n

6. Set the data area size limit to n kilobytes:

# ulimit -d n

7. Set the child process file write limit to n 512-byte blocks (default):

# ulimit -f n

8. Set the physical memory size limit to n kilobytes:

# ulimit -m n

9. Set the stack area size limit to n kilobytes:

# ulimit -s n

10. Set the process time limit to n seconds:

# ulimit -t n
Related Post