HomeAwsLinux Commands for Cloud and Devops Engineering

Linux Commands for Cloud and Devops Engineering

Here are some of the most commonly used Linux commands:

1. File and Directory Management

  • ls: List files and directories in the current directory.
  • cd: Change the current directory.
  • pwd: Print the current working directory.
  • mkdir: Create a new directory.
  • rm: Remove files or directories.
  • cp: Copy files or directories.
  • mv: Move or rename files or directories.
  • touch: Create an empty file or update the timestamp of an existing file.
  • cat: View the content of a file.
  • less: View file content page by page.
  • find: Search for files and directories.

2. File Permissions

  • chmod: Change file or directory permissions.
  • chown: Change the owner of a file or directory.
  • chgrp: Change the group ownership of a file or directory.

3. Text Processing

  • grep: Search for text within files.
  • sed: Stream editor for filtering and transforming text.
  • awk: A powerful text processing language.
  • sort: Sort lines of text files.
  • wc: Count words, lines, and characters in a file.
  • diff: Compare two files line by line.

4. System Information

  • uname -a: Show detailed system information.
  • df: Report file system disk space usage.
  • du: Estimate file space usage.
  • top: Display tasks and system resource usage.
  • htop: An interactive process viewer (similar to top).
  • free: Show memory and swap usage.
  • uptime: Show how long the system has been running.
  • ps: Display a snapshot of current processes.
  • whoami: Show the current user.
  • hostname: Show or set the system’s hostname.

5. Networking

  • ping: Check network connectivity to a host.
  • ifconfig: Configure network interfaces (use ip for newer systems).
  • netstat: Display network connections, routing tables, and more.
  • curl: Transfer data from or to a server using various protocols.
  • wget: Download files from the web.

6. Package Management

  • Debian/Ubuntu:
    • apt-get: Install, update, and manage software packages.
  • RedHat/CentOS:
    • yum or dnf: Install, update, and manage software packages.

7. Compression and Archiving

  • tar: Archive multiple files into a single file and compress it.
  • zip: Compress files into a zip archive.
  • unzip: Extract files from a zip archive.
  • gzip: Compress files using the gzip algorithm.
  • gunzip: Decompress gzip files.

8. User Management

  • adduser: Add a new user to the system.
  • passwd: Change a user’s password.
  • userdel: Delete a user from the system.
  • usermod: Modify a user account.

9. Process Management

  • kill: Terminate a process by its PID.
  • killall: Terminate all processes by name.
  • fg: Bring a background job to the foreground.
  • bg: Resume a suspended job in the background.
  • jobs: List jobs running in the background.

10. Other Essential Commands

  • sudo: Execute a command as another user, typically the superuser.
  • echo: Display a line of text or a variable.
  • history: Display a list of previously executed commands.
  • alias: Create a shortcut for a command.
  • df -h: Display disk usage in human-readable format.

These commands are essential for managing and interacting with a Linux system.

Here are the most commonly used Linux commands by AWS and DevOps Engineers:

1. System Information and Resource Monitoring

  • top / htop: Monitor system processes and resource usage in real time.
  • free -m: Check memory usage.
  • df -h: Check disk space usage.
  • uptime: Show system uptime and load averages.
  • vmstat: Report virtual memory statistics.
  • iostat: Monitor CPU and I/O statistics.
  • lscpu: Display CPU architecture information.

2. Networking and Cloud Connectivity

  • ping: Test network connectivity to a host.
  • curl: Send HTTP requests and test API endpoints (e.g., to check health of AWS services).
  • wget: Download files from the web or S3 buckets.
  • ssh: Securely connect to remote servers.
  • scp: Securely copy files between hosts.
  • netstat / ss: Check network connections and listening services.
  • nslookup / dig: Query DNS records to troubleshoot domain issues.
  • traceroute: Trace the route packets take to a destination, useful for diagnosing AWS VPC network issues.
  • telnet: Test open ports (commonly used for checking service connectivity).

3. File Management and Handling Large Files

  • ls -lh: List files with human-readable sizes.
  • find: Search for files, often used with automated backups or logs.
  • du -sh: Check the size of directories.
  • cat, less, more, tail -f: View log files, often used in troubleshooting logs from AWS services or containers.
  • gzip, gunzip, tar: Compress and extract files.
  • rsync: Synchronize files between servers or from local to AWS S3.

