Linux and Networking Essentials
The Linux commands, permissions, services and SSH skills plus the IP, port, DNS and CIDR knowledge every cloud engineer uses daily.
Video chapters
- 00:00Intro
- 00:37Why Linux matters in the cloud
- 01:30Moving around and reading files
- 02:30Users, sudo and permissions
- 03:38Software, services and resources
- 04:54SSH keys: how you log in to servers
- 05:57Networking: the five ideas you need
- 07:06CIDR and subnets, without the fear
- 08:21What happens when you open a website
- 09:02Your network troubleshooting toolkit
- 10:08Your foundation is ready
Almost every cloud server runs Linux, and almost every cloud problem is, at some level, a networking problem. This episode gives you the minimum solid foundation in both, so the AWS episodes that follow make sense.
What you need
- A Linux terminal: Ubuntu in WSL on Windows, the macOS Terminal, or any Linux machine
- Optional: a cheap VPS to practice SSH
Why Linux matters in the cloud
Why Linux first?
Because it runs the cloud. The vast majority of cloud servers, and almost all containers, run Linux.
Those servers have no desktop. There's no mouse and no windows. You manage them through a terminal, connected over SSH.
And that's actually a superpower. Anything you can type, you can put in a script, and run again on one server or on a hundred. That's the start of automation.
You'll mostly meet two distributions. Ubuntu, which is popular everywhere, and Amazon Linux, which AWS maintains. The commands are almost the same. The main difference is the package manager.
The goal for today is to be comfortable, not to be an expert. Expertise comes from using these commands again and again, and you'll use them in every episode of this course.
Quick reference
- It runs the cloud: Most cloud servers and containers are Linux
- No desktop: You manage servers through a terminal, over SSH
- Text = automation: Anything you type, you can script and repeat
- Two common distros: Ubuntu, and Amazon Linux on AWS
- Goal for today: Comfortable, not expert. That comes with practice
Moving around and reading files
Let's start with moving around. pwd prints the folder you're in. It stands for print working directory.
ls lists the files. With dash l a, you also see hidden files, their sizes, their owners, and their permissions.
cd changes folder. slash var slash log is where most Linux services write their logs, and you'll visit it often.
mkdir creates folders. Dash p creates the whole path at once, without complaining if part of it already exists.
cp copies, mv moves or renames, and rm deletes.
To read files, cat prints a whole file, less lets you scroll through a long one, and tail dash f follows a log live, as new lines arrive. When something breaks on a server, tail dash f on the right log file is very often your first move.
One warning. rm has no recycle bin. A deleted file is gone, so read every rm command twice before you press enter.
Quick reference
pwd # where am I? ls -la # list files, including hidden ones cd /var/log # go to a folder mkdir -p ~/app/config # create folders cp a.txt b.txt · mv old new · rm file cat file · less file · tail -f app.log
Users, sudo and permissions
Next, users and permissions. This is where many server problems hide.
Linux has a special user called root, who can do anything. That's exactly why you should avoid working as root all the time. One typo can damage the whole system.
Instead, you work as a normal user, and put sudo in front of a single command when it needs admin rights, like installing software.
Every file has permissions for three groups of people: the owner, the group, and everyone else. And for each, three rights: read, write, and execute. When you see r w x in a listing, that's what it means.
You change permissions with chmod. The numbers are a shortcut: seven means read, write and execute, five means read and execute, and zero means nothing. Six hundred, which means only the owner can read and write, is what you use for secret files like private keys.
And chown changes who owns a file. A very common bug is a web server that can't read files because they belong to the wrong user. Now you know where to look.
Quick reference
- root: The all-powerful user. Avoid working as root
- sudo: Run one command with admin rights
- chmod: Change permissions: chmod 600 secret.txt
- chown: Change owner: chown ubuntu:devs file
ls -l deploy.sh
-rwxr-x--- ubuntu devs deploy.sh owner = rwx group = r-x others = --- r = read w = write x = execute chmod 750 deploy.sh 7 = rwx 5 = r-x 0 = ---
Software, services and resources
Now, installing and running software. On Ubuntu, you update the package list with apt update, then install with apt install. Here we install nginx, a popular web server.
On Amazon Linux, the package manager is dnf instead, but the idea is identical.
Long running programs, like web servers and databases, run as services, managed by systemd. systemctl status shows whether a service is running. Restart restarts it, and enable makes it start automatically when the server boots.
When a service fails, read its logs with journalctl dash u, followed by the service name. Dash n fifty shows the last fifty lines.
To check the server's health, df dash h shows disk space, free dash h shows memory, and top shows what's using the C P U, live.
And ps aux, piped into grep, finds a specific process. That pipe symbol sends one command's output into another, and you'll use it constantly.
Here's a lesson from real incidents. A full disk, or a server running out of memory, causes far more outages than you'd expect. Check these two first when a server misbehaves.
Quick reference
sudo apt update && sudo apt install -y nginx # Ubuntu sudo dnf install -y nginx # Amazon Linux sudo systemctl status nginx · restart · enable sudo journalctl -u nginx -n 50 # service logs df -h · free -h · top # disk, memory, CPU ps aux | grep nginx # find a process
SSH keys: how you log in to servers
Next, SSH keys, because that's how you'll log in to every cloud server.
Instead of a password, you use a key pair, created on your own computer.
The public key goes on the server. It's safe to share, like a lock.
The private key stays on your computer, and never leaves it. It's the only thing that opens that lock.
You create a pair with ssh keygen. The modern type, E D two five five one nine, is short and secure. On AWS, you'll often download a private key file ending in dot p e m. Before using it, set its permissions to four hundred, so only you can read it, or SSH will refuse to use it. Then connect with ssh dash i, the key file, the user name, and the server's address.
On the server, the allowed public keys are listed in a file called authorized keys, in the user's dot ssh folder.
And one serious warning. If you lose the private key, you can't use it to log in again. Store it carefully, and back it up somewhere safe.
Quick reference
- Create a key pair on YOUR computer
- Public key → goes on the server
- Private key → never leaves your computer
- Server keeps allowed keys in ~/.ssh/authorized_keys
- Lost the private key? You can't log in with it again
terminal
$ ssh-keygen -t ed25519 -C "laptop" ~/.ssh/id_ed25519 (private) ~/.ssh/id_ed25519.pub (public) $ chmod 400 my-key.pem $ ssh -i my-key.pem ubuntu@203.0.113.10
Networking: the five ideas you need
Now networking. Five ideas cover most of what you need.
An IP address is a machine's address on a network. Public addresses are reachable from the internet. Private addresses only work inside a network, like your home Wi-Fi, or a private network in AWS.
A port says which program on that machine you want to talk to. One server can run SSH on port twenty two and a website on port four four three at the same time. Here are the ports you'll see every day. It's worth memorizing them.
TCP and UDP are the two main ways data travels. TCP is a reliable connection, used by the web, SSH and databases. UDP is faster, with no delivery guarantee, used for things like video calls and DNS.
DNS is the internet's phone book. It turns a name like example dot com into an IP address.
And a firewall decides which addresses may reach which ports. In AWS, the main firewall is called a security group, and you'll configure one in episode four.
Quick reference
- IP address: A machine's address. Public, or private inside a network
- Port: Which program on that machine: 22, 80, 443…
- TCP / UDP: Reliable connection vs fast, no guarantees
- DNS: Turns names into IP addresses
- Firewall: Decides which IPs may reach which ports
ports you'll see every day
22 SSH 80 HTTP 443 HTTPS 3306 MySQL 5432 PostgreSQL 6379 Redis IP:port → 203.0.113.10:443
CIDR and subnets, without the fear
CIDR notation looks scary, but you only need the basics. Something like ten dot zero dot zero dot zero slash sixteen describes a block of IP addresses.
The number after the slash says how many bits are fixed. The bigger that number, the smaller the block. Slash thirty two is exactly one address. Slash twenty four is two hundred and fifty six addresses. Slash sixteen is over sixty five thousand.
Private networks use three reserved ranges: addresses starting with ten, with one seven two sixteen to thirty one, and with one nine two one six eight. Your AWS networks will use these.
And zero dot zero dot zero dot zero slash zero means every address on the internet. When you see it in a firewall rule, it means open to the world. That's fine for a website on port four four three, and dangerous for a database or for SSH.
Keep this cheat sheet handy. One AWS detail: in every subnet, AWS reserves five addresses for itself, so a slash twenty four gives you two hundred and fifty one usable addresses, not two hundred and fifty six.
Quick reference
- 10.0.0.0/16 = a block of IP addresses
- The number after / = fixed bits. Bigger = smaller block
- Private ranges: 10.x · 172.16–31.x · 192.168.x
- 0.0.0.0/0 = every address on the internet
CIDR CHEAT SHEET
/32 1 address one exact IP /24 256 addresses a small subnet /20 4,096 addresses /16 65,536 addresses a whole VPC /0 everything the internet AWS reserves 5 addresses per subnet
What happens when you open a website
Let's put it together, and follow one request.
You type a website's name into your browser.
DNS turns that name into an IP address.
Your browser opens a TCP connection across the internet, to that IP address, on port four four three.
A firewall checks whether port four four three is allowed from your address.
If it is, the connection reaches the web server, which must be running, and listening on that port.
And the web server passes the request to the application, which builds the page. When a website doesn't load, the problem is at one of these six steps. Troubleshooting is simply checking them, in order.
Quick reference
Browser → DNS → Internet → Firewall → Web server → App
Your network troubleshooting toolkit
And here's the toolkit to check each step.
dig asks DNS for a name's IP address. If it returns the wrong address, or nothing at all, stop there. It's a DNS problem.
ping checks whether the machine answers at all.
nc dash z v checks whether a specific port is open. This one is incredibly useful, because it tells you if the firewall lets you through.
On the server itself, ss dash t u l p n lists every program that's listening, and on which port. If nginx isn't in that list, the service isn't running.
And curl dash i shows the headers the server sends back, like a two hundred, a four oh four, or a five oh two error from a broken app.
One caution. Many cloud firewalls block ping by default, so no ping reply doesn't always mean the server is down. Use the port check to be sure.
Remember the method: check the steps in order, and the first one that fails is where your problem is. This simple habit will save you hours in every job you ever have.
Quick reference
dig example.com +short # 1. does DNS give the right IP? ping 203.0.113.10 # 2. is the machine reachable? nc -zv 203.0.113.10 443 # 3. is the port open? sudo ss -tulpn # 4. on the server: who listens? curl -I https://example.com # 5. what does the server answer?
Your foundation is ready
Let's recap. You can move around and read logs. You understand users, sudo and permissions.
You can install software and manage services, and check disk, memory and C P U. You know how SSH keys work, and the networking basics: IP addresses, ports, DNS and CIDR.
And you have a five step method for troubleshooting any connection. In the next episode, we finally open AWS, and create your account the safe way: protecting the root user, setting up multi-factor authentication, creating proper users with I A M, and adding billing alerts before we build anything. The notes, with every command from today, are linked in the description.
Quick reference
- Files + logs: ls, cd, less, tail -f, /var/log
- Permissions: sudo, chmod 600 / 400, chown
- Services: apt / dnf, systemctl, journalctl, df, free
- SSH + networking: Key pairs, IPs, ports, DNS, CIDR
- Troubleshooting: dig → ping → nc → ss → curl
Practice
- Install nginx, check it with systemctl, and read its log with journalctl.
- Create an SSH key pair and log in to a server with it.
- Work out how many addresses are in a /20 and a /26.
Next episode
Episode 3: your AWS account, the safe way: root user, MFA, IAM, and billing alerts.
Key takeaways
- Most cloud servers run Linux, and you manage them in a terminal over SSH
- Use sudo for admin commands, and chmod 400 or 600 for keys and secrets
- IP addresses, ports, DNS and firewalls decide whether traffic reaches your app
- Troubleshoot in order: dig → ping → nc → ss → curl. The first step that fails is your problem