You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A comprehensive cheatsheet for Alpine Linux, covering package management, system administration, networking, and more. Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc and busybox.
Alpine Linux Cheatsheet
Package Management (apk)
Basic Package Operations
# Update package index
apk update
# Upgrade all installed packages
apk upgrade
# Install a package
apk add <package-name># Remove a package
apk del <package-name># Search for a package
apk search <package-name># Show package info
apk info <package-name># List all installed packages
apk list --installed
# Start a service
rc-service <service-name> start
# Stop a service
rc-service <service-name> stop
# Restart a service
rc-service <service-name> restart
# Add service to default runlevel
rc-update add <service-name> default
# Remove service from default runlevel
rc-update del <service-name> default
# List all services
rc-status
System Information
# Show system information
uname -a
# Show disk usage
df -h
# Show memory usage
free -h
# Show running processes
ps aux
# Show system uptime
uptime
Network Configuration
# Show network interfaces
ip addr show
# Configure network interface
setup-interfaces
# Test network connectivity
ping -c 4 google.com
# Show routing table
ip route show
# Edit network configuration
vi /etc/network/interfaces
User Management
# Add a new user
adduser <username># Add user to group
addgroup <username><groupname># Change password
passwd <username># Delete user
deluser <username># List all users
cat /etc/passwd
# Check disk space
df -h
# Check directory size
du -sh <directory># Mount a device
mount /dev/<device> /mnt/<mountpoint># Unmount a device
umount /mnt/<mountpoint>
Backup and Restore
# Create tar archive
tar -czf backup.tar.gz /path/to/backup
# Extract tar archive
tar -xzf backup.tar.gz
# Create system backup (root required)
lbu package /media/backup.apkovl.tar.gz
Tips and Tricks
Common Configuration Files
/etc/apk/repositories - Package repositories
/etc/network/interfaces - Network configuration
/etc/hostname - System hostname
/etc/hosts - Host mappings
/etc/resolv.conf - DNS configuration
Environment Variables
# Set environment variableexport VARIABLE=value
# View all environment variables
env
# Add permanent environment variableecho"export VARIABLE=value">>~/.profile
System Logs
# View system logs
less /var/log/messages
# View boot messages
dmesg
# Follow log in real-time
tail -f /var/log/messages
# Generate SSH key
ssh-keygen -t rsa -b 4096
# Copy SSH key to remote server
ssh-copy-id user@remote-server
# Edit SSH configuration
vi /etc/ssh/sshd_config
Troubleshooting
Common Commands
# Check system logs for errors
dmesg | grep -i error
# Check service status
rc-service <service-name> status
# Check system resource usage
top
# Check network connections
netstat -tuln
# Check disk health
smartctl -a /dev/sda # Requires smartmontools package