Learn to Code
All tracks
Learn to Code

Free lessons from scratch to pro — every language, databases and DevOps.

AboutContactPrivacy PolicyTerms of Use

Your progress is saved in this browser. © 2026 Learn to Code

LX
Linux
0/11 completed
Beginner
The Linux file systemUsers, groups and permissionsPackage managers
Intermediate
Processes and signalsDisks, storage and archivesNetworking commandsSSH and remote access
Advanced
systemd and servicesLogs and troubleshooting
Pro
Securing a serverPerformance and resource limits
Tracks / Linux / Beginner

The Linux file system

Linux runs most of the internet: nearly every cloud server, Docker container, Android phone and supercomputer. If you deploy code, you'll work on a Linux machine sooner or later, usually through a terminal over SSH. This track teaches you to find your way around one, run software on it, and keep it healthy.

💡 About the examples in this track: every command was run on Ubuntu 24.04 (with systemd, a web server and an SSH server installed), and the Output under it is exactly what it printed. Numbers like process IDs, sizes, dates and IP addresses will be different on your machine. If you're new to the terminal, do the Terminal & Command Line track first; this one builds on it.

One tree, starting at /

Windows has a separate tree per drive (C:\, D:\). Linux has one tree, starting at the root /. Extra disks, USB sticks and network drives are attached (mounted) as folders somewhere inside it.

bash
ls /
Output
bin		   dev	 lib		    mnt   root	sbin.usr-is-merged  tmp
bin.usr-is-merged  etc	 lib.usr-is-merged  opt   run	srv		    usr
boot		   home  media		    proc  sbin	sys		    var

(The *.usr-is-merged entries are markers Ubuntu 24.04 leaves after merging /bin into /usr/bin; ignore them.)

Every Linux system uses roughly the same layout, described by the Filesystem Hierarchy Standard:

Folder What lives there
/etc Configuration files for the system and installed programs (text files you edit)
/home Users' personal folders: /home/asha, /home/you
/root The home folder of the root (administrator) user
/usr/bin, /bin Programs (commands) everyone can run
/usr/sbin, /sbin System administration programs
/usr/lib, /lib Shared libraries used by programs
/usr/local Software you installed yourself, outside the package manager
/opt Optional, self-contained apps (often commercial or vendor software)
/var Variable data that grows: logs (/var/log), databases, caches, websites (/var/www)
/tmp Temporary files, often wiped on reboot
/dev Devices shown as files: disks (/dev/sda), /dev/null, /dev/random
/proc, /sys Virtual files the kernel creates to show live system information
/boot The kernel and files needed to start the machine
/mnt, /media Mount points for extra disks and removable media

On modern distributions /bin is just a link to /usr/bin (and /sbin to /usr/sbin), so both names work:

bash
ls -ld /bin /sbin /lib
Output
lrwxrwxrwx 1 root root 7 Apr 22  2024 /bin -> usr/bin
lrwxrwxrwx 1 root root 7 Apr 22  2024 /lib -> usr/lib
lrwxrwxrwx 1 root root 8 Apr 22  2024 /sbin -> usr/sbin

"Everything is a file"

Linux shows almost everything as a file, even things that aren't stored on a disk. That means the same tools (cat, echo, grep) work on all of them.

bash
cat /etc/os-release | head -4
echo "---"
head -3 /proc/meminfo
echo "---"
cat /proc/sys/kernel/hostname
echo "hello" > /dev/null && echo "/dev/null swallowed it"
head -c 8 /dev/urandom | od -An -tx1 | wc -w
Output
PRETTY_NAME="Ubuntu 24.04.5 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.5 LTS (Noble Numbat)"
---
MemTotal:        8024852 kB
MemFree:          365080 kB
MemAvailable:    6381764 kB
---
devbox
/dev/null swallowed it
8
  • /etc/os-release tells you which distribution and version you're on. It's the first thing to check on an unfamiliar server.
  • /proc/meminfo isn't a real file: the kernel generates it each time you read it. free, top and ps get their information from /proc.
  • /dev/urandom gives endless random bytes (here 8 of them, shown as hex).

File types

ls -l shows the type of each entry in the first character:

bash
ls -l /etc/hostname /etc/ssl/certs/ca-certificates.crt
ls -ld /etc /dev/null
ls -l /etc/localtime
Output
-rw-r--r-- 1 root root      7 Nov 22 10:47 /etc/hostname
-rw-r--r-- 1 root root 180744 Nov 22 09:12 /etc/ssl/certs/ca-certificates.crt
crw-rw-rw- 1 root root 1, 3 Nov 22 10:47 /dev/null
drwxr-xr-x 1 root root 4096 Nov 22 10:47 /etc
lrwxrwxrwx 1 root root 27 Nov 22 10:08 /etc/localtime -> /usr/share/zoneinfo/Etc/UTC
First letter Type
- Regular file
d Directory
l Symbolic link (shows name -> target)
c / b Character / block device (/dev/null, disks)
s / p Socket / named pipe (used by programs to talk to each other)

