Course: From Basic Science to Web Hosting
Module 04 — Linux Fundamentals
What Is the Linux Filesystem?
Difficulty: Beginner → Intermediate
Prerequisites: Lesson 016 — What Really Happens When You Run a Linux Command?
Estimated time: 30–40 minutes
1. The Big Question
You have already used paths such as:
/storage/websites/templates.cresignsys.com/public
and commands such as:
cd /storage/websites/
ls
But what exactly is this structure?
Why does Linux have:
/etc
/var
/usr
/home
/dev
/proc
/sys
?
To understand Linux administration properly, we first need to understand its filesystem.
2. What Is a Filesystem?
A filesystem is the software-defined structure used to organize and manage persistent data on storage.
At a simple level:
Storage device
↓
Filesystem
↓
Directories
↓
Files
For example:
SSD
↓
Filesystem
↓
/
├── etc
├── var
├── home
└── storage
3. Linux Has One Main Directory Tree
Linux organizes its filesystem as a tree.
At the top is:
/
This is called:
Root Directory
Do not confuse:
/
with:
root
The first is the filesystem’s top directory.
The second usually refers to the administrative user account.
4. The Root of the Filesystem
Everything in the normal Linux filesystem hierarchy starts from:
/
For example:
/etc
means:
/
└── etc
And:
/var/log
means:
/
└── var
└── log
And:
/storage/websites/
means:
/
└── storage
└── websites
5. Absolute Paths
A path beginning with / is an absolute path.
Example:
cd /storage/websites/
It means:
Start from the filesystem root and go to
storage, thenwebsites.
6. Relative Paths
A path without / at the beginning is normally interpreted relative to the current directory.
Suppose:
pwd
returns:
/storage/websites/
Then:
cd templates.cresignsys.com
means:
/storage/websites/templates.cresignsys.com
7. pwd
The command:
pwd
means:
Print Working Directory
Example:
pwd
Output:
/storage/websites/templates.cresignsys.com/public
This tells you exactly where you currently are in the filesystem tree.
8. ls
The command:
ls
lists directory contents.
For example:
ls
might show:
index.php
wp-config.php
wp-content
wp-admin
wp-includes
9. cd
The command:
cd
means:
change directory
Example:
cd /storage/websites/
Then:
pwd
might show:
/storage/websites
10. The Linux Filesystem Tree
A simplified Linux filesystem might look like:
/
├── bin
├── boot
├── dev
├── etc
├── home
├── lib
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin
├── srv
├── sys
├── tmp
├── usr
├── var
└── storage
Some modern distributions use merged directories such as /usr/bin being the effective location behind /bin; the exact filesystem layout can vary.
11. /bin
Historically:
/bin
contains essential user command binaries.
Examples conceptually include:
ls
cp
mv
cat
On modern Ubuntu systems, /bin is commonly a symbolic link into /usr/bin.
You can inspect it with:
ls -ld /bin
12. /sbin
Historically:
/sbin
contains system-administration commands.
Modern Linux distributions may similarly merge this into /usr/sbin.
Examples include tools used for:
System administration
Networking
Disk management
Boot/system maintenance
13. /usr
This is one of the most important directories.
It contains a large part of the operating system’s user-space software.
For example:
/usr/bin
/usr/sbin
/usr/lib
/usr/share
Conceptually:
/usr
├── bin
├── sbin
├── lib
└── share
Many applications and utilities live here.
14. /etc
This is extremely important for a server.
/etc
primarily contains system and application configuration.
Examples:
/etc/nginx/
/etc/ssh/
/etc/systemd/
/etc/php/
/etc/mysql/
So when you modify:
/etc/nginx/
you are modifying Nginx configuration.
15. Your Nginx Configuration
You have worked with:
/etc/nginx/sites-enabled/
This is part of:
/etc
↓
nginx
↓
configuration
For example:
/etc/nginx/sites-enabled/templates.cresignsys.com
can contain the Nginx server configuration for that website.
16. /var
/var is used for variable/changing system data.
Examples:
/var/log
/var/lib
/var/cache
The word “variable” means the contents can change during normal operation.
17. /var/log
This directory contains logs.
For example:
/var/log/nginx/
may contain:
access.log
error.log
You can inspect them with:
sudo tail -f /var/log/nginx/error.log
This is extremely useful when troubleshooting websites.
18. /var/lib
This is commonly used for persistent application/system state.
For example, databases and system services may maintain data under /var/lib.
The exact location depends on the software.
19. /var/cache
This contains cache data maintained by various applications.
Caches can often be regenerated, although you should never assume every file under a cache directory is safe to delete without understanding the specific application.
20. /home
This normally contains users’ home directories.
Example:
/home/ubuntu
Inside:
/home/ubuntu/
you may have:
Documents
Downloads
scripts
projects
21. /root
This is normally the home directory of the root user:
/root
Remember the distinction:
/
= filesystem root
root
= privileged Linux user
and:
/root
= root user's home directory
These are three related but different concepts.
22. /tmp
This directory is commonly used for temporary files.
/tmp
Applications can use it for temporary data.
Important:
Do not assume anything placed in
/tmpwill persist permanently.
Temporary-directory cleanup behavior depends on the system configuration.
23. /boot
This contains files related to booting the operating system.
For example:
/boot
may contain:
Linux kernel
initramfs
bootloader-related files
The exact arrangement depends on the boot architecture.
24. /dev
This is a very interesting directory.
/dev
contains device nodes representing devices and device interfaces.
Examples can include:
/dev/null
/dev/zero
/dev/random
and storage/device nodes.
Linux uses the filesystem interface to expose many devices to user-space programs.
25. /dev/null
One famous Linux device is:
/dev/null
Anything written to it is discarded.
For example:
echo "hello" > /dev/null
The text disappears.
Conceptually:
Program
↓
/dev/null
↓
discard
26. /dev/zero
Another special device:
/dev/zero
provides a stream of zero-valued bytes when read.
This illustrates an important Linux idea:
Many devices and kernel interfaces can be exposed through file-like interfaces.
27. /proc
Now we reach something very important.
/proc
is not an ordinary disk directory.
It is a virtual filesystem provided by the kernel.
It exposes information about:
Processes
CPU
Memory
Kernel state
System information
For example:
cat /proc/cpuinfo
can display processor information.
28. /proc/meminfo
Try:
cat /proc/meminfo
You can see information about memory.
Conceptually:
Linux kernel
↓
/proc
↓
Information exposed to user space
The data is dynamically generated by the kernel.
29. /proc/PID
Every process has a process ID, commonly called:
PID
Suppose a process has:
PID = 1234
Linux can expose information under:
/proc/1234/
Conceptually:
Process
↓
PID
↓
/proc/PID
This becomes extremely useful when learning process management.
30. /sys
Similar to /proc, Linux provides:
/sys
which is a virtual filesystem exposing information about devices, drivers, buses, and kernel device models.
Conceptually:
Hardware
↓
Kernel device model
↓
/sys
↓
User-space tools
31. /run
/run
contains runtime state.
It is generally temporary and is usually populated during boot.
Examples can include:
PID information
Sockets
Runtime service state
32. /media
This is commonly used as a location for automatically mounted removable media.
For example:
/media/username/USB
33. /mnt
Traditionally used as a temporary or manually managed mount point.
For example:
/mnt/data
could be used for a mounted filesystem.
34. /opt
/opt
is commonly used for optional/add-on application software.
For example, some third-party software may install under:
/opt/application/
35. /srv
/srv
is intended for data served by the system.
For example, a service could theoretically use:
/srv/www/
However, server administrators often choose other directory structures based on their architecture.
Your:
/storage/websites/
is perfectly valid as a custom hosting layout.
36. /storage
This is important for your setup.
Unlike directories such as /etc or /var, /storage is not a mandatory standard Linux directory.
You or your hosting architecture created it for your own purpose.
For example:
/storage
└── websites
├── site1
├── site2
└── site3
This is a good example of Linux’s flexibility.
37. Your Hosting Structure
Your architecture can be represented as:
/
└── storage
└── websites
└── templates.cresignsys.com
└── public
├── index.php
├── wp-admin
├── wp-content
├── wp-includes
└── wp-config.php
This is the physical filesystem organization of the website files.
38. Filesystem vs Website URL
This distinction is extremely important.
Your filesystem path might be:
/storage/websites/templates.cresignsys.com/public/
But the user sees:
https://templates.cresignsys.com/
These are not the same thing.
Nginx creates the connection between them.
Conceptually:
Browser URL
↓
Nginx configuration
↓
Filesystem path
39. Nginx root
A typical Nginx configuration might contain something conceptually like:
server {
server_name templates.cresignsys.com;
root /storage/websites/templates.cresignsys.com/public;
}
This tells Nginx:
Use this filesystem directory as the document root for this virtual host.
Therefore:
https://templates.cresignsys.com/
can map to:
/storage/websites/templates.cresignsys.com/public/
40. One URL Request
Suppose someone requests:
https://templates.cresignsys.com/about.html
Conceptually:
Browser
↓
DNS
↓
Server IP
↓
TCP 443
↓
TLS
↓
Nginx
↓
server_name
↓
root directory
↓
about.html
The physical file might be:
/storage/websites/templates.cresignsys.com/public/about.html
41. Why /etc and /storage Are Different
This distinction will become extremely useful.
/etc
↓
Configuration
while:
/storage
↓
Your website data
For example:
/etc/nginx/
contains instructions telling Nginx how to serve the site.
While:
/storage/websites/templates.cresignsys.com/public/
contains the website itself.
42. Configuration vs Data
This is a general systems principle:
Configuration
↓
How the software should behave
Data
↓
What the software works with
For your website:
Nginx configuration
↓
How requests are handled
WordPress files/database
↓
Website content
43. Logs Are Another Layer
Nginx also produces logs:
/var/log/nginx/
So we have:
/etc/nginx/
↓
Configuration
/storage/websites/
↓
Website data
/var/log/nginx/
↓
Operational records
These three locations have completely different purposes.
44. A Practical Example
Suppose the website gives:
502 Bad Gateway
Don’t immediately edit WordPress.
First consider:
Nginx
↓
PHP-FPM
Check:
sudo systemctl status nginx
Then:
sudo systemctl status php*-fpm
And inspect:
sudo tail -f /var/log/nginx/error.log
Now you are troubleshooting according to the architecture.
45. Another Example: 404
Suppose:
https://templates.cresignsys.com/test.html
returns:
404 Not Found
Possible causes include:
Wrong Nginx root
Wrong URL
File does not exist
Nginx location rule
WordPress routing
First understand which layer is responsible.
46. Filesystem Hierarchy to Remember
For your web-hosting work, memorize these first:
/
├── etc → configuration
├── var → changing data/logs
├── usr → installed user-space software
├── home → user home directories
├── root → root user's home
├── tmp → temporary data
├── dev → device interfaces
├── proc → kernel/process information
├── sys → kernel/device information
├── run → runtime state
└── storage → your custom hosting storage
47. The Deeper Architecture
Now connect today’s lesson with everything before it:
HARDWARE
↓
CPU / RAM / SSD
↓
Linux Kernel
↓
Virtual Filesystem Interface
↓
Filesystem
↓
Directories
↓
Configuration / Data / Logs
↓
Applications
And for your hosting server:
Linux
│
├── /etc/nginx
│ ↓
│ Nginx configuration
│
├── /var/log/nginx
│ ↓
│ Nginx logs
│
└── /storage/websites
↓
Website files
48. Most Important Concept
Don’t memorize directories as a random list.
Understand their purpose:
/etc
= "How should the system/software behave?"
/var
= "What changing operational data exists?"
/usr
= "What software is installed?"
/home
= "Where are user files?"
/dev
= "How does user space interact with devices?"
/proc
= "What does the kernel expose about processes/system?"
/sys
= "What does the kernel expose about devices/system structure?"
/storage
= "Where did we choose to keep our hosting data?"
49. Quick Check
What is /?
The root of the Linux filesystem hierarchy.
What is /etc?
Primarily system and application configuration.
What is /var/log?
A common location for system/application logs.
What is /usr?
A major hierarchy containing user-space programs, libraries, and shared data.
What is /proc?
A kernel-provided virtual filesystem exposing process and system information.
What is /sys?
A kernel-provided virtual filesystem exposing device/kernel information.
What is /storage?
In your server, a custom directory used for hosting data.
Where are your website files?
For example:
/storage/websites/templates.cresignsys.com/public/
Where is Nginx configuration?
Commonly under:
/etc/nginx/
Where are Nginx logs?
Commonly:
/var/log/nginx/
Next Lesson — 018
Linux Users, Groups, Ownership and Permissions
This is the next essential foundation before managing multiple websites.
We will build from the deepest basics:
User
↓
Group
↓
Process identity
↓
File owner
↓
Permissions
↓
r / w / x
↓
chmod
↓
chown
↓
chgrp
↓
sudo
↓
www-data
↓
Nginx
↓
PHP-FPM
↓
WordPress
Then we will answer an important real-world question:
Why can Nginx/PHP sometimes read a WordPress file but cannot write to it?
That leads directly into secure multi-domain web hosting.
Leave a Reply