빠른 참조

Ubuntu 치트시트 (APT, dpkg, systemd)

Ubuntu 및 Debian Linux 빠른 참조 가이드: APT 패키지 관리, dpkg 유틸리티, 캐시 정리 및 systemd 서비스 제어를 정리합니다.

· 게시일

APT 및 dpkg를 이용한 패키지 관리

APT 명령어

# Update repository package indexes
sudo apt update

# Upgrade installed packages to newest versions
sudo apt upgrade -y

# Search for a package by keyword
apt search nginx

# Install package
sudo apt install nginx -y

# Remove package keeping configuration
sudo apt remove nginx

# Purge package and configuration files
sudo apt purge nginx

dpkg 명령어

# Identify which package owns a specific binary or file
dpkg -S $(which nginx)

# List all files installed by a package
dpkg -L nginx

# Install a local .deb package file
sudo dpkg -i package.deb

# Show status and details of installed package
dpkg -s nginx

# List all installed packages
dpkg --get-selections

패키지 캐시

다운로드한 패키지 아카이브는 다음 경로에 캐시됩니다:

/var/cache/apt/archives/

캐시에서 오래된 불필요한 패키지 정리:

sudo apt clean
sudo apt autoremove -y

systemd를 이용한 서비스 관리

# Check service status
systemctl status nginx

# Start / stop / restart service
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx

# Enable service to launch at system boot
sudo systemctl enable nginx

관련 주제