·터미널 명령어

ps

프로세스·시스템

쓰는 꼴

ps aux | ps -ef

지금 이 순간 돌고 있는 프로세스를 한 장으로 찍어 보여줍니다 — `ps aux`는 대시 없는 BSD 꼴이고 `ps -ef`는 POSIX 꼴이라, 두 꼴을 섞어 쓰는 것이 가장 흔한 실수입니다.

자주 쓰는 옵션

옵션
auxBSD form (no dash): every process of every user, including those with no terminal. Works on Linux and macOS.
-efPOSIX form: the same list with the parent PID and the full command line.
-p <pid>Show one process only.
-u <user>Only the processes of that user.
-o pid,ppid,%cpu,%mem,commChoose exactly which columns to print.
--sort=-%cpuSort by CPU, highest first. GNU procps only; macOS ps has no --sort.

예시

ps aux | grep -i nginx

Find the nginx processes and their PIDs.

ps -eo pid,%mem,comm --sort=-%mem | head

The ten processes using the most memory (Linux).

ps -p 1234 -o etime=

How long PID 1234 has been running, with no header.

무엇이 돌고 있고 무엇이 자원을 먹는지 봅니다. 죽이기 전에 무엇인지 확인하는 것이 순서입니다.

읽는 방법

  • 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
  • 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
  • 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.

자주 묻는 것

Q. ps은 무엇을 하나요?

지금 이 순간 돌고 있는 프로세스를 한 장으로 찍어 보여줍니다 — `ps aux`는 대시 없는 BSD 꼴이고 `ps -ef`는 POSIX 꼴이라, 두 꼴을 섞어 쓰는 것이 가장 흔한 실수입니다.

Q. 어떻게 치나요?

ps aux | ps -ef — 대괄호는 생략할 수 있는 자리입니다.

Q. 옵션은 몇 개나 자주 쓰나요?

여기 정리한 것은 6개입니다. 전체 목록은 man ps에 있습니다. 이 명령은 프로세스·시스템 갈래입니다.

같이 보는 명령

man 페이지: man ps