Sample Header Ad - 728x90

Difference between ulimit -a and /proc/$PID/limits

1 vote
1 answer
112 views
In Linux, there are user limits for accessing system resources. Shell built-in command ulimit can be used to see user limits for the current user.
ulimit -a       # soft limits
ulimit -a -H    # hard limits
Then I also can see per process soft/hard limit by looking at /proc/$PID/limits.
# For example, the limits on firefox process:
PID=$(ps -A | grep firefox | awk '{print $1;}' | head -n1)
cat /proc/$PID/limits

# OR in short:
cat /proc/$(ps -A | grep firefox | awk '{print $1;}' | head -n1)/limits
I am wondering what is the difference between these two output? I see /proc/$PID/limits having some limits larger than ulimit -a -H (Hard limits) output for the same resource. Can process spawned by a user have its limits exceed user limits (ulimit)? --- I tried to include my question in a question with similar goals: https://unix.stackexchange.com/review/suggested-edits/470961 . The edit was rejected.
Asked by Amith (313 rep)
Aug 26, 2024, 02:26 PM
Last activity: Sep 4, 2024, 03:00 PM