How to increase ulimit

Hello,

Cannot increase ulimit

aario@openmandriva-x8664:~$ ulimit -l
8192
aario@openmandriva-x8664:~$ cat /etc/os-release
NAME="OpenMandriva Lx"
VERSION="25.03 (ROME) Rolling"
ID="openmandriva"
VERSION_ID="25.03"
PRETTY_NAME="OpenMandriva Lx 25.03 (ROME) Rolling"
BUILD_ID="20250302.09"
VERSION_CODENAME="rome"
ANSI_COLOR="1;43"
LOGO="openmandriva"
CPE_NAME="cpe:/o:openmandriva:openmandriva_lx:25.03"
HOME_URL="http://openmandriva.org/"
BUG_REPORT_URL="https://github.com/OpenMandrivaAssociation/distribution/issues/"
SUPPORT_URL="https://forum.openmandriva.org"
PRIVACY_POLICY_URL="https://www.openmandriva.org/tos"
aario@openmandriva-x8664:~$ cat ~/.config/systemd/user/memlock.service
[Unit]
Description=Set memlock to unlimited

[Service]
LimitMEMLOCK=infinity
ExecStart=/bin/bash -c 'echo "Memlock limit set to unlimited"'

[Install]
WantedBy=default.target
aario@openmandriva-x8664:~$ systemctl --user status memlock.service
β—‹ memlock.service - Set memlock to unlimited
     Loaded: loaded (/home/aario/.config/systemd/user/memlock.service; enabled; preset: enabled)
    Drop-In: /usr/lib/systemd/user/service.d
             └─10-timeout-abort.conf
     Active: inactive (dead) since Mon 2025-03-17 10:25:37 CET; 5min ago
   Duration: 30ms
 Invocation: f52f46b40e404d1999b1b53cdc0e002a
   Main PID: 1819 (code=exited, status=0/SUCCESS)
   Mem peak: 1.4M
        CPU: 4ms

Mar 17 10:25:36 openmandriva-x8664 systemd[1759]: Started memlock.service - Set memlock to unlimited.
Mar 17 10:25:37 openmandriva-x8664 bash[1819]: Memlock limit set to unlimited
aario@openmandriva-x8664:~$ cat /etc/security/limits.d/10-memlock.conf
aario soft memlock unlimited
aario hard memlock unlimited
aario@openmandriva-x8664:~$

Any ideas would be appreciated. Thanks in advance.

This is nothing I have ever had to modify, so I am not familiar with it, but I understand what it is. Here is what AI told me.
+++++++++++++

Ulimit linux

The ulimit command in Linux is used to view or limit the system resource usage for individual users. It can be used to manage various limits such as the maximum number of processes a user can create, the maximum file size, and the maximum number of open files, among others.15

To view all current resource limits for the current user, you can use the -a flag:

ulimit -a

This command provides a detailed report about the resource limits.1

To set a specific limit, you can use flags such as -u for the maximum number of processes, -f for the file size limit, and -n for the maximum number of open files. For example, to limit the maximum number of processes to 10, you would use:

ulimit -u 10

The -H flag sets the hard limit, which can only be raised by root users, while the -S flag sets the soft limit, which can be changed by any process.1

Persistent changes to these limits can be made by editing the /etc/security/limits.conf file, which requires superuser permissions.16

To set the limit of processes for the super-user root to be unlimited, you can add the following line to the .bashrc file:

ulimit -u unlimited

Alternatively, you can run ulimit -u unlimited directly at the command prompt.7

The ulimit command is particularly useful in environments with multiple users and can help prevent potential attacks such as fork bombs, which can use up all system resources and make the system unresponsive.

+++++++++++++++++++++++++++++++++

I checked and I do not have /etc/security/limits.conf , however I type ulimit at the command prompt and mine is unlimited.

β”Œβ”€β”€[wilson@heisenberg] Mon Mar 17, 06:46:40 [~] 
└──[ <$> ulimit
unlimited
β”Œβ”€β”€[wilson@heisenberg] Mon Mar 17, 06:46:45 [~] 
└──[ <$> ulimit -a
real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) unlimited
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 0
file size                   (blocks, -f) unlimited
pending signals                     (-i) 123742
max locked memory           (kbytes, -l) 8192
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) 8192
cpu time                   (seconds, -t) unlimited
max user processes                  (-u) 123742
virtual memory              (kbytes, -v) unlimited
file locks                          (-x) unlimited