4. File Permissions and Ownership

  • chmod: Modify file or directory permissions.
  • chown: Change file or directory ownership.
  • chgrp: Change the group of a file or directory.

5. Service and Process Management

  • ps aux: List all running processes.
  • systemctl: Manage services (start, stop, restart, enable at boot).
  • kill / killall: Terminate running processes (e.g., web servers, database services).
  • journalctl: View system logs, especially for services managed with systemd.

6. Package Management

  • Ubuntu/Debian:
    • apt-get update && apt-get upgrade: Update and upgrade packages.
  • RedHat/CentOS:
    • yum update or dnf: Manage packages.
  • pip: Install Python packages, often used for deploying AWS Lambda or EC2 instances.

7. Version Control (Git)

  • git clone: Clone a repository (often from GitHub, GitLab, or Bitbucket).
  • git pull: Update the local repository with the latest changes.
  • git checkout: Switch branches or restore working tree files.
  • git log: View commit history.
  • git diff: Show changes between commits.

8. AWS-Specific CLI Commands

  • AWS CLI (aws): Manage AWS resources directly from the terminal.
    • aws ec2 describe-instances: List EC2 instances.
    • aws s3 cp / sync: Upload/download files to/from S3 buckets.
    • aws lambda invoke: Test and invoke AWS Lambda functions.
    • aws cloudwatch get-metric-statistics: Retrieve metrics for monitoring.
    • aws elb describe-load-balancers: List load balancers in your AWS environment.

9. Docker and Container Management

  • docker ps: List running Docker containers.
  • docker images: List Docker images on a host.
  • docker pull: Download a Docker image from Docker Hub.
  • docker run: Run a Docker container.
  • docker exec: Execute commands in a running container.
  • docker logs: View logs from a container.

10. Kubernetes (K8s) Management

  • kubectl get pods: List all running pods in a Kubernetes cluster.
  • kubectl describe pod <pod_name>: Detailed information about a pod.
  • kubectl apply -f <file.yaml>: Apply a YAML configuration to the cluster.
  • kubectl logs <pod_name>: View logs of a specific pod.
  • kubectl exec -it <pod_name> — /bin/bash: Access a running pod’s shell.

11. CI/CD Tools (Jenkins, GitLab, CircleCI)

  • jenkins-cli.jar: Access Jenkins from the command line.
  • curl -X POST <jenkins_url>: Trigger Jenkins jobs via API.
  • git tag: Work with tags in repositories for CI/CD versioning.

12. Infrastructure as Code (IaC)

  • Terraform:
    • terraform init: Initialize a Terraform configuration.
    • terraform plan: Preview the changes that will be applied.
    • terraform apply: Apply the infrastructure changes.
    • terraform destroy: Tear down the infrastructure.
  • Ansible:
    • ansible-playbook: Execute Ansible playbooks to automate infrastructure management.
    • ansible -i <inventory> -m ping: Test connection to hosts in the inventory.

13. Log and Monitoring Tools

  • tail -f /var/log/syslog: Monitor system logs in real-time.
  • journalctl -u <service>: View logs for a specific service.
  • dmesg: Print kernel ring buffer messages (useful for diagnosing system hardware issues).
  • CloudWatch:
    • aws logs tail /aws/lambda/<function_name>: Stream logs from AWS CloudWatch for Lambda functions.

14. Scripting and Automation

  • Bash Scripting:
    • #!/bin/bash: The shebang used at the start of shell scripts.
    • for, while, if, case: Used to write conditional scripts for automation.
    • crontab: Schedule jobs for regular tasks, like backups or health checks.

These commands are essential for AWS and DevOps engineers to effectively manage cloud infrastructure, automate workflows, troubleshoot issues, and monitor system performance.

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

To deliver applications and desktops to 10,000 concurrent users in a Citrix Virtual Apps and Desktops environment, the architecture needs...
L2 Admin Issues (Intermediate Level) L3 Admin Issues (Advanced Level) General Troubleshooting Approach: These issues require proactive monitoring and troubleshooting...
Citrix Virtual Desktops are in Unregistered  State how to Troubleshoot: When Citrix Virtual Desktops are in an Unregistered state, it...
×

Hello!

Click one of our contacts below to chat on WhatsApp

×