Appendix B: Command Cheat Sheet
Friends, keep this cheat sheet open beside you during labs. Ubuntu and Amazon Linux/CentOS commands are given side by side, so pick the right command for your OS.
मित्रांनो, लॅब करताना ही चीट शीट बाजूला उघडी ठेवा. Ubuntu आणि Amazon Linux/CentOS च्या कमांड्स शेजारी-शेजारी दिल्या आहेत, म्हणजे तुमच्या OS प्रमाणे योग्य कमांड निवडा.
दोस्तों, लैब करते समय ये चीट शीट बगल में खुली रखो. Ubuntu और Amazon Linux/CentOS की कमांड्स साथ-साथ दी गई हैं, तो अपने OS के हिसाब से सही कमांड चुनो.
B.1 Package and service management
| Task | Ubuntu | Amazon Linux 2023 / CentOS Stream 9 |
|---|---|---|
| Update package lists / upgrade | sudo apt update && sudo apt upgrade -y |
sudo yum update -y |
| Install | sudo apt install -y <pkg> |
sudo yum install -y <pkg> |
| Remove | sudo apt remove <pkg> |
sudo yum remove <pkg> |
| Search | apt search <word> |
yum search <word> |
| Start now + enable at boot | sudo service <svc> start + sudo systemctl enable <svc> |
same |
| Status / logs | sudo service <svc> status, journalctl -u <svc> -f |
same |
| Apache service | apache2 |
httpd |
| MySQL service | mysql |
mariadb |
| Web user | www-data |
nginx / apache |
| Firewall | sudo ufw allow 'Nginx Full' |
sudo firewall-cmd --permanent --add-service=http && sudo firewall-cmd --reload |
B.2 Files, permissions, users
ls -la cd /path pwd mkdir -p a/b
cp -r src dst mv old new rm -r dir touch file
cat f less f head -n 20 f tail -f f wc -l f
chmod 755 dir chmod 644 file chmod 400 key.pem
sudo chown -R user:group /path
sudo useradd -m -s /bin/bash u sudo passwd u sudo usermod -aG wheel u (Ubuntu: sudo)
B.3 Search and text
grep -rin "text" /path find / -name "*.conf" 2>/dev/null
awk '{print $1}' file sed -i 's/old/new/g' file
cmd | sort | uniq -c | sort -rn cmd > out.txt 2>&1 echo x | sudo tee -a /etc/file
B.4 Networking
ip a ip r hostname -I curl -s https://checkip.amazonaws.com
sudo ss -tlnp ping -c 4 host curl -I http://host dig +short domain
nc -zv host 3306 traceroute host sudo hostnamectl set-hostname web01
B.5 Disk and EBS
df -hT du -sh /path lsblk -f sudo blkid
sudo file -s /dev/nvme1n1 sudo mkfs -t xfs /dev/nvme1n1
sudo mkdir /data && sudo mount /dev/nvme1n1 /data sudo umount /data
sudo growpart /dev/nvme0n1 1 sudo xfs_growfs -d / sudo resize2fs /dev/nvme0n1p1
sudo mount -a # test /etc/fstab (UUID=... /data xfs defaults,nofail 0 2)
B.6 Web servers
sudo nginx -t && sudo service nginx reload
sudo apachectl configtest && sudo service httpd reload # AL2023 / CentOS
sudo apache2ctl configtest && sudo service apache2 reload # Ubuntu
sudo a2ensite site.conf ; sudo a2dissite 000-default.conf ; sudo a2enmod rewrite proxy proxy_http
sudo restorecon -Rv /var/www ; sudo setsebool -P httpd_can_network_connect 1 # CentOS SELinux
sudo nginx -T | grep -E "listen|server_name|root" # what Nginx really loaded
sudo apachectl -S # Apache vhosts + default (Ubuntu: apache2ctl -S)
sudo ln -s /etc/nginx/sites-available/site /etc/nginx/sites-enabled/ # Ubuntu Nginx enable site
sudo semanage fcontext -a -t httpd_sys_content_t "/srv/site(/.*)?" ; sudo restorecon -Rv /srv/site
sudo semanage port -a -t http_port_t -p tcp 8081 # CentOS: allow a new web port
curl -H "Host: site1.example.com" http://localhost # test a vhost without DNS
| Setting | Nginx (server { }) |
Apache (<VirtualHost>) |
|---|---|---|
| Port | listen 80; |
<VirtualHost *:80> + Listen 80 |
| Site name | server_name example.com www.example.com; |
ServerName example.com + ServerAlias www.example.com |
| Folder | root /var/www/site; |
DocumentRoot /var/www/site + <Directory> |
| Index file | index index.html; |
DirectoryIndex index.html |
| No folder listing | autoindex off; |
Options -Indexes |
| Redirect | return 301 https://$host$request_uri; |
Redirect permanent / https://example.com/ |
| Hide version | server_tokens off; |
ServerTokens Prod + ServerSignature Off |
B.7 DNS and domains
dig example.com +short dig www.example.com +short dig NS example.com +short
dig @8.8.8.8 example.com +short dig MX example.com +short dig +trace example.com
nslookup example.com host example.com curl -I http://example.com
sudo yum install -y bind-utils # dig on AL2023/CentOS (Ubuntu: sudo apt install -y dnsutils)
ipconfig /flushdns # Windows resolvectl flush-caches # Linux laptop
sudo certbot --nginx -d example.com -d www.example.com -d blog.example.com
Typical records: A @ → Elastic IP · CNAME www → @ · A blog → Elastic IP · TTL 300–3600.
B.8 Databases
sudo mysql # admin shell (socket auth)
sudo mysql_secure_installation
mysql -u appuser -p -h 127.0.0.1 appdb
mysqldump -u appuser -p appdb > backup.sql mysql -u appuser -p appdb < backup.sql
mongosh # MongoDB shell: show dbs ; use db ; db.col.find()
B.9 App process managers
pm2 start app.js --name api ; pm2 status ; pm2 logs api ; pm2 reload api ; pm2 startup ; pm2 save
sudo systemctl daemon-reload ; sudo service flaskapp start ; sudo systemctl enable flaskapp ; journalctl -u flaskapp -f
gunicorn --workers 3 --bind 127.0.0.1:8000 wsgi:app
B.10 EC2 operations (AWS CLI, optional)
aws ec2 allocate-address --domain vpc
aws ec2 associate-address --instance-id i-xxx --allocation-id eipalloc-xxx --allow-reassociation
aws ec2 release-address --allocation-id eipalloc-xxx
aws ec2 create-image --instance-id i-xxx --name web-v1 # add --no-reboot only if you accept the risk
aws ec2 copy-image --source-region ap-south-1 --source-image-id ami-xxx --region ap-south-2 --name web-v1-dr
aws ec2 deregister-image --image-id ami-xxx ; aws ec2 delete-snapshot --snapshot-id snap-xxx
aws ec2 create-snapshot --volume-id vol-xxx --description "before-upgrade"
aws ec2 modify-instance-attribute --instance-id i-xxx --instance-type "{\"Value\": \"t3.small\"}" # instance stopped
nproc ; free -h ; lscpu # verify after resizing
B.11 SSH and file transfer
ssh -i key.pem ec2-user@IP ssh -i key.pem ubuntu@IP
scp -i key.pem file ec2-user@IP:~/ scp -i key.pem -r dir ubuntu@IP:~/
scp -i key.pem ec2-user@IP:/path/file . rsync -avz -e "ssh -i key.pem" dir/ ubuntu@IP:~/dir/
Ravindra Bagale's Tip
Don't copy placeholders like <pkg>, <svc>, IP, key.pem or i-xxx from the cheat sheet as they are – put in your own value first. And before running commands like delete or mkfs, check the device or path once.
Ravindra Bagale's Tip – मराठी
Cheat sheet मधले <pkg>, <svc>, IP, key.pem किंवा i-xxx सारखे placeholders तसेच copy करू नका – आधी तुमची value टाका. आणि delete किंवा mkfs सारखे commands चालवण्याआधी एक वेळा device किंवा path check करा.
Ravindra Bagale's Tip – हिंदी
Cheat sheet के <pkg>, <svc>, IP, key.pem या i-xxx जैसे placeholders वैसे ही copy मत करो – पहले अपनी value डालो. और delete या mkfs जैसे commands चलाने से पहले एक बार device या path check करो.
Practice Tasks
Practice checks run in your browser. They check the answer for this exercise; they do not create resources or connect to your AWS account.
About this scenarioAhmednagar Sugar Co-op is a sugar co-operative business in Ahilyanagar. Balasaheb Pawar looks after its IT and cloud work. They count money in INR and run their AWS resources in the ap-south-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.
0 / 12
Easy List your EC2 instances
Before changing anything, see what is running and in which state.
Show details of all EC2 instances of Ahmednagar Sugar Co-op in ap-south-1.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy List files in a bucket folder
Check that the upload worked and see file sizes.
List the objects under s3://nagarsugar-invoices-2026/reports/.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy Create a bucket
A bucket is the top-level container for your files in S3.
Create the bucket nagarsugar-invoices-2026 in ap-south-1.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy Read a config file
Reading a file on the screen is the quickest way to check its settings.
Print the whole file /etc/nagarsugar/app.conf on the screen.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Easy List all files with details
Hidden files (like .env) and file sizes or owners only show with the right options.
Show a long listing of every file, including hidden ones, in /var/www/nagarsugar.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Easy Create an empty file
Some apps need a file to exist before they can write to it.
Create an empty file named orders-inr.csv in the current folder.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Easy List Availability Zones
Spreading servers across AZs keeps you up if one data centre fails.
List the Availability Zones in ap-south-1.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy List all Regions
Choose a Region close to your users for low delay and the right laws.
List the AWS Regions available to your account.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy Create nested folders in one go
Projects need a clean folder tree. Making all levels in one command saves time and avoids errors.
Create the folder /srv/nagarsugar/reports/2026 for Ahmednagar Sugar Co-op. The parent folders do not exist yet, so create them too.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Easy Show where you are
Before you copy or delete anything, you must know which folder you are in.
Balasaheb Pawar logged in to the Ahmednagar Sugar Co-op server and is not sure which folder the terminal is in. Print the current folder path.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Easy Check who you are logged in as
Always confirm the account and identity before running changes.
Show the account ID and ARN of the identity your CLI is using.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Create an AMI from a server
An AMI is a full server image. Launch identical copies from it any time.
Create an AMI named nagarsugar-web-v1 from instance i-05c252ad5d1311a2b.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.