본문 바로가기
프로그래밍

[ubuntu][ulimit] bash: ulimit: open files: cannot modify limit: Operation not permitted

by Ohdumak 2022. 5. 13.

$ ulimit -n 10000
bash: ulimit: open files: 제한을 수정할 수 없음: 명령을 허용하지 않음
bash: ulimit: open files: cannot modify limit: Operation not permitted

ubuntu 에서 root가 아닌 사용자 계정으로 ulimit -n open files 변경이 안되는 문제

검색을 해보면 sudo vi /etc/security/limits.conf 에 아래 내용을 추가하라고 나오지만, 설정 후 재부팅해도 안되는 현상 확인
ohdumak           soft    nofile          65534
ohdumak           hard    nofile          65534
ohdumak           soft    nproc           65534
ohdumak           hard    nproc           65534

[해결 방법]

I was running into this error with WSL2 also. After changing everything outlined through this issue the limits for ulimit wouldn't be raised and wouldn't let me modify the values past the limits, but when checking the rights for the user I was running my command as: 
sudo su username --shell /bin/bash --command "ulimit -n"
 The ulimit would return the raised value. I then logged into myself from myself 
su username --shell /bin/bash
 and I was able to raise the ulimit values as expected, but only for that session. This makes me think that the initial WSL shell is restricted in some way.

 

  1. sudo vi /etc/security/limits.conf 에 아래 내용 추가
    ohdumak           soft    nofile          65534
    ohdumak           hard    nofile          65534
    ohdumak           soft    nproc           65534
    ohdumak           hard    nproc           65534
  2. 특정 사용자의 ulimit -n 정보 확인
    sudo su ohdumak --shell /bin/bash --command "ulimit -n"
  3. 특정 사용자로 재로그인
    su ohdumak --shell /bin/bash
  4. 해당 세션에서만 사용 가능

 

[참고]

https://github.com/Microsoft/WSL/issues/1688

 

Can't raise "open files" ulimit · Issue #1688 · microsoft/WSL

Please use the following bug reporting template to help produce actionable and reproducible issues. Please try to ensure that the reproduction is minimal so that the team can go through more bugs! ...

github.com

 

 

728x90

댓글