[Linux]: SSH Cannot switch to specific user with an Error “su: cannot set user id: Resource temporarily unavailable”

Updated on September 3, 2017

One of my colleague came with a problem that he was not able to login to a particular user account on a Linux machine. However, I was able to login to another account on the same machine, but not to the one my colleague actually wants to. Even I tried to switch (su -) from my user account on the same machine to his account, but only see an error message as “su: cannot set user id: Resource temporarily unavailable“.  Well, that error message gave us a hint that the problem might be with an account itself and not with the machine.

Below is the snapshot of the error message:

$su - swift
Password:
su: cannot set user id: Resource temporarily unavailable

Linux SSH: Switch user

The cause might be because of user’s ‘process run limit’ exceeded. To verify this, I ran the below command.

$ ps -eLF|grep swift | wc -l
1026

Where “-L” option will display all processes for the user account ‘swift’.

Find out the max user process allowed using the below command:

$ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) 1024
pending signals                 (-i) 514963
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1024
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

In the above case, 1026 is greater than the max allowed of 1024. The solution is to increase the maximum number of processes allowed for an user account.

Solution:

1. The process limit can be increased by editing: /etc/security/limits.conf (you need root privilege to do that)

swift hard nproc 4096

No need to restart any services.

2. If you don’t have the root privilege, then the user can increase the limit by using the below command.

$ulimit -u 4096

3. stop any unwanted processes

That’s it! My colleague left the place with a big smile on his face.

Was this article helpful?

Related Articles

Leave a Comment