본문으로 이동
메뉴 여닫기
환경 설정 메뉴 여닫기
개인 메뉴 여닫기
로그인하지 않음
지금 편집한다면 당신의 IP 주소가 공개될 수 있습니다.
프로세스의 현재 상태를 출력한다.
  • 유닉스와 리눅스 모두에서 명령어와 옵션이 같음
  • 경로: /bin/ps
ps [옵션]
  • 전체 프로세스와 관련된 옵션
  • -A : 모든 프로세스를 출력한다.
  • -N : -A 옵션과 비슷하나 ps 프로세스를 제외하고 출력한다.
  • -a : 세션 리더 및 터미널에 속하지 않는 프로세스를 제외하고 출력한다.
  • -d : 세션 리더를 제외한 모든 프로세스를 출력한다.
  • -e : 커널 프로세스를 제외한 모든 프로세스를 출력한다.
  • 전체 옵션
********* simple selection *********  ********* selection by list *********
-A all processes                      -C by command name
-N negate selection                   -G by real group ID (supports names)
-a all w/ tty except session leaders  -U by real user ID (supports names)
-d all except session leaders         -g by session OR by effective group name
-e all processes                      -p by process ID
                                      -q by process ID (unsorted & quick)
T  all processes on this terminal     -s processes in the sessions given
a  all w/ tty, including other users  -t by tty
g  OBSOLETE -- DO NOT USE             -u by effective user ID (supports names)
r  only running processes             U  processes for specified users
x  processes w/o controlling ttys     t  by tty
*********** output format **********  *********** long options ***********
-o,o user-defined  -f full            --Group --User --pid --cols --ppid
-j,j job control   s  signal          --group --user --sid --rows --info
-O,O preloaded -o  v  virtual memory  --cumulative --format --deselect
-l,l long          u  user-oriented   --sort --tty --forest --version
-F   extra full    X  registers       --heading --no-heading --context
                                      --quick-pid
                    ********* misc options *********
-V,V  show version      L  list format codes  f  ASCII art forest
-m,m,-L,-T,H  threads   S  children in sum    -y change -l format
-M,Z  security data     c  true command name  -c scheduling class
-w,w  wide output       n  numeric WCHAN,UID  -H process hierarchy
  • 어떤 프로세스가 실행되고 있는지 확인할 때 흔히 아래와 같이 쓰인다
# ps -ef | grep [프로세스명]

실행결과 예시

편집 원본 편집
# ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 Jan02 ?        00:00:07 /sbin/init
root         2     0  0 Jan02 ?        00:00:00 [kthreadd]
root         3     2  0 Jan02 ?        00:00:04 [migration/0]
root         4     2  0 Jan02 ?        00:00:07 [ksoftirqd/0]
root         5     2  0 Jan02 ?        00:00:00 [stopper/0]
root         6     2  0 Jan02 ?        00:00:13 [watchdog/0]
root         7     2  0 Jan02 ?        00:00:04 [migration/1]
root         8     2  0 Jan02 ?        00:00:00 [stopper/1]
root         9     2  0 Jan02 ?        00:00:07 [ksoftirqd/1]
root        10     2  0 Jan02 ?        00:00:11 [watchdog/1]
root        11     2  0 Jan02 ?        01:28:32 [events/0]
root        12     2  0 Jan02 ?        01:07:32 [events/1]
root        13     2  0 Jan02 ?        00:00:00 [events/0]
root        14     2  0 Jan02 ?        00:00:00 [events/1]
root        15     2  0 Jan02 ?        00:00:00 [events_long/0]
root        16     2  0 Jan02 ?        00:00:00 [events_long/1]
root        17     2  0 Jan02 ?        00:00:00 [events_power_ef]
root        18     2  0 Jan02 ?        00:00:00 [events_power_ef]
root        19     2  0 Jan02 ?        00:00:00 [cgroup]
... (이하 생략) ...
항목 뜻
USER, UID 프로세스 소유자
PID 프로세스 번호
PPID 부모 프로세스의 PID (-ef, -l 형식)
%CPU, %MEM CPU·메모리 사용 비율 (u, aux 형식)
VSZ, RSS 가상 메모리 크기, 실제 메모리에 올라온 크기(KB)
TTY 연결된 터미널. 없으면 ?
STAT 프로세스 상태 코드 (아래 표)
START, STIME 시작 시각
TIME 지금까지 쓴 총 CPU 시간
CMD, COMMAND 실행 명령
상태 코드 뜻
R 실행 중이거나 실행 대기
S 잠든 상태(깨울 수 있음)
D 깨울 수 없는 대기(주로 디스크 입출력 대기)
T 멈춤(Ctrl+Z, SIGSTOP)
Z 좀비(끝났는데 부모가 거두지 않음)
  • 덧붙는 표시: < 높은 우선순위, N 낮은 우선순위, s 세션 리더, + 포그라운드, l 멀티스레드
  • 프로세스별 디스크 사용 비율은 ps 로 볼 수 없다. 디스크 입출력은 iotop, pidstat -d 로, 파일 시스템 사용량은 df·du 로 본다

데몬이 떠 있는지 확인

편집 원본 편집
$ ps -ef | grep httpd
$ ps aux | grep sshd
  • 서비스를 제공하는 데몬이 살아 있는지는 ps 로 프로세스 목록을 찍어 본다 → 리눅스 데몬
  • daemon·men 같은 명령은 없다. fsck 는 파일 시스템을 검사하고, man 은 매뉴얼을 보여 준다