← Back to Linux Notes
ES · EN

🐧 Linux Basics for DevOps (from zero)

If you’re new to Linux: here’s a minimal workflow to SSH into a server (e.g., EC2), understand where you are, read files, and check host health safely.

Beginner
Level
12–18 min
Read
Servers / EC2
Context
Main idea: in DevOps you don’t need “500 commands”. You need a survival kit to: get oriented, read logs, validate resources, and troubleshoot fast.

🧠 Minimum concepts (so you don’t get lost)

🎯 First-minute checklist (right after connecting)

Right after SSH, ask:

whoami          # shows the current user (e.g., ubuntu, ec2-user)
hostname        # server hostname (helps you confirm which machine you are on)
pwd             # "print working directory": current directory
uname -a        # system info (kernel, architecture) for quick context
uptime          # how long it has been running + load average (high load can mean trouble)
date            # current date/time (useful when correlating logs)

🧭 Basic navigation (moving around)

Think of this as a file explorer, but using commands.

pwd             # where am I (current location)
ls              # list files/folders here
ls -lah         # detailed listing: permissions, owner, size, date (very common on servers)

cd /var/log     # cd = change directory: move to /var/log (typical log folder)
cd ..           # go one level up (from /var/log -> /var)
cd ~            # go to your home directory
cd              # with no arguments = also goes to home

clear           # clears the screen (visual only)
Quick tip: if you get lost, always run:
pwd
ls -lah

📄 Read files (without editing)

In DevOps you often read logs and configs. Learn to read safely first.

cat file.txt            # prints the whole file (best for small files)
less app.log             # interactive viewer (best for large logs)
                          # inside less:
                          # - press 'q' to quit
                          # - use arrows / PageUp / PageDown to move
                          # - type /ERROR then Enter to search for "ERROR"

head -n 50 app.log       # first 50 lines
tail -n 50 app.log       # last 50 lines

tail -f app.log          # follow logs live (updates as new lines appear)
                          # Ctrl + C to stop

🗂️ Create, copy, move and delete (safely)

This is where beginners often break things. Let’s do it carefully.

mkdir folder             # create a folder
mkdir -p a/b/c            # create nested folders even if parents don't exist (-p)

touch file.txt            # create an empty file (or update timestamp if it exists)

cp source.txt copy.txt    # copy a file
cp -r folder1 folder2     # copy a whole folder (-r = recursive)

mv old.txt new.txt        # rename a file
mv file.txt /tmp/         # move a file to /tmp (temporary folder)

rm file.txt               # delete a file (no recycle bin)
rm -r folder/             # delete a folder and contents (careful)
rm -rf folder/            # force delete without prompts (VERY careful)
DevOps rule before deleting: confirm location and target.
pwd
ls -lah

🔎 Find things fast

When you don’t know where a file is, or you need to search logs:

find . -name "file*.log"        # search from current directory (.)
                               # matches names like file123.log

grep -R "ERROR" .               # search the word ERROR in all files recursively
grep -n "ERROR" app.log         # search in one file and show line numbers (-n)

📌 Quick host health checks

These tell you if the server is healthy or near failure.

df -h                 # disk space (100% disk can break services)
free -h               # memory (low memory can cause swapping and slowness)
ps aux | head         # processes (head shows only the first few lines)

top                   # real-time monitoring (CPU/memory/processes)
                      # press 'q' to quit

ip a                  # network interfaces + IP addresses
ss -tulpen            # listening ports + owning processes (great for troubleshooting)

☁️ AWS / DevOps usage (real scenarios)

✅ Takeaways (what to remember)