Sorry I should have added something like β€œAI already inquired” to my post.
So the commands I entered and posted their results, were actually from AI suggestions.
One solution that AI suggested was based on the config files in the etc folder. They were totally ignored by the system whatever it is, PAM, etc.
Another solution was by setting an environment variable for the user by systemd. That was also totally ignored.
There were many other things that AI told me to do but those were not solutions, but rather things to check. And the answer of all of them was showing that in fact the ulimit setting is not working.
As a result, the application OTPClient which I need so bad does not work and complains about ulimit being very low.
If I keep asking AI for more suggestions, then it does not remember first messages in the thread, and keeps repeating them all over again.
if I start a new message with AI and mention all the things I have tried and all the things I have checked, then the token becomes so large that the AI starts to hollusinate (Tried with chatgpt 4).
Longer conversations usually end up with AI telling me that I’m beyond my free account and need a plus membership :frowning:
So, any Human suggestion would be highly appreciated.
I have a feeling that this is one of those cases that I have to give up and just accept that linux kernel has been over complicated recently and nowadays it just cannot do such thing that it used to do back then, anymore (https://community.unix.com/t/how-to-set-ulimit-in-linux/393256/6)

Update:
Based on the solution in:

I tried creating the file:

/etc/security/limits.conf

With the content:

@aario soft memlock unlimited
@aario hard memlock unlimited

Now, after a reboot, I have:

aario@openmandriva-x8664:~$ ulimit -l
8192
aario@openmandriva-x8664:~$ ssh aario@localhost "ulimit -l"
(aario@localhost) Password: 
X11 forwarding request failed on channel 0
unlimited

Normal session, limited.
ssh session, unlimited.
What else can I do? Thanks in advance.

I am a bit confused. In your first post, you showed your memlock is unlimited. In the last post, your settings for /etc/security/limits.conf are only for memlock and not for other parameters. Am I missing something?

As I understand: In Linux, the memlock parameter in /etc/security/limits.conf specifies how much memory a user can lock into its address space, which cannot be moved to swap space.

However this is only one parameter. Ulimit controls this, but also controls how many files a user can have open and how large they can be and how many processes a user can have running.

As I said, I am not familiar with these things on Linux, but I had to manage them on the AS/400, because we had so many users logged in at any one time.

Earlier, I ran ulimit and it shows unlimited. However, I can run ulimit -a and get this.

β”Œβ”€β”€[wilson@heisenberg] Mon Mar 17, 09:35:25 [~] 
└──[ <$> ulimit -a
real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) unlimited
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 0
file size                   (blocks, -f) unlimited
pending signals                     (-i) 123742
max locked memory           (kbytes, -l) 8192
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) 8192
cpu time                   (seconds, -t) unlimited
max user processes                  (-u) 123742
virtual memory              (kbytes, -v) unlimited
file locks                          (-x) unlimited

Might you need to set a different parameter than just memlock?

I am learning as we go here too.

As you can see, mine shows the same thing for -l, so is it possible to lock every bit of memory to never go to swap? Maybe increase to another fixed amount?

I can see what the kernel sets with the following

β”Œβ”€β”€[wilson@heisenberg] Mon Mar 17, 09:37:48 [~] 
└──[ <$> cat /proc/1/limits
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            8388608              unlimited            bytes     
Max core file size        unlimited            unlimited            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             123742               123742               processes 
Max open files            1073741816           1073741816           files     
Max locked memory         4103634944           4103634944           bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       123742               123742               signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us        
1 Like

I don’t know that one. But a workaround I have found was as I said, run ssh to my own local system and there the new ulimit setting was applied! Then run anything I want from inside ssh. In my case it was the flatpack application OTPClient.

So the workaround/solution:
Creating the file:
/etc/security/limits.conf
With content:

@aario soft memlock unlimited
@aario hard memlock unlimited

And then running:

ssh aario@localhost

Considering that my username is aario.

Inside the ssh session, the ulimit settings works. Even though outside of it the system might be a bit buggy and not respecting the configuration.

Thanks again for all your ideas and help.

I find it unusual that this program could need more than 8GB of memory to run.

On his github, I can see where someone had to increase from 16MB, but I can’t see any reason for it to complain about 8GB. I would ask him about it. Maybe there is something else.

1 Like

I also thought of it and I think it’s a weird software. I reallized that my favorite kde password manager KeepassX already has OTP. So I won’t use OTPClient anymore! Over complicated and troublesome.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.