Can't edit /proc/self/limits

I need to edit the /proc/self/limits to modify the max locked memory cap.

Trouble is, the file is read-only, and I can’t modify its attributes with chmod, this happens when I try:

localhost:/home/user # ls -l /proc/self/limits 
-r--r--r-- 1 root root 0 Dec  3 21:51 /proc/self/limits
localhost:/home/user # chmod +rwx  /proc/self/limits 
chmod: changing permissions of '/proc/self/limits': Operation not permitted

How do I circumvent this? Is there another method to edit the values in the file?

I can’t see where anybody would expect a regular user account to able to modify that file.

I’d fully expect you’d need root privileges in order to modify it.

/proc is not a real filesystem; you have to modify it using the ulimit -l command, as I recall.

That’s what I used, notice the “#” in the snippet above. The whole issue arises from the fact that neither root can modify the file

Great!

for future reference,

ulimit -l unlimited

seems to do the trick.

But now, a follow-up question: from the ulimit’s man page it seems that the change only applies to the current shell and its descendants. How do I make the change permanent and system-wide?

@madsplinter

@sfalken wrote:

Notice the prompt:
"The prompt for the root user in Linux is in the format
[root@localhost ~] #.
The # symbol indicates that the user is in the root account. "

However, ulimit is required.

That’s a new one on me.

Ok.

@madsplinter

This might provide some info (this is just a snippet):

:~> cat /etc/security/limits.conf 
# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain>        <type>  <item>  <value>
#
#Where:
#<domain> can be:
#        - a user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#        - the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#  ...

Well, of course every user can change his/her shell prompt to his/her liking. But by default, the default prompt for root is different from the one for other users (remark that those defaults maybe different for different shells). And assuming that not many users change from it, it is the main reason why we ask to include the prompt (together with the command) when posting code in the forums. From the (default) prompt one can read the user (most important root or not), the working directory (often important when no absolute paths are shown in commands) and the host name (often not so important, but can be when it is about networking).

@madsplinter ,

I really doubt that you want to change something in /proc/self/.

boven:/proc # ls -l self
lrwxrwxrwx 1 root root 0 Dec  4 08:46 self -> 11015/
boven:/proc #

This points to the “current running process”, which is the ls command from the code above. When you do this several times you will see a different PID each time.

I doubt you want to change the limits of that current running ls process, it will be finished before you can say “Jack Robinson”.

Yeah, I’m fully aware of this. I’ve just been using Linux/BSD for close to 30 years, and wasn’t ever aware there was some hard and fast rule about the Prompt indicating whether one was at a user, or root prompt, just by the last character in the prompt.

Not saying you’re not right, just not something that ever came to my attention.

You can find some more information in e.g. man bash . Search for the environment variables PS1 (and PS2 , etc.)

As example (I can not remember that I changed from the defaults in bash ):

henk@boven:~> echo $PS1
\[$(ppwd)\]\u@\h:\w>
henk@boven:~> 
boven:~ # echo $PS1
\[$(ppwd)\]\[\]\h:\w #\[\]
boven:~ # 

But as I explained, different shells have different defaults. This is from ksh

henk@boven:/home/henk> echo $PS1
henk@boven:${PWD}>
henk@boven:/home/henk>
1 Like

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