반응형

DevOps Engineer's Essential Linux Command Set: A Wiki Guide to EfficiencyEN

Mastering core Linux commands is crucial for DevOps engineers to achieve operational prowess. This guide covers essential commands for CI/CD Pipeline Management, Container Orchestration, Network Debugging, and Real-time Monitoring & Log Analysis.

CI/CD Pipeline Management

`git`: Version control, CI trigger.

git clone <repo-url>
git pull origin main
git commit -m "feat: add new feature"
git push origin main

DevOps Tip: Automate `git pull` in your CI pipeline for fresh code. Use specific branch tags for releases.

`ssh`: Secure remote execution, file transfer.

ssh user@host "ls -la /var/www/html"
scp /local/path/file user@host:/remote/path/

DevOps Tip: Use SSH keys for passwordless authentication in automated scripts.

`rsync`: Efficient file synchronization.

rsync -avz /local/dir/ user@host:/remote/dir/

DevOps Tip: `rsync` with `--delete` option can be used for deployment artifact cleanup.

`find & xargs`: File search and command execution.

find . -name "*.log" | xargs rm

DevOps Tip: Great for bulk operations on files, like compressing old logs or deleting temporary files.

Container Orchestration with Kubernetes

`kubectl`: Kubernetes control tool.

kubectl get pods
kubectl apply -f deployment.yaml
kubectl logs <pod-name> -f

DevOps Tip: Use `kubectl describe` for detailed resource information during debugging.

`docker`: Container runtime.

docker build -t myapp:1.0 .
docker run -d -p 80:80 myapp:1.0
docker ps -a

DevOps Tip: Learn Docker Compose for multi-container local development.

`helm`: Kubernetes package manager.

helm install my-release stable/nginx
helm upgrade my-release -f values.yaml stable/nginx
helm uninstall my-release

DevOps Tip: Helm charts provide reproducible deployments across environments.

Network Debugging & Diagnostics

`ss`: Socket statistics (netstat replacement).

ss -tunap
ss -ltn 'sport = :80'

DevOps Tip: `ss` is faster and more powerful than `netstat` for modern Linux systems.

`tcpdump`: Packet analyzer.

tcpdump -i eth0 port 80
tcpdump -i any host 192.168.1.100

DevOps Tip: Use `tcpdump` to verify network traffic and pinpoint connectivity issues.

`dig`: Domain Information Groper (DNS lookup).

dig example.com A
dig @8.8.8.8 google.com MX

DevOps Tip: Essential for diagnosing DNS resolution problems in distributed systems.

`curl / wget`: Data transfer tools.

curl -I https://google.com
wget -O index.html https://example.com/

DevOps Tip: Use `curl -v` for verbose output to debug HTTP requests and responses.

Real-time Monitoring & Log Analysis

`top / htop`: Process monitoring.

top
htop # more user-friendly version of top

DevOps Tip: `htop` provides a better interactive interface for process management.

`journalctl`: Systemd journal client.

journalctl -u nginx.service -f
journalctl --since "2 hours ago"

DevOps Tip: Use `journalctl` for centralized logging across systemd services.

`tail`: Output the last part of files (log monitoring).

tail -f /var/log/syslog
tail -n 100 access.log | grep ERROR

DevOps Tip: `tail -f` is indispensable for real-time log monitoring during deployments or debugging.

`grep / sed / awk`: Text processing superpowers.

grep "ERROR" app.log
sed 's/old_text/new_text/g' file.txt
awk '{print $1, $3}' access.log

DevOps Tip: Master these three for powerful log analysis and data extraction.

Command Summary

CommandPurposeCategory
git Version control, CI trigger CI/CD Pipeline Management
ssh Secure remote execution, file transfer CI/CD Pipeline Management
rsync Efficient file synchronization CI/CD Pipeline Management
find & xargs File search and command execution CI/CD Pipeline Management
kubectl Kubernetes control tool Container Orchestration with Kubernetes
docker Container runtime Container Orchestration with Kubernetes
helm Kubernetes package manager Container Orchestration with Kubernetes
ss Socket statistics (netstat replacement) Network Debugging & Diagnostics
tcpdump Packet analyzer Network Debugging & Diagnostics
dig Domain Information Groper (DNS lookup) Network Debugging & Diagnostics
curl / wget Data transfer tools Network Debugging & Diagnostics
top / htop Process monitoring Real-time Monitoring & Log Analysis
journalctl Systemd journal client Real-time Monitoring & Log Analysis
tail Output the last part of files (log monitoring) Real-time Monitoring & Log Analysis
grep / sed / awk Text processing superpowers Real-time Monitoring & Log Analysis
Metadata

Tistory Tags:

DevOpsLinuxCommandsCI/CDKubernetesContainerizationNetworkDebuggingMonitoringShellScriptingInfrastructureAsCodeSystemd

Search Summary:

Master essential Linux commands for DevOps! This wiki-guide covers CI/CD, Kubernetes, network debugging, and real-time monitoring with practical examples & tips.

 

반응형

+ Recent posts