The default ulimit for open files is unlimited.
Once I change it to a lower limit, e.g.
[user1@localhost ~]$ ulimit -H -n 2048
[user1@localhost ~]$ ulimit -H -n
Then I try to change it to a higher HARD
limit, it would not let me.
The only way I can change the hard ulimit to a higher level
[user1@localhost ~]$ ulimit -H -n 4096
bash: ulimit: open files: cannot modify limit: Operation not permitted
is to use /etc/security/limits.conf AND REBOOT!
E.g. in limits.conf file:
user1 hard nofile 8192
I cannot use sudo to do hard limit change like so:
$ sudo ulimit -H -n
which gives error.
And when I user su (root) like so:
<sign it here>
# set ulimit for -n (open files) to 8192:
$ ulimit -H -n 8192
It works, but once I exit su, those changes inside su were no longer valid outside of su.
So it seems su takes me into a new shell!
So how do I change hard limit without changing
/etc/security/limits.conf AND REBOOT in the present shell?