AWS/Linux Commands Cheatsheet for DevOps Engineers

As a DevOps engineer working with AWS and Linux, having a solid understanding of command-line tools is essential for managing infrastructure, automating tasks, and troubleshooting issues.

In this comprehensive cheatsheet, we'll cover intermediate and expert-level AWS/Linux commands commonly used by DevOps engineers.

Each command will be described in detail, accompanied by examples and relevant documentation links.

AWS CLI Commands

AWS Configuration and Authentication

  1. aws configure: Configure AWS CLI with your access key, secret key, default region, and output format. Documentation

  2. aws sts get-caller-identity: Retrieve the AWS account ID and IAM user details. This command is useful for verifying your authentication and authorization. Documentation

  3. aws ec2 describe-instances: Retrieve information about EC2 instances in your AWS account. Documentation

  4. aws s3 ls: List all S3 buckets in your AWS account. Documentation

  5. aws iam list-users: List all IAM users in your AWS account. Documentation

EC2 Instance Management

  1. aws ec2 run-instances: Launch new EC2 instances based on specified parameters, such as instance type, AMI, security groups, and key pair. Documentation

  2. aws ec2 describe-instances: Retrieve information about EC2 instances, including their status, public/private IP addresses, and tags. Documentation

  3. aws ec2 start-instances: Start one or more stopped EC2 instances. Documentation

  4. aws ec2 stop-instances: Stop one or more running EC2 instances. Documentation

  5. aws ec2 terminate-instances: Terminate one or more EC2 instances. Exercise caution, as this action is irreversible. Documentation

S3 Bucket Operations

  1. aws s3 cp: Copy files and directories between local machine and S3 buckets, or between S3 buckets. Documentation

  2. aws s3 sync: Synchronize files and directories between a local directory and an S3 bucket. This command is useful for incremental backups or data migrations. Documentation

  3. aws s3 rm: Remove objects (files) from an S3 bucket. Documentation

  4. aws s3 ls: List objects (files) in an S3 bucket. Documentation

  5. aws s3api put-bucket-policy: Set an S3 bucket policy to define access permissions. Documentation

Networking and Security

  1. aws ec2 create-security-group: Create a security group to control inbound and outbound traffic for EC2 instances. Documentation

  2. aws ec2 authorize-security-group-ingress: Add an inbound rule to a security group to allow specific traffic to EC2 instances. Documentation

  3. aws ec2 describe-security-groups: Retrieve information about security groups in your AWS account. Documentation

  4. aws elbv2 create-load-balancer: Create a load balancer for distributing traffic across multiple EC2 instances. Documentation

  5. aws route53 change-resource-record-sets: Update DNS records in Amazon Route 53. This command is useful for managing domain names and routing traffic. Documentation

AWS CloudFormation

  1. aws cloudformation create-stack: Create a new AWS CloudFormation stack based on a template file. Documentation

  2. aws cloudformation describe-stack-events: Retrieve events associated with a specific AWS CloudFormation stack. Documentation

  3. aws cloudformation update-stack: Update an existing AWS CloudFormation stack by modifying the template or stack parameters. Documentation

  4. aws cloudformation delete-stack: Delete an AWS CloudFormation stack and all associated resources. Documentation

  5. aws cloudformation validate-template: Validate the syntax and structure of an AWS CloudFormation template file. Documentation

Linux Commands

File and Directory Operations

  1. ls: List files and directories in the current directory. Documentation

  2. cd: Change the current directory. Use cd .. to navigate to the parent directory. Documentation

  3. pwd: Print the current working directory. Documentation

  4. mkdir: Create a new directory. Documentation

  5. rm: Remove files and directories. Use the -r option to remove directories recursively. Documentation

Text Processing

  1. grep: Search for patterns in files or command output. Documentation

  2. sed: Stream editor for filtering and transforming text. Documentation

  3. awk: Pattern scanning and processing language for manipulating text files. Documentation

  4. cut: Extract sections from lines of files. Documentation

  5. sort: Sort lines of text files. Documentation

