Chapter 3
Now that you can run commands, let’s go sightseeing inside Linux. We’ll explore files, directories, and the weird but powerful concept of links.
📂 Listing Files with ls
lsThe ls command shows files and directories.
Basic usage:
lsUseful options:
ls -l # long listing (permissions, size, owner, date)
ls -a # show hidden files (those starting with .)
ls -lh # human-readable sizes
ls -lt # sort by modification time (newest first)
ls -R # list recursively into subdirectories💡 Combine options → ls -lha shows everything in a readable way.
🧾 What’s This File? (file)
file)Linux doesn’t rely on extensions like .txt or .exe. To know what something is:
file /bin/lsOutput example:
/bin/ls: ELF 64-bit LSB executableIt tells you if it’s a binary, script, image, text file, etc.
📖 Viewing Files with less
lessOpen a file to scroll through:
less /etc/passwdControls:
↑ ↓→ move line by linePgUp / PgDn→ scroll pages/word→ search forward?word→ search backwardn→ next match,N→ previousq→ quit
💡 less doesn’t load the whole file at once → perfect for giant logs.
🗂️ Key Linux Directories
Linux follows the Filesystem Hierarchy Standard (FHS). Some key spots:
/→ root of everything/bin→ essential binaries (likels,cat,cp)/usr/bin→ user applications (editors, compilers, etc.)/etc→ system configuration files/home→ user directories (/home/you)/var→ variable data (logs, spool, caches)/tmp→ temporary files/liband/usr/lib→ libraries programs depend on/dev→ device files (disks, terminals, etc.)/proc→ virtual system info (kernel, processes)
Run:
ls /bin /etc /usr /varto see how different they look.
🔗 Links: Hard vs Symbolic
Linux lets you make multiple names for the same file.
Hard Links
A hard link is another directory entry pointing to the same file data.
Both names are equal — delete one, the data still exists until all are gone.
ln original.txt hardlink.txtSymbolic (Soft) Links
A symlink is a shortcut that points to another file.
If the target disappears, the symlink breaks.
ln -s /lib/libc-2.6.so libc.so.6Example from a real system:
lrwxrwxrwx 1 root root 11 2007-08-11 07:34 libc.so.6 -> libc-2.6.soHere:
lat the start means “link”libc.so.6is the symlinkIt points to →
libc-2.6.so
🏋️ Exercises
List everything in
/etcwith details:ls -lha /etcUse
fileto check:file /bin/bash file /etc/passwdOpen
/etc/passwdwithless→ search for your username.Explore directories:
ls /bin ls /usr/bin ls /var/logCreate a hard link and symbolic link to a file:
echo "hello" > test.txt ln test.txt hard.txt ln -s test.txt soft.txt ls -lNow delete
test.txtand see what happens tohard.txtvssoft.txt.
Date Learned: 15 August 2025
Source: The Linux Command Line, Chapter 3
Last updated