Files
reference/source/_posts/alpine-linux.md
T
Fechin 172342c8a3 feat: modernize development toolchain
- Add comprehensive development tooling:
  * ESLint configuration with modern JavaScript rules
  * Prettier for consistent code formatting
  * Husky for Git hooks automation
  * lint-staged for pre-commit checks
  * Conventional Commits with commitlint
  * Stylelint for CSS code quality

- Fix CSS issues:
  * Resolve duplicate selectors in layout_note.css
  * Merge duplicate selectors in layout_list.css
  * Ensure stylelint compliance

- Apply consistent code formatting:
  * Format all JavaScript, CSS, and Markdown files
  * Standardize code style across the project
  * Fix console statement warnings in main.js

- Update project documentation:
  * Enhance README with modern development practices
  * Update package.json with new scripts and dependencies

This modernization establishes a robust development environment with
automated code quality checks, consistent formatting~
2025-06-18 14:09:17 +08:00

4.5 KiB

title, date, icon, background, tags, categories, intro
title date icon background tags categories intro
Alpine Linux 2024-03-20 12:00:00 icon-alpine bg-blue-600
linux
server
container
Operating System
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

Advanced Package Operations

# Add package from testing repository
apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing <package-name>

# Add multiple packages
apk add package1 package2 package3

# Clean package cache
apk cache clean

System Administration

Service Management (OpenRC)

# 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

File System Operations

Basic File Operations

# Create directory
mkdir <directory-name>

# Remove directory
rm -r <directory-name>

# Copy files
cp <source> <destination>

# Move/rename files
mv <source> <destination>

# Change permissions
chmod <permissions> <file>

# Change ownership
chown <user>:<group> <file>

Container Operations

Docker Support

# Install Docker
apk add docker

# Start Docker service
rc-service docker start

# Enable Docker at boot
rc-update add docker default

System Maintenance

Disk Operations

# 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 variable
export VARIABLE=value

# View all environment variables
env

# Add permanent environment variable
echo "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

Security

Firewall (using iptables)

# Install iptables
apk add iptables

# Allow SSH (port 22)
iptables -A INPUT -p tcp --dport 22 -j ACCEPT

# Save iptables rules
/etc/init.d/iptables save

# Restore iptables rules
/etc/init.d/iptables restart

SSH Configuration

# 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