Process Management

  1. ps: Display information about active processes. Documentation

  2. top: Monitor system processes and resource usage in real-time. Documentation

  3. kill: Send a signal to terminate or control processes. Documentation

  4. nohup: Run a command that keeps running even after logging out. Documentation

  5. bg/fg: Control background and foreground jobs. Documentation

System Monitoring and Resource Management

  1. df: Display disk space usage of file systems. Documentation

  2. free: Display memory usage and available space. Documentation

  3. top: Monitor CPU and memory usage of processes in real-time. Documentation

  4. htop: Interactive process viewer with more advanced features. Documentation

  5. iotop: Monitor I/O usage information of processes. Documentation

Network Configuration and Troubleshooting

  1. ifconfig: Display or configure network interfaces. Documentation

  2. ping: Send ICMP echo requests to a network host. Documentation

  3. netstat: Display network connections, routing tables, and interface statistics. Documentation

  4. nslookup: Query DNS servers for DNS records. Documentation

  5. traceroute: Print the route packets take to network host. Documentation

Package Management

  1. apt-get: Command-line tool for package management in Debian-based systems. Documentation

  2. yum: Package manager for RPM-based distributions like CentOS, Fedora, and Red Hat. Documentation

  3. dnf: Next-generation package manager used in Fedora and CentOS 8+. Documentation

  4. pacman: Package manager for Arch Linux and its derivatives. Documentation

  5. pip: Package installer for Python. Documentation

User and Group Management

  1. useradd: Create a new user account. Documentation

  2. usermod: Modify user account properties. Documentation

  3. userdel: Delete a user account. Documentation

  4. groupadd: Create a new group. Documentation

  5. groupmod: Modify group properties. Documentation

File Permissions

  1. chmod: Change file permissions. Documentation

  2. chown: Change file owner and group. Documentation

  3. chgrp: Change group ownership of files. Documentation

  4. lsattr: List file attributes on a Linux second extended file system. Documentation

  5. chattr: Change file attributes on a Linux second extended file system. Documentation

Archiving and Compression

  1. tar: Archive files together and create a tarball. Documentation

  2. gzip: Compress files using gzip compression. Documentation

  3. gunzip: Decompress files compressed with gzip. Documentation

  4. zip: Package and compress files into a zip archive. Documentation

  5. unzip: Extract files from a zip archive. Documentation

System Information

  1. uname: Print system information (kernel version, hostname, etc.). Documentation

  2. uptime: Display system uptime and load average. Documentation

  3. date: Print or set the system date and time. Documentation

  4. whoami: Print the username of the current user. Documentation

  5. hostname: Print or set the system hostname. Documentation

SSH and Remote Access

  1. ssh: Open a secure shell connection to a remote host. Documentation

  2. scp: Securely copy files between local and remote hosts. Documentation

  3. rsync: Efficiently synchronize files and directories between local and remote hosts. Documentation

  4. ssh-keygen: Generate SSH key pairs for secure authentication. Documentation

  5. ssh-agent: Manage SSH agents for storing private keys. Documentation

Conclusion

This extensive AWS/Linux commands cheatsheet covers a wide range of intermediate and expert-level commands that DevOps engineers use on a daily basis. Each command was described in detail, accompanied by relevant examples and documentation links for further reference. By familiarizing yourself with these commands, you'll be better equipped to manage AWS infrastructure, perform Linux system administration tasks, and streamline your DevOps workflows.

Remember, practice and hands-on experience are crucial for mastering these commands. Experiment with them in a controlled environment and explore their various options and arguments. The more you use them, the more proficient you'll become in leveraging their power for efficient and effective DevOps operations.

Happy command-line hacking!

Disclaimer: This article is intended as a reference guide and should not be considered as exhaustive or definitive. Command options, behaviors, and documentation may vary based on the specific Linux distribution, version, and AWS service configurations. Always refer to the official documentation for the most accurate and up-to-date information.