Skip to main content

Linux Fundamentals

Master the essential Linux commands and file system navigation that every developer needs. Linux File System

The Linux File System

Everything in Linux starts from the root directory /. Unlike Windows (where you might have C:, D:, E:\ as separate drive letters), Linux has a single tree. Everything — every file, device, process, and even hardware interface — hangs off that one root. Plug in a USB drive? It gets mounted somewhere in this tree. Check CPU info? It is a file in this tree.

Key Directories



File Operations

Creating Files and Directories

Copying and Moving

Deleting

There is no recycle bin in Linux. When rm deletes a file, it is gone. There is no undo, no trash folder, no recovery tool (without specialized forensic software). Be especially careful with rm -rf combined with variables — rm -rf $DIR/ where $DIR is accidentally empty expands to rm -rf /, which attempts to delete your entire filesystem. Always double-check before pressing Enter.

Viewing File Contents


Finding Files

Using find

Using locate

When to use find vs locate: Use find when you need real-time, accurate results (it scans the actual filesystem). Use locate when speed matters and slightly stale results are acceptable (it searches a pre-built index). On a server with millions of files, find / can take minutes while locate returns instantly.

Using grep to search inside files


File Permissions Preview

We’ll cover permissions in detail in the next module.

Practical Examples

Example 1: Organizing Files

Example 2: Finding Large Files

Example 3: Searching Logs


Useful Shortcuts


Wildcards and Patterns


Redirection and Pipes

Redirection and pipes are what make the Linux command line so powerful. Each command has three standard streams: stdin (input, fd 0), stdout (output, fd 1), and stderr (errors, fd 2). Redirection lets you reroute these streams to files. Pipes let you connect the output of one command to the input of another, building powerful data processing pipelines.
The pipe is the most important concept here. Linux follows a philosophy of small, focused tools. grep searches, sort sorts, wc counts, head takes the first N lines. Individually they are simple. Piped together, they solve complex problems: cat access.log | grep "500" | awk '{print $1}' | sort | uniq -c | sort -rn | head -10 gives you the top 10 IP addresses causing 500 errors.

Key Takeaways

  • Linux file system starts at / (root)
  • Use ls, cd, pwd for navigation
  • cp, mv, rm for file operations
  • cat, less, head, tail to view files
  • find and grep to search
  • Tab completion and history save time
  • Pipes (|) chain commands together

Next: Linux Permissions & Users →