티스토리 뷰
서버 배포를 위해서 Linux OS를 사용하게 된다.
GUI도 지원하지만, 대부분 CLI로 명령어를 직접 입력하여 조작한다.
가장 많이 사용하고 반복된 작업임에도 구글링으로 끝나 매번 잊어버리게 된다.
이번 기회에 자주 사용되는 프로세스 관리 명령어를 정리해보았다.
[참고] 실행환경
Ubuntu 20.04 AMI 적용한 AWS EC2
ps 명령어로 프로세스 조회
ps <option>
- -l : long format
- -f : full format
- -e : all process
ps -l
# 모든 프로세스 조회
ps -ef
# 특정 문자가 들어간 프로세스 조회
ps -ef | grep <STRING>
cf. --help o 옵션 명령어로 도움말 엿보기
$ ps --help o
Usage:
ps [options]
Output formats:
-F extra full
-f full-format, including command lines
f, --forest ascii art process tree
-H show process hierarchy
-j jobs format
j BSD job control format
-l long format
l BSD long format
-M, Z add security data (for SELinux)
-O <format> preloaded with default columns
O <format> as -O, with BSD personality
-o, o, --format <format>
user-defined format
s signal format
u user-oriented format
v virtual memory format
X register format
-y do not show flags, show rss vs. addr (used with -l)
--context display security context (for SELinux)
--headers repeat header lines, one per page
--no-headers do not print header at all
--cols, --columns, --width <num>
set screen width
--rows, --lines <num>
set screen height
ps 명령어로 프로세스 종료
# -9 : 강제 종료
kill -9 <PID or PPID>
sudo kill -9 <PID or PPID>
# -15 : 작업 종료
kill -15 <PID or PPID>
lsof 로 실행중인 포트 확인
sudo lsof -i -P -n
sudo lsof -i -P -n | grep LISTEN
참고자료
https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/
'TIL, WIL' 카테고리의 다른 글
0225 TIL: 3계층 아키텍처에서 Service-Repository-Model 의존성 주입하기 (Express, Sequelize) (0) | 2023.02.25 |
---|---|
0213-0219 WIL : NoSQL vs SQL (0) | 2023.02.19 |
0218 TIL : 웹소켓(WebSocket), Socket.io (0) | 2023.02.18 |
댓글