리눅스 ps
IT위키
더 많은 작업
- 프로세스의 현재 상태를 출력한다.
- 유닉스와 리눅스 모두에서 명령어와 옵션이 같음
- 경로: /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 | 좀비(끝났는데 부모가 거두지 않음) |