리눅스 ps

From CS Wiki

개요[edit | edit source]

프로세스의 현재 상태를 출력한다.
  • 유닉스와 리눅스 모두에서 명령어와 옵션이 같음
  • 경로 : /bin/ps

사용법[edit | edit source]

문법[edit | edit source]

ps [옵션]

옵션[edit | edit source]

  • 전체 프로세스와 관련된 옵션
  • -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

예제[edit | edit source]

  • 어떤 프로세스가 실행되고 있는지 확인할 때 흔히 아래와 같이 쓰인다
# ps -ef | grep [프로세스명]

실행결과 예시[edit | edit source]

# 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]
... (이하 생략) ...

참고 문헌[edit | edit source]