Linux

ulimit 설정

비번변경 2021. 9. 13. 19:10

ulimit

접속하는 쉘이나 프로세스가 사용할 수 있는 자원을 조절한다. 즉, 실행시킨 프로세스가 동시에 사용할 수 있는 파일 수 등을 조절할 수 있다.

 

Hard Limit : -H. 한 번 설정되면 root 권한으로만 값을 증가시킬 수 있다.

Soft Limit : -S. hard limit까지 조절될 수 있다.

 

옵션을 명시하지 않으면, 두 값이 동시에 설정된다.

 

설정 확인

ulimit -a
# -a : 모든 값 출력
# -n : open file descriptor의 최대 수

# hard 설정 확인
ulimit -a -H

# soft 설정 확인
ulimit -a -S

ulimit -a

 

설정

ulimit <OPTION> <VALUE>

# 예시 : max user process 값을 2048로 설정
ulimt -u 2048

명령어를 이용한 설정은 휘발성이다.

 

설정 파일 경로 및 내용

설정을 유지하고 싶다면 설정 파일 내용을 수정하면 된다. 파일 수정 후, 재접속하면 수정 내용이 반영된다.

설정 방법은 파일 내에 주석으로 설명되어 있다.

/etc/security/limits.conf


#<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
#
#<type> can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
#<item> can be one of the following:
#        - core - limits the core file size (KB)
#        - data - max data size (KB)
#        - fsize - maximum filesize (KB)
#        - memlock - max locked-in-memory address space (KB)
#        - nofile - max number of open file descriptors
#        - rss - max resident set size (KB)
#        - stack - max stack size (KB)
#        - cpu - max CPU time (MIN)
#        - nproc - max number of processes
#        - as - address space limit (KB)
#        - maxlogins - max number of logins for this user
#        - maxsyslogins - max number of logins on the system
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#        - sigpending - max number of pending signals
#        - msgqueue - max memory used by POSIX message queues (bytes)
#        - nice - max nice priority allowed to raise to values: [-20, 19]
#        - rtprio - max realtime priority
#
#<domain>      <type>  <item>         <value>
#

#*               soft    core            0
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4


# End of file

 

728x90