Contents
see ListLinux 시스템 관리: 2025년 핵심 역량
2025년 Linux 시스템 관리는 커널 보안 강화, 컨테이너 기반 운영, 자동화가 핵심입니다. 리눅스 커널에 Rust 코드가 통합되기 시작했고, 라이브 패치(Live Patching) 사용률이 31.5%로 증가했습니다. 이 문서는 개발자와 시스템 관리자가 즉시 활용할 수 있는 실전 명령어와 설정을 다룹니다.
시스템 정보 확인 필수 명령어
# 시스템 전반 정보
uname -a # 커널 버전, 아키텍처 등
lsb_release -a # Linux 배포판 정보
hostnamectl # 호스트이름, OS, 커널 정보
# 하드웨어 정보
lscpu # CPU 상세 정보
free -h # 메모리 사용량 (human-readable)
df -h # 디스크 사용량
lsblk # 블록 디바이스 목록
nvme list # NVMe SSD 목록
# 실시간 시스템 모니터링
top # 기본 모니터링
htop # 개선된 대화형 모니터링
iotop -o # 디스크 I/O (활성 프로세스만)
vmstat 1 10 # 가상 메모리 통계 (1초 간격 10회)
# 프로세스 상세 분석
ps aux --sort=-%mem | head -20 # 메모리 사용 상위 프로세스
ps aux --sort=-%cpu | head -20 # CPU 사용 상위 프로세스
ss -tulnp # 열린 포트와 프로세스
lsof -i :3000 # 특정 포트 사용 프로세스파일 시스템 관리
# 대용량 파일/디렉토리 찾기
du -sh /* 2>/dev/null | sort -rh | head -20 # 루트 하위 크기 순 정렬
du -sh /var/log/* | sort -rh | head -10 # 로그 디렉토리 크기
# 오래된 파일 찾기 및 삭제
find /var/log -name '*.gz' -mtime +30 -delete # 30일 이상된 .gz 로그 삭제
find /tmp -type f -atime +7 -delete # 7일 이상 미접근 임시파일 삭제
# 특정 크기 이상 파일 찾기
find / -type f -size +500M 2>/dev/null
# 심볼릭 링크 찾기
find /etc -type l -ls
# 파일 권한 일괄 수정
find /var/www -type d -exec chmod 755 {} ;
find /var/www -type f -exec chmod 644 {} ;
# inode 사용량 확인 (파일 수 많을 때 중요)
df -i
find /tmp -type f | wc -l # /tmp의 파일 수 확인sysctl: 커널 파라미터 최적화
# /etc/sysctl.d/99-custom.conf에 설정
# 네트워크 성능 최적화 (고성능 서버용)
cat >> /etc/sysctl.d/99-performance.conf << 'EOF'
# TCP 버퍼 크기 증가
net.core.rmem_max = 134217728
net.core.wmem_max = 134217728
net.ipv4.tcp_rmem = 4096 87380 134217728
net.ipv4.tcp_wmem = 4096 65536 134217728
# 동시 연결 처리 최적화
net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 65535
# TIME_WAIT 소켓 재사용
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
# 파일 핸들 최대값
fs.file-max = 2097152
# 가상 메모리 설정
vm.swappiness = 10 # 스왑 사용 최소화
vm.dirty_ratio = 15
vm.dirty_background_ratio = 5
EOF
# 즉시 적용
sysctl -p /etc/sysctl.d/99-performance.conf
# 현재 값 확인
sysctl net.core.somaxconn
sysctl -a | grep tcpsystemd 서비스 관리
# 서비스 상태 관리
systemctl status nginx # 상태 확인
systemctl start nginx # 시작
systemctl stop nginx # 중지
systemctl restart nginx # 재시작
systemctl reload nginx # 설정 리로드 (무중단)
systemctl enable nginx # 부팅 시 자동 시작
systemctl disable nginx # 자동 시작 해제
# 실패한 서비스 확인
systemctl --failed
# 서비스 로그 확인
journalctl -u nginx # 전체 로그
journalctl -u nginx -n 100 -f # 최근 100줄 + 실시간
journalctl -u nginx --since '1 hour ago'
# 커스텀 서비스 파일 생성
cat > /etc/systemd/system/myapp.service << 'EOF'
[Unit]
Description=My Node.js Application
After=network.target
Wants=postgresql.service
[Service]
Type=simple
User=webapp
WorkingDirectory=/opt/myapp
ExecStart=/usr/bin/node /opt/myapp/dist/index.js
Restart=on-failure
RestartSec=5
# 환경 변수
Environment=NODE_ENV=production
EnvironmentFile=/opt/myapp/.env
# 리소스 제한
LimitNOFILE=65535
MemoryMax=2G
CPUQuota=80%
# 보안 설정
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ReadWritePaths=/opt/myapp/logs
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now myapp.service보안 강화: 방화벽과 SELinux
# UFW (Ubuntu 기반) 방화벽 설정
ufw enable
ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp # SSH
ufw allow 80/tcp # HTTP
ufw allow 443/tcp # HTTPS
# 특정 IP만 허용
ufw allow from 192.168.1.0/24 to any port 5432 # DB 포트
# 현재 규칙 확인
ufw status verbose
# firewalld (RHEL/CentOS 기반)
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-port=3000/tcp
firewall-cmd --reload
firewall-cmd --list-all
# SSH 보안 강화 (/etc/ssh/sshd_config)
PermitRootLogin no
PasswordAuthentication no # 키 인증만 허용
PubkeyAuthentication yes
X11Forwarding no
MaxAuthTries 3
ClientAliveInterval 300
ClientAliveCountMax 2
AllowUsers deploy admin
# SSH 재시작
systemctl reload sshd로그 분석과 모니터링
# journalctl 고급 활용
# 부팅 이후 에러만
journalctl -b -p err
# 특정 시간대 로그
journalctl --since '2026-04-01 00:00:00' --until '2026-04-08 23:59:59'
# 디스크 사용량 확인 및 정리
journalctl --disk-usage
journalctl --vacuum-size=500M # 500MB 이하로 정리
journalctl --vacuum-time=7d # 7일 이상된 로그 삭제
# 로그 로테이션 설정 (/etc/logrotate.d/myapp)
cat > /etc/logrotate.d/myapp << 'EOF'
/opt/myapp/logs/*.log {
daily
rotate 30
compress
delaycompress
missingok
notifempty
create 644 webapp webapp
postrotate
systemctl reload myapp
endscript
}
EOF자동화: cron과 bash 스크립트
# crontab 설정
crontab -e
# 자동화 작업 예시
# 형식: 분 시 일 월 요일 명령어
0 2 * * * /opt/scripts/backup.sh # 매일 새벽 2시 백업
0 */6 * * * /opt/scripts/health-check.sh # 6시간마다 헬스체크
30 1 * * 0 /opt/scripts/weekly-cleanup.sh # 매주 일요일 새벽 청소
# 실용적인 백업 스크립트
cat > /opt/scripts/backup.sh << 'SCRIPT'
#!/bin/bash
set -euo pipefail
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/backup"
DB_NAME="myapp"
# PostgreSQL 백업
pg_dump -U postgres $DB_NAME | gzip > "$BACKUP_DIR/db_${DATE}.sql.gz"
# 애플리케이션 파일 백업
tar -czf "$BACKUP_DIR/app_${DATE}.tar.gz" /opt/myapp --exclude='*.log'
# 30일 이상된 백업 삭제
find $BACKUP_DIR -name '*.gz' -mtime +30 -delete
# 성공 로그
echo "[$(date)] 백업 완료: db_${DATE}.sql.gz" >> /var/log/backup.log
SCRIPT
chmod +x /opt/scripts/backup.sh프로세스 성능 분석: strace와 perf
# strace: 시스템 콜 추적
strace -p $(pgrep nginx) # 실행 중인 nginx 추적
strace -e trace=file ls /tmp # 파일 관련 시스템 콜만
strace -c command # 시스템 콜 통계 요약
# perf: 성능 분석
perf top # 실시간 CPU 핫스팟
perf record -g -p $(pgrep myapp) # 60초간 프로파일 수집
perf report # 결과 분석
# lsof: 파일/포트 사용 분석
lsof -u webapp # 특정 사용자의 열린 파일
lsof -p $(pgrep myapp) # 특정 프로세스의 열린 파일
lsof +D /var/log # 디렉토리 접근 프로세스
# netstat/ss 대체 (ss가 더 빠름)
ss -s # 소켓 통계 요약
ss -tulnp # TCP/UDP 포트 모두
ss -tp | grep ESTABLISHED # 활성 TCP 연결정리
2025년 Linux 시스템 관리의 핵심은 systemd 기반 서비스 관리, sysctl 파라미터 최적화, 방화벽 보안 설정, 자동화 스크립트의 조합입니다. 커널 라이브 패치로 리부트 없이 보안 업데이트를 적용하고, journalctl로 구조화된 로그를 분석하며, cron과 bash 스크립트로 반복 작업을 자동화하는 것이 현대 Linux 시스템 관리자의 기본 역량입니다. 특히 systemd 서비스 파일의 보안 설정(NoNewPrivileges, PrivateTmp, MemoryMax)을 적극 활용하면 시스템 보안을 크게 강화할 수 있습니다.