Home / Alt manpages / proc_pid_limits(5)

  • proc_pid_limits(5)
  • File format
  • linux

Read a Process's Resource Limits from /proc

You will finish with a safe, repeatable way to inspect the resource limits of a Linux process, tell a soft limit from a hard limit, and avoid mistaking a displayed value for a system-wide setting. Allow about ten minutes. You need a shell and a running Linux system with procfs mounted. The examples are read-only unless you choose to start a short-lived test process.

1. Check the local contract

The interface is /proc/PID/limits, where PID is the process ID. The installed manpage describes it as a file containing the soft limit, hard limit and unit for each resource limit. It has existed since Linux 2.6.24. This guide was checked against Linux man-pages 6.7, package version 6.7-2, on a Linux 6.8.0-139-generic host.

Confirm that procfs is available and see the exact file name for your shell. This is an ordinary command and does not need elevated privileges:

$ test -r /proc/self/limits && echo readable
readable
$ readlink -f /proc/self/limits
/proc/12345/limits

The number in the second result is an example. /proc/self is a kernel-provided link to the process doing the reading, so it is usually the least confusing first target.

2. Read your current shell's limits

Print the complete table for the current shell:

$ cat /proc/self/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size             8388608              unlimited            bytes
Max core file size        0                    unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             127192               127192               processes
Max open files            1048576              1048576              files
...                      ...                  ...                  ...

Your values can differ with the login method, service manager, container, user limits configuration and kernel. The spacing is for humans, not a stable data interchange format. When a script needs to extract one value, anchor it to the resource name and treat unlimited as a distinct value rather than trying to convert it to a number.

Checkpoint: confirm that the table has three pieces of information per row: a named resource, a soft limit, and a hard limit, followed by the unit. A limit of 0 is a real value. It is not the same as unlimited.

3. Check a particular process

Replace PID with an existing process ID. Reading your own process is unprivileged. Reading another process may be subject to the permissions and process namespaces of the host, so begin without sudo and do not treat a permission error as a reason to grant broad access.

$ PID=PID
$ test -d "/proc/$PID" || { echo "no such process: $PID"; exit 1; }
$ test -r "/proc/$PID/limits" || { echo "limits file is not readable"; exit 1; }
$ sed -n '1,12p' "/proc/$PID/limits"
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
...

A process can exit between the directory check and the read. That race is normal for procfs, whose entries describe live processes. If the second command fails, obtain a fresh PID and retry. Do not assume that a reused PID still identifies the process you first saw.

4. Interpret soft and hard limits

The soft limit is the value enforced for ordinary resource use by the process. The hard limit is the ceiling to which the process may raise its soft limit, subject to the relevant kernel rules and privileges. The hard limit is not a second amount added to the soft limit. For example, a row with a soft open-file limit of 1024 and a hard limit of 4096 means the current allowance is 1024 files, with 4096 as the ceiling for raising it.

The file reports process-level values, not a live count of current usage. To investigate a process that cannot open another file, compare its Max open files row with the process's actual file descriptors and its error logs. A high hard limit alone does not prove that the process is currently allowed to use it.

Units matter. CPU time is shown in seconds, file size and address-related values are shown in bytes, and pending signals or processes use counts. Keep the unit beside the number in notes and scripts. Do not compare a byte limit directly with a value reported in kilobytes or pages.

5. Compare a shell with a child process

Limits are inherited when a child is created, so a useful diagnostic is to inspect a child rather than only your interactive shell. This command starts a short-lived shell, prints its own limits, and exits. It changes no persistent configuration:

$ sh -c 'sed -n "1,12p" /proc/self/limits'
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
...

That output should normally match the parent for inherited limits, although a launcher, service manager or wrapper can deliberately adjust them before the final program starts. If a service behaves differently from your shell, inspect the service's own PID and its launch configuration rather than changing your login shell first.

6. Know what this file cannot change

/proc/PID/limits is a report. Opening it with cat, sed or an editor does not raise, lower or reset a limit. Do not attempt to redirect output into it: the documented interface is for displaying limits, not configuring them. A command such as ulimit changes the shell's resource-limit state for that shell and its children, while service managers and application launchers may have their own configuration. Those are separate actions and are outside this inspection workflow.

Before changing a limit elsewhere, record the current table and identify the exact process that needs the change. Raising a hard limit can widen the impact of a runaway process; lowering limits can break a service. Make changes in the relevant service or session configuration, test them in a maintenance window, and keep the previous value so you can restore it. No undo is needed for the commands in this guide because they only read files and start a shell that exits immediately.

7. Diagnose the usual failures

  • No such file or directory: the PID may have exited, or it may not exist in your process namespace. Find the current PID again.
  • Permission denied: access to another process is restricted by the host's permissions, namespaces or security policy. Try /proc/self/limits to separate a general procfs problem from a target-process problem. Use elevated access only under your normal operational policy.
  • Unexpected values: inspect the actual target PID, its service or container boundary, and the command that launched it. Do not infer a process limit from your own shell's table.
  • Parsing breaks: do not split on columns of spaces or assume every value is numeric. Preserve unlimited and read the unit column.

Done means

  • You can read /proc/self/limits without elevated privileges.
  • You can inspect a chosen PID while allowing for process exit and PID reuse.
  • You can explain the difference between soft and hard limits.
  • You keep each value paired with its resource name and unit.
  • You know that this file reports limits and does not configure them.