Every Linux system follows a standard directory layout called the Filesystem Hierarchy Standard (FHS). Once we learn where things live, navigating any Linux box feels familiar.
The FHS Tree
The key takeaway: config goes in /etc, logs go in /var/log, and our stuff lives in /home.
Essential Navigation Commands
pwd # print current directory
ls -la # list all files with details (including hidden)
cd /var/log # change to a specific directory
cd ~ # go home (same as just "cd")
cd - # go back to the previous directory
mkdir -p app/src/utils # create nested directories in one shot
Viewing and Searching Files
cat config.json # dump entire file to screen
head -20 access.log # first 20 lines
tail -f app.log # follow log output in real-time (Ctrl+C to stop)
wc -l data.csv # count lines in a file
grep is our best friend for searching inside files.
grep "error" app.log # find lines containing "error"
grep -i "warning" app.log # case-insensitive search
grep -r "TODO" src/ # recursive search through directories
grep -n "function" index.js # show line numbers
find searches for files by name, type, or age.
find /var/log -name "*.log" # find all .log files
find . -type f -mtime -1 # files modified in the last 24 hours
find . -name "*.tmp" -delete # find and delete .tmp files
Pipes and Redirection
Pipes (|) send the output of one command into another. Think of it like an assembly line.
cat access.log | grep "404" | wc -l # count 404 errors
ps aux | grep nginx # find nginx processes
history | grep "docker" # search command history
Redirection sends output to files instead of the screen.
echo "hello" > file.txt # write to file (overwrites!)
echo "world" >> file.txt # append to file (safe)
cat missing.txt 2> err.log # redirect errors (stderr) to a file
sort data.txt > sorted.txt # sort and save to a new file
Wildcards
ls *.log # all files ending in .log
ls app.??? # app followed by exactly 3 characters
rm temp_[0-9]* # remove files starting with temp_ followed by a digit
Quick awk Intro
awk is great for pulling columns out of structured text.
# print the 1st and 3rd column from a space-separated file
awk '{print $1, $3}' access.log
# print lines where the 5th column is greater than 500
awk '$5 > 500' access.log
In simple language, the Linux filesystem is like a well-organized filing cabinet. Once we know which drawer (/etc, /var, /home) holds what, we can find anything fast.