Linux Commands Every Developer Should Know

TELEGRAM
0/5 Votos: 0
Reportar esta app

Descripción

Why Every Developer Needs Linux Skills

Over 90% of web servers run Linux. Cloud instances are Linux. CI/CD pipelines are Linux. Containers are Linux at their core. You don’t need to be a Linux expert, but you need to be comfortable.

Navigation and Files

# Where am I?
pwd

# List files (detailed view)
ls -la

# Change directory
cd /var/log        # Absolute path
cd ../             # Go up one level
cd ~               # Home directory

# Create directories
mkdir project
mkdir -p deep/nested/path

# Copy, move, delete
cp file.txt backup.txt
cp -r source_dir dest_dir  # Recursive copy
mv file.txt new-name.txt
rm file.txt
rm -rf directory/  # BE CAREFUL! No recycle bin

Reading Files

cat file.txt                  # Print entire file
head -n 20 file.txt          # First 20 lines
tail -n 20 file.txt          # Last 20 lines
tail -f /var/log/nginx/error.log  # Follow log in real-time
less file.txt                 # Page through file

Search and Find

# Find files
find /var -name "*.log" -mtime -7  # Log files from last 7 days

# Search file contents
grep "ERROR" application.log
grep -r "database_url" ./config/  # Recursive search
grep -n "function" app.js         # With line numbers

# Powerful text processing
cat access.log | awk '{print $1}' | sort | uniq -c | sort -rn | head -10

Process Management

# View running processes
ps aux
top         # Live process monitor
htop        # Better process monitor

# Kill processes
kill 1234          # Graceful kill by PID
kill -9 1234       # Force kill
pkill nginx        # Kill by name

# Background jobs
python server.py &    # Run in background
jobs                  # List background jobs
fg                    # Bring to foreground

Networking

curl https://api.example.com/health  # HTTP request
curl -X POST -H "Content-Type: application/json"      -d '{"key":"value"}' https://api.example.com/

# Check open ports
netstat -tlnp
ss -tlnp

# SSH to server
ssh [email protected]
ssh -i key.pem ubuntu@ec2-ip-address

Permissions

chmod +x script.sh        # Make executable
chmod 755 script.sh       # rwxr-xr-x
chown user:group file     # Change ownership
sudo command              # Run as root

Deixe um comentário

O seu endereço de email não será publicado. Campos obrigatórios marcados com *