Linux Command Line for Cloud Servers

Get comfortable on a Linux shell: files, permissions, processes, packages, services and logs, because most cloud servers and containers run Linux.

Beginner · about 12 hours · difficulty 2/5

Most EC2 instances, containers and CI runners run Linux. You will SSH into machines, read logs and debug services from a terminal, so the shell must feel natural.

Daily commands

  • Navigation and files: ls, cd, pwd, cp, mv, rm, mkdir, find.
  • Reading files: cat, less, head, tail -f (follow a log live).
  • Searching: grep, and pipes (|) to chain commands together.
  • Disk and memory: df -h, du -sh, free -m, top or htop.

Users and permissions

Every file has an owner, a group and rwx bits. Learn chmod, chown and sudo. On EC2 you log in as ec2-user (Amazon Linux) or ubuntu (Ubuntu), not root, and use sudo for admin work.

Packages and services

  • Package managers: dnf on Amazon Linux 2023, apt on Ubuntu.
  • systemd runs services: systemctl status nginx, systemctl restart nginx, journalctl -u nginx.

Networking from the shell

  • ss -tulpn shows which ports are listening.
  • curl -v tests an HTTP endpoint and shows headers.
  • dig or nslookup checks DNS.
  • ping and traceroute check reachability (note that many cloud firewalls block ICMP).

Pitfalls

  • Running everything as root.
  • Editing config files without a backup copy.
  • Using chmod 777 to "fix" a permission error.

You are ready to move on when you can install nginx on a fresh Linux VM, start it with systemd, confirm it listens on port 80 and read its logs.

Key concepts

  • Filesystem navigation
  • Pipes, grep and redirection
  • Users, groups and permissions
  • sudo and the root user
  • dnf and apt package managers
  • systemd and journalctl
  • Processes: ps, top, kill
  • Shell networking tools: ss, curl, dig, traceroute
  • Bash scripting basics

Mini project

Install Ubuntu in WSL or a free VM (VirtualBox) on your laptop. Install nginx, serve a custom index.html, write a Bash script that checks whether nginx is running and restarts it if not, and run it from cron every minute. Everything runs locally, so there is no cloud cost.

Check yourself

Your web app on a Linux server is not responding. Which three commands would you run first, and what would each tell you?

Free resources