Part ofLinux Foundations·Step 1 of 3
General

Linux Commands for Beginners: Your First 30 Commands

Beginner40 min to complete12 min readJune 1, 2026Updated August 19, 2026

Quick answer

Learn the 30 Linux commands every engineer uses daily. Covers filesystem navigation, file manipulation, search, and getting help — no prior terminal experience needed.

beginner · 40 min

Before you begin

  • A Linux terminal, macOS Terminal, or WSL on Windows
  • No prior command-line experience needed
Linux
Bash
CLI
Shell
Beginner

Linux Commands for Beginners: Your First 30 Commands

Every engineer who works with servers, containers, or cloud infrastructure spends a significant portion of their day in a terminal. Kubernetes, CI/CD pipelines, SSH sessions, Docker — all of it assumes you're comfortable at the command line. This tutorial gets you there from scratch.

By the end you'll have 30 commands memorised, understand how the Linux filesystem works, and be able to find, create, move, and inspect files without touching a mouse.


Why the Terminal?

Three reasons the terminal beats a GUI for engineering work:

  1. Speed — A three-second CLI command replaces five minutes of clicking through a file manager.
  2. Scripting — You can chain commands together and automate repetitive tasks.
  3. Remote access — Servers don't have GUIs. SSH gives you a terminal and nothing else.

How Linux Organises Files

Linux uses a single tree rooted at / (called the root). Everything — disks, devices, processes — is a file somewhere under /.

/
├── bin/       # Essential system binaries (ls, cp, mv)
├── etc/       # Configuration files
├── home/      # User home directories (/home/ajeet)
├── var/       # Variable data — logs, caches
├── tmp/       # Temporary files (cleared on reboot)
├── usr/       # User programs and libraries
└── proc/      # Virtual filesystem — running kernel info

Your home directory is ~. It's shorthand for /home/yourusername (or /root if you're the root user).


1. Where Am I? — pwd

bash
pwd

print working directory. Tells you where you are in the tree. Always run this if you're disoriented.

/home/ajeet/projects

2. What's Here? — ls

bash
ls              # List files in the current directory
ls /etc         # List files in /etc
ls -l           # Long format: permissions, owner, size, date
ls -la          # Long format + hidden files (dotfiles)
ls -lh          # Human-readable file sizes (KB, MB)

The -l output looks like this:

-rw-r--r--  1 ajeet  ajeet  4096 Jun  1 10:00 config.yaml
drwxr-xr-x  3 ajeet  ajeet    96 Jun  1 09:00 scripts/

The first character: - = file, d = directory, l = symlink.


3. Move Around — cd

bash
cd /etc           # Go to /etc (absolute path)
cd projects       # Go into the projects/ subfolder (relative)
cd ..             # Go up one level
cd ../..          # Go up two levels
cd ~              # Go home
cd -              # Go back to previous directory

Absolute paths start with /. Relative paths don't.


4. Create Directories — mkdir

bash
mkdir logs                    # Create logs/
mkdir -p app/config/secrets   # Create nested directories in one shot

-p means "create parents as needed" — without it, mkdir app/config/secrets fails if app/ doesn't exist.


5. Create Empty Files — touch

bash
touch app.log
touch notes.txt config.yaml

touch creates an empty file if it doesn't exist. It also updates the modification timestamp if the file already exists — useful for triggering watches.


6. Copy Files and Directories — cp

bash
cp config.yaml config.yaml.bak      # Copy a file
cp -r src/ src-backup/              # Copy a directory recursively

Always make a backup before editing config files: cp nginx.conf nginx.conf.bak.


7. Move and Rename — mv

bash
mv old-name.txt new-name.txt        # Rename
mv config.yaml /etc/app/            # Move to a different directory
mv *.log /var/logs/archive/         # Move all .log files

mv is how you rename files. Linux does have a rename command but it's for batch renames with regex patterns — mv is simpler for single files.


8. Remove Files and Directories — rm

bash
rm file.txt               # Delete a file
rm -r old-project/        # Delete a directory and everything inside
rm -rf dist/              # Force delete without prompts (use with care)

Warning: Linux has no Recycle Bin. rm is permanent. Double-check paths before running rm -rf.


9. View File Contents — cat, less, head, tail

bash
cat config.yaml           # Print entire file to terminal
less application.log      # Paginated view (q to quit, / to search)
head -20 server.log       # First 20 lines
tail -50 server.log       # Last 50 lines
tail -f server.log        # Follow live updates (great for log watching)

Use less for large files — cat on a 500MB log will flood your terminal.


10. Search Inside Files — grep

