Is anyone aware of a way to find the "ulimit -a" values for another user in Linux? I want user A to be able to check User B's ulimit values. Assumptions are the User A and User B are non-root users.
Thanks in advance
Pancho's answer is correct, but sometimes you may get an error like this:
su - www-data -c "ulimit -n"
No directory, logging in with HOME=/
This account is currently not available.
You may specify a shell to overcome this:
su www-data --shell /bin/bash --command "ulimit -aH"
( -aH
give you hard limit, -aS
give you soft limit )
I would suggest:
grep 'open files' /proc/$( pgrep -o <some-user> )/limits
For example:
grep 'open files' /proc/$( pgrep -o memcache )/limits
You need to realize that pgrep -o will match the oldest of the processes; which, I'd presume, is be the parent.
If I am understanding correctly, you are wanting to achieve something like the following...
Assuming I am root and I would like to find out the soft limit information configured for the user fred, the following approach:
su - fred -c "ulimit -Sa"
will return the desired values.
Alternatively, if as per your question, you are not root, then you could use sudo and if desired inject the necessary password on execution as shown here
echo "freds password" | sudo -Siu fred ulimit \-Sa
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With