기본 Linux 명령어를 넘어 시스템 관리자가 알아야 할 고급 기술들을 다룹니다. 프로세스 모니터링, 로그 분석, 네트워크 디버깅, systemd 서비스 관리까지 실무에서 바로 사용할 수 있는 내용입니다.
Beyond basic Linux commands, this covers advanced skills every system administrator should know. From process monitoring to log analysis, network debugging, and systemd service management - all practical knowledge for real-world use.
프로세스 관리 심화 Advanced Process Management
$ ps aux --sort=-%mem # 메모리 사용량순 정렬
$ ps aux --sort=-%cpu # CPU 사용량순 정렬
# 특정 프로세스 찾기
$ pgrep -a nginx # nginx 관련 프로세스
$ pidof nginx # nginx의 PID만
# 실시간 모니터링
$ top -p 1234,5678 # 특정 PID만 모니터링
$ htop # 향상된 인터페이스 (설치 필요)
# 프로세스 종료
$ kill -15 1234 # 정상 종료 요청 (SIGTERM)
$ kill -9 1234 # 강제 종료 (SIGKILL)
$ pkill -f "node server" # 패턴으로 종료
$ ps aux --sort=-%mem # Sort by memory usage
$ ps aux --sort=-%cpu # Sort by CPU usage
# Find specific processes
$ pgrep -a nginx # nginx related processes
$ pidof nginx # Just nginx PIDs
# Real-time monitoring
$ top -p 1234,5678 # Monitor specific PIDs
$ htop # Enhanced interface (needs install)
# Terminate processes
$ kill -15 1234 # Request graceful shutdown (SIGTERM)
$ kill -9 1234 # Force kill (SIGKILL)
$ pkill -f "node server" # Kill by pattern
📊 주요 시그널 종류 📊 Common Signal Types
- SIGTERM (15): 정상 종료 요청. 프로세스가 정리 작업 후 종료
- SIGTERM (15): Graceful shutdown. Process can clean up before exit
- SIGKILL (9): 강제 종료. 무시할 수 없음
- SIGKILL (9): Force kill. Cannot be ignored
- SIGHUP (1): 설정 파일 다시 읽기 (데몬 재시작)
- SIGHUP (1): Reload config file (daemon restart)
- SIGSTOP (19): 프로세스 일시 정지
- SIGSTOP (19): Pause process
시스템 로그 분석 System Log Analysis
$ journalctl -u nginx # 특정 서비스 로그
$ journalctl -f # 실시간 로그 (tail -f와 유사)
$ journalctl --since "1 hour ago"
$ journalctl -p err # 에러 레벨 이상만
# 부팅 관련 로그
$ journalctl -b # 현재 부팅 로그
$ journalctl -b -1 # 이전 부팅 로그
# 전통적인 로그 파일
$ tail -f /var/log/syslog
$ tail -f /var/log/auth.log # 인증 로그
$ grep "Failed password" /var/log/auth.log
$ journalctl -u nginx # Specific service logs
$ journalctl -f # Real-time logs (like tail -f)
$ journalctl --since "1 hour ago"
$ journalctl -p err # Error level and above
# Boot related logs
$ journalctl -b # Current boot logs
$ journalctl -b -1 # Previous boot logs
# Traditional log files
$ tail -f /var/log/syslog
$ tail -f /var/log/auth.log # Auth logs
$ grep "Failed password" /var/log/auth.log
네트워크 디버깅 Network Debugging
$ ss -tulnp # 열린 포트와 프로세스
$ ss -s # 연결 통계 요약
$ netstat -an | grep :80 # 80번 포트 연결
# 네트워크 인터페이스
$ ip addr # IP 주소 확인
$ ip route # 라우팅 테이블
# DNS 확인
$ dig google.com # DNS 조회
$ nslookup google.com
# 패킷 캡처 (root 필요)
# tcpdump -i eth0 port 80
# tcpdump -i any -w capture.pcap
$ ss -tulnp # Open ports with processes
$ ss -s # Connection statistics summary
$ netstat -an | grep :80 # Port 80 connections
# Network interfaces
$ ip addr # Check IP addresses
$ ip route # Routing table
# DNS check
$ dig google.com # DNS lookup
$ nslookup google.com
# Packet capture (root required)
# tcpdump -i eth0 port 80
# tcpdump -i any -w capture.pcap
디스크 및 메모리 관리 Disk and Memory Management
$ df -h # 파일시스템별 사용량
$ du -sh /var/* # 디렉토리별 크기
$ du -h --max-depth=1 | sort -hr # 크기순 정렬
# 큰 파일 찾기
$ find / -type f -size +100M 2>/dev/null
# 메모리 사용량
$ free -h # 메모리 요약
$ vmstat 1 5 # 가상 메모리 통계
# 캐시 정리 (주의해서 사용)
# sync && echo 3 > /proc/sys/vm/drop_caches
$ df -h # Usage by filesystem
$ du -sh /var/* # Size by directory
$ du -h --max-depth=1 | sort -hr # Sort by size
# Find large files
$ find / -type f -size +100M 2>/dev/null
# Memory usage
$ free -h # Memory summary
$ vmstat 1 5 # Virtual memory stats
# Clear cache (use with caution)
# sync && echo 3 > /proc/sys/vm/drop_caches
systemd 서비스 관리 systemd Service Management
$ systemctl status nginx # 상태 확인
$ systemctl start nginx # 시작
$ systemctl stop nginx # 중지
$ systemctl restart nginx # 재시작
$ systemctl reload nginx # 설정만 다시 로드
# 부팅 시 자동 실행
$ systemctl enable nginx # 활성화
$ systemctl disable nginx # 비활성화
# 모든 서비스 목록
$ systemctl list-units --type=service
$ systemctl list-units --failed # 실패한 서비스
$ systemctl status nginx # Check status
$ systemctl start nginx # Start
$ systemctl stop nginx # Stop
$ systemctl restart nginx # Restart
$ systemctl reload nginx # Reload config only
# Auto-start on boot
$ systemctl enable nginx # Enable
$ systemctl disable nginx # Disable
# List all services
$ systemctl list-units --type=service
$ systemctl list-units --failed # Failed services
💡 서비스 파일 위치 💡 Service File Locations
커스텀 서비스 파일은 /etc/systemd/system/에 생성합니다.
변경 후에는 systemctl daemon-reload를 실행하세요.
Custom service files are created in /etc/systemd/system/.
After changes, run systemctl daemon-reload.
