// hands-on lab
Test
# 10 Linux Commands Every Cloud Engineer Should Know
If you work in **cloud engineering, DevOps, or SRE**, Linux is not optional—it is one of the most important skills you can develop.
Whether you're troubleshooting an EC2 instance, checking why an application is slow, investigating logs, managing processes, or debugging a production issue, you'll often find yourself inside a Linux terminal.
The good news? You don't need to memorize hundreds of commands.
Here are **10 Linux commands every cloud engineer should know**, along with practical examples and situations where you'll actually use them.
--- [Detailed Markdown guide](https://ia.net/writer/support/basics/markdown-guide) ## 1. `ls` — List Files and Directories
The `ls` command is one of the first commands you'll use on a Linux server.
It shows the files and directories in your current location.
```bash ls ```
For more detailed information:
```bash ls -l ```
To include hidden files:
```bash ls -la ```
### Useful example
```bash ls -lah /var/log ```
This displays files in `/var/log` with:
* Human-readable file sizes * Permissions * Owners * Modification dates * Hidden files
### Cloud use case
When troubleshooting a server, you may need to quickly inspect configuration files, application directories, or logs.
---
## 2. `cd` — Navigate Between Directories
`cd` stands for **change directory**.
```bash cd /var/log ```
Go back to the previous directory:
```bash cd .. ```
Go directly to your home directory:
```bash cd ~ ```
### Useful example
```bash cd /var/log/nginx ls -lah ```
This lets you move into an application's log directory and inspect its files.
### Cloud use case
When you're connected to an EC2 or other Linux server, you'll constantly move between directories while troubleshooting applications and services.
---
## 3. `pwd` — Find Your Current Location
`pwd` means **print working directory**.
```bash pwd ```
Example output:
```text /home/ec2-user ```
This is particularly useful when you're working with long directory structures and aren't sure where you currently are.
### Cloud use case
Imagine you're running a deployment script and suddenly realize you're in the wrong directory.
Instead of guessing:
```bash pwd ```
Know exactly where you are.
---
## 4. `grep` — Search Through Text
`grep` is incredibly useful for searching logs and configuration files.
For example:
```bash grep "ERROR" application.log ```
This prints every line containing `ERROR`.
You can also search recursively:
```bash grep -r "database" /var/log/ ```
Ignore case:
```bash grep -i "error" application.log ```
### Cloud use case
Suppose your application is failing in production.
Instead of manually reading thousands of log lines:
```bash grep "ERROR" application.log ```
You can immediately focus on the relevant entries.
A common combination is:
```bash cat application.log | grep "ERROR" ```
Although for simple searches, directly using `grep` on the file is usually cleaner:
```bash grep "ERROR" application.log ```
---
## 5. `tail` — Watch Logs in Real Time
If you're troubleshooting a running application, `tail` is your best friend.
To see the last 10 lines:
```bash tail application.log ```
To continuously watch new log entries:
```bash tail -f application.log ```
Now, whenever your application writes a new log entry, you'll see it immediately.
### Example
```bash tail -f /var/log/nginx/error.log ```
You can then reproduce an issue and watch the error appear in real time.
### Cloud use case
This is extremely useful during:
* Deployments * Incident troubleshooting * Application debugging * API failures * Nginx troubleshooting * Database connectivity issues
---
## 6. `ps` — Check Running Processes
The `ps` command lets you see processes currently running on your system.
A common command is:
```bash ps aux ```
You can combine it with `grep`:
```bash ps aux | grep nginx ```
This helps determine whether a particular application or service is running.
### Example
```bash ps aux | grep java ```
You might see:
```text ec2-user 1234 2.1 8.4 ... java -jar application.jar ```
The number `1234` is the **process ID (PID)**.
### Cloud use case
If your application appears to be down, checking the running processes is often one of the first troubleshooting steps.
---
## 7. `top` — Monitor System Resources
`top` provides a live view of system resource usage.
Run:
```bash top ```
You'll see information about:
* CPU usage * Memory usage * Running processes * Load average * Process IDs
If a server suddenly becomes slow, `top` can quickly tell you whether a process is consuming excessive CPU or memory.
### Cloud use case
Imagine your EC2 instance is experiencing high CPU utilization.
Instead of immediately restarting the server, run:
```bash top ```
You may discover that a single process is consuming most of the CPU.
That's much better information to have before taking action.
---
## 8. `df` — Check Disk Space
`df` shows available disk space.
Use:
```bash df -h ```
The `-h` option makes the output human-readable.
Example:
```text Filesystem Size Used Avail Use% /dev/xvda1 20G 18G 2.0G 90% ```
A disk that's almost full can cause serious problems.
For example:
* Applications may stop writing logs * Databases may fail * Deployments may fail * Temporary files may not be created
### Cloud use case
If an application suddenly starts failing, always consider checking disk space:
```bash df -h ```
---
## 9. `du` — Find What Is Using Your Disk
`df` tells you **how much** disk space is being used.
`du` helps you find **where** that space is being used.
For example:
```bash du -sh * ```
To investigate `/var`:
```bash du -sh /var/* ```
You might discover:
```text 12G /var/log 3G /var/lib 500M /var/cache ```
Now you know where the disk usage is coming from.
### Cloud use case
A classic production incident looks like this:
```bash df -h ```
You discover the disk is 95% full.
Then:
```bash du -sh /var/* ```
You discover that old application logs are consuming most of the disk.
You've now gone from **"the server is running out of space"** to **"I know exactly why."**
---
## 10. `curl` — Test APIs and Connectivity
`curl` is one of the most useful networking tools available on Linux.
Test whether a website is reachable:
```bash curl https://example.com ```
Check only the response headers:
```bash curl -I https://example.com ```
Test an API:
```bash curl https://api.example.com/health ```
Send a GET request with a header:
```bash curl -H "Authorization: Bearer TOKEN" \ https://api.example.com/users ```
### Cloud use case
Suppose your application says:
> "The API is unreachable."
Instead of immediately blaming the network, test it directly from the server:
```bash curl https://api.example.com/health ```
You can quickly determine whether the server can reach the endpoint and inspect the response.
---
# Bonus: Combine Commands
The real power of Linux comes from **combining commands**.
For example:
```bash ps aux | grep java ```
Find Java processes.
Or:
```bash df -h | grep "/" ```
Check the filesystem containing the root directory.
Or:
```bash grep "ERROR" application.log | tail ```
Find errors and display the latest matching entries.
This is where Linux becomes incredibly powerful.
You can take the output from one command and send it into another using the **pipe (`|`)** operator.
---
# A Practical Cloud Troubleshooting Workflow
Imagine you receive an alert:
> **Production server is slow.**
Instead of randomly restarting things, you can investigate systematically.
### Step 1: Check CPU and memory
```bash top ```
### Step 2: Check disk space
```bash df -h ```
### Step 3: Find large directories
```bash du -sh /var/* ```
### Step 4: Check application processes
```bash ps aux | grep java ```
### Step 5: Check recent application logs
```bash tail -100 application.log ```
### Step 6: Search for errors
```bash grep "ERROR" application.log ```
### Step 7: Test external connectivity
```bash curl https://api.example.com/health ```
Now you're troubleshooting based on **evidence**, rather than guessing.
---
# Final Cheat Sheet
| Command | What It Does | Common Cloud Use | | ------- | ----------------------- | ---------------------- | | `ls` | Lists files | Inspect directories | | `cd` | Changes directory | Navigate servers | | `pwd` | Shows current directory | Confirm location | | `grep` | Searches text | Find log errors | | `tail` | Shows end of files | Monitor logs | | `ps` | Shows processes | Check applications | | `top` | Monitors resources | Investigate high CPU | | `df` | Shows disk usage | Check free space | | `du` | Shows directory sizes | Find large files | | `curl` | Makes HTTP requests | Test APIs/connectivity |
---
# Conclusion
You don't need to know every Linux command to become a good cloud engineer.
But you should be comfortable with the commands that help you **navigate, inspect, troubleshoot, and understand a server**.
Start with these 10:
```text ls cd pwd grep tail ps top df du curl ```
Then practice combining them with pipes, filters, and options.
Because in cloud engineering, the terminal isn't just where you type commands.
**It's where you figure out what actually went wrong.** 🐧☁️
No checklist — explore the sandbox, then mark the step complete.
Sign in to save checklist progress.
Click Start sandbox for an in-browser Linux environment.
No Docker on the server — the sandbox runs in your browser (or an embedded lab host).