bash
grep "ERROR" app.log                    # Lines containing ERROR
grep -i "error" app.log                 # Case-insensitive
grep -r "database_url" ./config/        # Search recursively in a directory
grep -n "timeout" server.conf           # Show line numbers
grep -v "DEBUG" app.log                 # Lines that do NOT contain DEBUG

grep is one of the most used commands in engineering work. Learn -r, -i, -n, and -v early.


11. Find Files — find

bash
find . -name "*.yaml"                   # All YAML files under current dir
find /etc -name "nginx.conf"            # Find nginx.conf in /etc
find . -type d -name "node_modules"     # Find directories named node_modules
find . -mtime -1                        # Files modified in the last 24 hours
find . -size +100M                      # Files larger than 100MB

find searches the actual filesystem — unlike locate which uses a cached index. It's slower but always current.


12. Get Help — man and --help

bash
man ls              # Full manual page for ls
man grep            # Full manual page for grep
ls --help           # Quick usage summary
grep --help         # Quick usage summary

man opens a paginated reader. Press q to quit, / to search, n to jump to the next match.

If the man page is overwhelming, tldr (install with brew install tldr or apt install tldr) gives practical examples:

bash
tldr tar            # Shows the 5 most common tar uses
tldr find

13. Who Am I and Where? — whoami, hostname, uname, date

bash
whoami              # Your current username
hostname            # The machine's name
uname -a            # Kernel name, version, architecture
date                # Current date and time

Useful when you're SSH'd into multiple servers and need to confirm which one you're on.


Quick Reference: All 30 Commands

CommandWhat it does
pwdPrint working directory
lsList files
ls -laList all files with details
cd <dir>Change directory
cd ..Go up one level
cd ~Go to home directory
mkdir <dir>Create directory
mkdir -p <path>Create nested directories
touch <file>Create empty file
cp <src> <dst>Copy file
cp -r <src> <dst>Copy directory
mv <src> <dst>Move or rename
rm <file>Delete file
rm -r <dir>Delete directory
cat <file>Print file contents
less <file>Paginated file view
head -n <num> <file>First n lines
tail -n <num> <file>Last n lines
tail -f <file>Follow live updates
grep <pattern> <file>Search inside file
grep -r <pattern> <dir>Search recursively
grep -iCase-insensitive search
grep -vInvert match
find . -name <pattern>Find files by name
find . -type dFind directories
man <cmd>Full manual
<cmd> --helpQuick help
whoamiCurrent username
hostnameMachine name
uname -aKernel and architecture

Common Mistakes to Avoid

Mistake 1: rm -rf / or rm -rf ./* Always double-check what * expands to. Run ls * before rm *.

Mistake 2: Paths without quotes rm my file.txt deletes two files: my and file.txt. Use rm "my file.txt".

Mistake 3: Editing the original instead of a backup Before editing any config: cp file.conf file.conf.bak. Takes two seconds.


Frequently Asked Questions

What is the difference between an absolute and a relative path?

An absolute path starts at the root and means the same thing from anywhere. A relative path is interpreted from your current directory, so the same command behaves differently depending on where you run it. Use absolute paths in scripts and cron jobs, where the working directory is rarely what you assume.

Why does my terminal say permission denied?

Either the file's permissions exclude you, or a directory in its path does not permit traversal. Reaching a file requires execute permission on every directory leading to it, so the block is often a parent rather than the file itself. Check the whole path before changing the file's mode.

What does the tilde mean in a path?

It expands to your home directory, so ~/notes is the same as the full path to your home plus notes. It is expanded by the shell rather than the command, which is why it sometimes fails inside quotes or in a configuration file that no shell reads.

How do I safely delete something?

Look before you delete — list the target first, then remove it. Recursive deletion has no undo and no recycle bin. Be especially careful with wildcards and with a trailing slash on a variable that might be empty, which is the classic way a script deletes far more than intended.

What's Next

These 30 commands cover daily navigation and file work. The natural next steps:

This tutorial covers Stage 1 of the Platform Engineering Roadmap — Linux & Systems Fundamentals is the foundation every other skill in that roadmap builds on.

Keep the Linux Commands Cheat Sheet (DevOps) open while you work — it condenses the commands from this series into an incident-day quick reference.

Next in Linux Foundations

Linux Commands for Intermediate Users: Processes, Pipes & Networking

Continue

We built Podscape to simplify Kubernetes workflows like this — logs, events, and cluster state in one interface, without switching tools.

Struggling with this in production?

We help teams fix these exact issues. Our engineers have deployed these patterns across production environments at scale.