Recently, when logging on to the development machine, there are errors as follows:
-bash:cannot Modify Limit:operation not permitted
It must be somewhere. Ulimit settings, think about it, when the user logs on or the user su command switches, the system invokes the following script:
/etc/profile.d/file
/etc/profile
/etc/bashrc
/lebyzhao/.bashrc
/lebyzhao/.bash_profile
It may be that there is a ulimit-n configuration, check, sure enough in the/etc/profile, there are lines ulimit-n 65535
When you log in with Lebyzhao, you are not root, do not have permission to execute, only show the above error.
Comment out here/etc/profile this line is no error.
Ulimit-n configuration is critical, so here is a long-winded, because this and the current login session, users and even user groups limits configuration related, sometimes looks very strange.
In addition to applying ulimit-n, you can also modify the Linux hardware and software restriction file/etc/security/limits.conf:
If you add the following code:
* Soft Nofile 65535
* Hard Nofile 65535
The number of files opened by all users is limited to 65535. Here's a simple explanation. The command format is the users type item value,users is the user name or group name that begins with the sign @ (no @ test is also available), * represents all users, and type is set to hard or soft. item specifies that the resource you want to restrict, such as Cpu,core nofile Nproc or Maxlogins,value, is the corresponding limit value.
When you log in, Pam sets the upper limit from limits.conf (of course, the Ulimit command can be set in the range below the upper limit).
Look on the web, it seems that the kernel also provides a setup interface:/proc/sys/fs/nr_open, we are interested in the search to see.
In short, we use the ulimit-n command in this shell session, the server process startup (script), the user login such as/etc/profile settings, or set limits.conf, can achieve your purpose, the scene and the pros and cons are also obvious.
If you are still interested: when we use sudo limit-n 65536 to test the settings, we will be prompted not to find the command, because Ulimit and CD, and so on, is the kernel built-in instructions, not/usr/sbin and so on the following binary program commands. If you want to set it up after you login (non-root), can you do this: sudo sh-c "ulimit-n 65535"? In combination with sudo and the user, it is not difficult to understand whether it is feasible or not.
Ulimit configuration error when logging on to the server, also talk about Ulimit configuration