Sunday, March 16, 2025

Think-with-tech common used flags for managing infrastructure, cloud infra, security, and automation.


Below are some of the most commonly used flags (options/switches) for essential tools across different areas.

1. Linux & System Administration

 ls (List Directory Contents)

# bash
ls -l    # Long format
ls -a    # Show hidden files
ls -h    # Human-readable sizes
ls -t    # Sort by modification time

 grep (Search for Patterns)

# bash
grep -i    # Case-insensitive search
grep -r    # Recursive search
grep -v    # Invert match (exclude)
grep -E    # Use extended regex

 find (Search Files & Directories)

# bash
find / -name "*.log"     # Find all log files
find . -type d           # Find directories only
find . -mtime -7         # Find files modified in the last 7 days

 tar (Archive & Extract Files)

# bash
tar -cvf archive.tar file   # Create archive
tar -xvf archive.tar        # Extract archive
tar -czvf archive.tar.gz dir# Compress with gzip

 chmod (Change File Permissions)

# bash
chmod -R 755 dir/   # Change directory permissions recursively

2. Git & Version Control

 git (Version Control)

# bash
git clone -b branch-name repo-url   # Clone a specific branch
git log --oneline --graph --all     # View commit history
git diff --staged                   # Show staged changes
git reset --hard HEAD~1              # Reset to previous commit

3. Kubernetes (kubectl)

# bash
kubectl get pods -A               # List all pods across namespaces
kubectl apply -f deployment.yaml   # Apply changes from YAML file

4. Docker & Containerization

 docker (Container Management)

# bash
docker ps -a        # List containers in all states
docker images -q    # List only image IDs
docker run -it ubuntu bash  # Run an interactive container
docker rm -f $(docker ps -aq)  # Remove all containers by force

5. Ansible (Automation)

# bash

ansible-playbook -i inventory.ini site.yml --check   # Dry-run mode

ansible-playbook -vv site.yml                        # Increase verbosity
ansible-playbook --tags "deploy" site.yml           # Run specific tags

6. Terraform (Infrastructure as Code)

# bash
terraform plan -out=tfplan  # Preview changes
terraform destroy --auto-approve  # Destroy infra without confirmation

7. AWS CLI (Cloud Management)

# bash
aws s3 ls --recursive     # List all S3 objects recursively
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running"
aws eks update-kubeconfig --name my-cluster   # Update kubeconfig for EKS

8. Networking & Security

 curl (HTTP Requests)

# bash
curl -I https://example.com     # Get HTTP headers
curl -X POST -d '{"key":"value"}' -H "Content-Type: application/json" https://api.com
curl -k https://untrusted-site.com  # Ignore SSL certificate errors

 iptables (Firewall Rules)

# bash
iptables -L -n -v    # List firewall rules
iptables -A INPUT -p tcp --dport 22 -j ACCEPT  # Allow SSH
iptables -F          # Flush all rules

9. Logging & Monitoring

 journalctl (System Logs)

# bash
journalctl -u nginx --since "1 hour ago"  # View logs for a service
journalctl -f  # Follow logs in real-time

 top / htop (Process Monitoring)

# bash
top -u user  # Show processes for a specific user
htop -s %MEM  # Sort by memory usage

10. Miscellaneous

 ssh (Remote Access)

# bash
ssh -i my-key.pem user@server  # Use a private key
ssh -p 2222 user@server        # Connect via a different port

 rsync (File Synchronization)

# bash
rsync -avz source/ user@remote:/destination/  # Sync files with compression
rsync --delete -avz source/ dest/  # Sync and delete extra files in the destination

twtech-insights:

These flags make command-line operations more efficient, whether you're managing infrastructure, cloud, security, or automation.

No comments:

Post a Comment

AWS DynamoDB | Read/Write Capacity Modes.

  In Amazon DynamoDB, Read/Write Capacity Mode s determine how twtech pays for throughput and how DynamoDB allocates resources to serve ...