Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find ulimit -a for other users

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

like image 988
gr8odinsraven Avatar asked Aug 14 '14 07:08

gr8odinsraven


3 Answers

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 )

like image 78
huynhbaoan Avatar answered Oct 21 '22 11:10

huynhbaoan


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.

like image 37
Renich Avatar answered Oct 21 '22 11:10

Renich


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
like image 6
Pancho Avatar answered Oct 21 '22 12:10

Pancho