The file command looks inside a file to tell you what it really is. Linux doesn't care about extensions:

bash
file /etc/hostname /usr/bin/ls /usr/bin/zcat /etc/ssl/certs
Output
/etc/hostname:  ASCII text
/usr/bin/ls:    ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=00a639537eef557c0dcb20ad52892bc84863ed94, for GNU/Linux 3.7.0, stripped
/usr/bin/zcat:  POSIX shell script, ASCII text executable
/etc/ssl/certs: directory

Links

A symbolic link (symlink) is a shortcut that points to another path. They're everywhere on servers: web server config, the current release of an app, the active Python version.

bash
mkdir -p releases/v1 releases/v2
echo "version 1" > releases/v1/app.txt
echo "version 2" > releases/v2/app.txt
ln -s releases/v1 current
cat current/app.txt
ln -sfn releases/v2 current     # switch the link atomically
cat current/app.txt
ls -l current
readlink -f current
Output
version 1
version 2
lrwxrwxrwx 1 you you 11 Nov 22 10:47 current -> releases/v2
/home/you/releases/v2

This "release folders + a current link" pattern is how many deployment tools switch versions instantly and roll back just as fast.

A hard link (ln without -s) is a second name for the same file data. Deleting one name leaves the other working. You'll meet them less often; the 2 in ls -l output is the hard-link count.

Hidden files and dotfiles

Names starting with . are hidden from ls (use ls -a). Programs keep per-user settings in these dotfiles in your home folder:

bash
ls -a ~ | head -8
Output
.
..
.bash_logout
.bashrc
.example.sh
.profile
current
releases
Dotfile Purpose
~/.bashrc Commands run when you open a Bash terminal (aliases, PATH)
~/.profile Run once at login
~/.ssh/ SSH keys and settings
~/.config/ Settings of many modern apps
~/.gitconfig Your Git name, email and aliases

Finding files

find searches by name, type, size, age and more:

bash
find /etc -maxdepth 1 -name "*.conf" | sort | head -5
echo "---"
find /var/log -type f -name "*.log" 2>/dev/null | sort | head -4
echo "---"
find /usr/bin -type f -size +1M | wc -l
find ~ -type f -mmin -60 | wc -l
Output
/etc/adduser.conf
/etc/ca-certificates.conf
/etc/debconf.conf
/etc/deluser.conf
/etc/e2scrub.conf
---
/var/log/alternatives.log
/var/log/apt/history.log
/var/log/apt/term.log
/var/log/bootstrap.log
---
7
3
Test Matches
-name "*.log" Name (use -iname to ignore case)
-type f / -type d Files / directories
-size +100M Bigger than 100 MB
-mtime -7 / -mmin -60 Changed in the last 7 days / 60 minutes
-user asha Owned by asha
-exec cmd {} + Run a command on the results

Two more ways to find things:

bash
command -v python3 bash
whereis -b nginx
Output
/usr/bin/python3
/usr/bin/bash
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx

command -v tells you which program actually runs when you type a name. whereis also finds binaries outside your PATH (such as /usr/sbin/nginx).

How much space?

bash
df -h / | sed 's/  */ /g'
du -sh /usr/share/doc /etc 2>/dev/null
du -h --max-depth=1 /var 2>/dev/null | sort -h | tail -4
Output
Filesystem Size Used Avail Use% Mounted on
overlay 224G 15G 199G 7% /
6.0M	/usr/share/doc
2.7M	/etc
1.8M	/var/cache
8.7M	/var/lib
8.7M	/var/log
20M	/var
  • df shows free space on each mounted file system.
  • du shows how much space folders use. du -h --max-depth=1 | sort -h is the standard way to find what's filling a disk.

You'll go deeper in Disks, storage and archives.

Practice

  1. Find out which Linux distribution and version you're running.
  2. List every .conf file directly inside /etc and count them.
  3. Create a current symlink that points to a v1 folder, then switch it to v2 and confirm with readlink.
  4. Find the five biggest folders inside /usr.
✎ Check your understanding

1.Where does system-wide configuration usually live?

2.Where would you look for a web server's log files?

3.What does ln -sfn releases/v2 current do?

4.What is /proc?