Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

command not found when using sudo ulimit [closed]

I was using ubuntu 12.04 ,on which I run ulimit -n ,it is showing 1024, I want to increase my open file limit from 1024 to 65535,so I tried the following command:

sudo ulimit -n 65535 

but i get the following error:

sudo: ulimit: command not found 

How to increase the file limit from 1024 to 65535? Any help will be appreciated.

like image 816
sunpy Avatar asked Jul 05 '13 07:07

sunpy


People also ask

Does Ulimit require Sudo?

ulimit is a shell builtin like cd , not a separate program. sudo looks for a binary to run, but there is no ulimit binary, which is why you get the error message. You need to run it in a shell. However, while you do need to be root to raise the limit to 65535, you probably don't want to run your program as root.

Where is the Ulimit command on Linux?

The system resources are defined in a configuration file located at “/etc/security/limits. conf”. “ulimit”, when called, will report these values.

What is Ulimit command in Linux?

ulimit is admin access required Linux shell command which is used to see, set, or limit the resource usage of the current user. It is used to return the number of open file descriptors for each process. It is also used to set restrictions on the resources used by a process.


1 Answers

ulimit is a shell builtin like cd, not a separate program. sudo looks for a binary to run, but there is no ulimit binary, which is why you get the error message. You need to run it in a shell.

However, while you do need to be root to raise the limit to 65535, you probably don’t want to run your program as root. So after you raise the limit you should switch back to the current user.

To do this, run:

sudo sh -c "ulimit -n 65535 && exec su $LOGNAME" 

and you will get a new shell, without root privileges, but with the raised limit. The exec causes the new shell to replace the process with sudo privileges, so after you exit that shell, you won’t accidentally end up as root again.

like image 61
andrewdotn Avatar answered Oct 03 '22 04:10

andrewdotn