Friday, September 11, 2026

File System — Complete Beginner Guide

Unlike Windows, where you commonly see drives such as C:\, D:\, etc., Linux uses one main directory tree starting from / (root).

Think of it like this:

                         /
                    Linux Root
                         │
       ┌─────────────────┼─────────────────┐
       │                 │                 │
      /bin              /etc             /home
       │                 │                 │
   Commands          Configuration      Users
                         │
       ┌─────────────────┼─────────────────┐
       │                 │                 │
      /var              /tmp              /usr
       │                 │                 │
     Logs            Temporary          Programs

1. What is a Linux File System?

The Linux file system is the structure Linux uses to:

  • Store files
  • Store directories
  • Organize system files
  • Store user data
  • Store application files
  • Store configuration
  • Store logs
  • Manage devices

The top-level directory is:

/

This is called the root directory.

⚠️ Don't confuse / (root directory) with /root (the home directory of the root administrator).

2. Linux File System Structure

The major directories are:

Directory

Purpose

Example

/

Root of entire file system

/

/bin

Essential user commands

ls, cp, mv

/boot

Boot-related files

Kernel, bootloader files

/dev

Device files

Disk, terminal devices

/etc

System configuration

/etc/ssh/

/home

Normal users' home directories

/home/sandeep

/lib

Essential libraries

System libraries

/media

Removable media mount points

USB drive

/mnt

Temporary mount points

Mounted disk

/opt

Optional/third-party software

/opt/app

/proc

Process/kernel information

/proc/cpuinfo

/root

Root user's home directory

/root

/run

Runtime information

Process/service runtime data

/sbin

System administration commands

ip, fsck

/srv

Data served by services

Web/server data

/sys

Kernel/device information System

Hardware information

/tmp

Temporary files

Temporary application files

/usr

User applications and utilities

/usr/bin

/var

Frequently changing data varible

Logs, cache, databases

3. The Linux File System Tree

A simple structure to remember:

/
├── bin
├── boot
├── dev
├── etc
├── home
│   ├── user1
│   └── user2
├── lib
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin
├── srv
├── sys
├── tmp
├── usr
│   ├── bin
│   ├── lib
│   └── local
└── var
    ├── log
    ├── cache
    └── www

You can see this structure on Ubuntu with:

ls /

If tree is installed:

tree -L 1 /

4. / Root Directory

Everything in Linux starts from /.

Example:

/

Under / you have:

/home
/etc
/var
/usr
/tmp
/opt
...

You can go to root using:

cd /

Check:

pwd

Output:

/

Think of / as:

The main building containing everything inside Linux.

5. /home — User Files

Normal users usually have their personal directory under /home.

Example:

/home/sandeep

If the username is sandeep:

/home/sandeep

Your personal files can be stored here:

/home/sandeep/
├── Documents
├── Downloads
├── Pictures
├── Projects
└── linux-lab

Check:

cd /home
ls

Or:

cd ~

~ means current user's home directory.

Check:

pwd

6. /root — Root User's Home

/root is the home directory of the root administrator.

Example:

/root

It is different from:

/

Remember:

PathMeaning
/Entire Linux file system
/rootRoot user's home directory
~Current user's home directory

7. /etc — Configuration Files ⭐

This is extremely important for System Administrators.

/etc contains system and application configuration files.

Examples:

/etc/hosts
/etc/hostname
/etc/passwd
/etc/group
/etc/fstab
/etc/ssh/

Check:

ls /etc

Important files

File

Purpose

/etc/hostname

Computer hostname

/etc/hosts

Local hostname/IP mappings

/etc/passwd

User account information

/etc/group

Group information

/etc/fstab

Filesystem mount configuration

/etc/ssh/

SSH configuration

/etc/resolv.conf

DNS resolver configuration

Example:

cat /etc/hostname

8. /var — Variable Data ⭐

/var contains data that changes frequently.

Examples:

/var/log
/var/cache
/var/lib
/var/tmp

The most important for administrators is:

/var/log

It contains system and application logs.

Example:

ls /var/log

You may see:

syslog
auth.log
kern.log
dpkg.log

View a log:

sudo tail /var/log/syslog

Logs are very important for troubleshooting.

9. /tmp — Temporary Files

/tmp is used for temporary files.

Example:

cd /tmp

Create a test file:

touch test.txt

Check:

ls

Applications can use /tmp for temporary data.

Don't use /tmp for important permanent files.

10. /usr — Applications and Utilities

/usr contains many user applications, commands, libraries and shared resources.

Important directories:

/usr/bin
/usr/sbin
/usr/lib
/usr/local
/usr/share

For example:

ls /usr/bin

You will find many commands/programs there.

You can check where a command is located:

which ls

Example output:

/usr/bin/ls

11. /bin — Essential Commands

Traditionally /bin contains essential commands.

Examples:

ls
cp
mv
rm
cat
mkdir

On many modern Ubuntu systems, /bin is linked to /usr/bin because of the usr-merge design.

So don't be surprised if:

ls -ld /bin

shows that /bin is a symbolic link.

12. /sbin — System Administration Commands

/sbin traditionally contains system administration commands.

Examples include tools related to:

  • Networking
  • Filesystems
  • System recovery
  • Administration

Modern Ubuntu systems may also use /usr/sbin as part of usr-merge.

13. /boot — Boot Files

/boot contains files needed when Linux starts.

Example:

ls /boot

You may find:

vmlinuz
initrd
grub

Important:

The Linux kernel is loaded during the boot process.

14. /dev — Devices ⭐

Linux treats many hardware devices as files.

/dev contains device files.

Examples:

/dev/sda
/dev/sdb
/dev/null
/dev/zero
/dev/tty

Check:

ls /dev

For disks:

lsblk

Example:

NAME   SIZE TYPE
sda     20G disk
├─sda1  19G part
└─sda2   1G part

This is very important for Linux administration.

15. /proc — Process and Kernel Information ⭐

/proc is a virtual filesystem.

It provides information about:

  • Running processes
  • CPU
  • Memory
  • Kernel
  • System information

Example:

cat /proc/cpuinfo

Memory:

cat /proc/meminfo

Kernel version:

cat /proc/version

Running process directories can be seen with:

ls /proc

Numbers such as:

1
100
245
...

can represent Process IDs (PIDs).

16. /sys — Kernel & Hardware Information

/sys is another virtual filesystem.

It provides information about:

  • Hardware
  • Devices
  • Kernel
  • Drivers

Example:

ls /sys

It is commonly used by Linux tools and administrators when investigating hardware/device information.

17. /run — Runtime Data

/run contains temporary runtime information created after boot.

It may contain information related to:

  • Services
  • Processes
  • PID files
  • Sockets

Example:

ls /run

18. /media — Removable Devices

When removable devices such as USB drives are mounted automatically, they may appear under:

/media

Example:

/media/user/USB

19. /mnt — Mount Point

/mnt is traditionally used as a temporary location for mounting filesystems.

Example:

sudo mount /dev/sdb1 /mnt

Then the contents of the disk can be accessed through:

/mnt

20. /opt — Optional Software

/opt is commonly used for optional or third-party software.

Example:

/opt/myapp
/opt/software

For example, an organization might install a custom application:

/opt/company-app/

21. /srv — Service Data

/srv can contain data served by system services.

For example:

/srv/www

It is not used for every web server installation, but the directory exists for this purpose.

22. Linux File System — Important Concept

Linux has one directory tree.

Windows:

C:\
D:\
E:\

Linux:

/
├── home
├── etc
├── var
├── usr
└── ...

Additional disks/filesystems are normally mounted somewhere inside this tree.

For example:

/
├── home
├── var
├── usr
└── data       ← another filesystem mounted here

23. Absolute Path vs Relative Path ⭐

This is very important.

Absolute Path

Starts from /.

Example:

/home/sandeep/linux-lab/test.txt

It gives the complete location.

Relative Path

Starts from your current directory.

Example:

linux-lab/test.txt

If you are currently inside:

/home/sandeep

then:

linux-lab/test.txt

means:

/home/sandeep/linux-lab/test.txt

24. . and ..

Two very important symbols:

SymbolMeaning
.Current directory
..Parent directory
~Current user's home directory
/Root directory

Example:

pwd

Suppose:

/home/sandeep

Go into parent:

cd ..

Now:

/home

Go back:

cd sandeep

Ex-
ls ~
ls ..
ls /
cd /

25. Important File Commands


Command

Purpose

Example

pwd

Show current directory

 pwd

ls

List files 

 ls

ls -l

Detailed listing

 ls -l

ls -la

Include hidden files

 ls -la

cd

Change directory

 cd /etc

mkdir

Create directory

 mkdir test

touch

Create file

 touch file.txt

cp

Copy

 cp a.txt b.txt

mv

Move/rename

 mv a.txt new.txt

rm

Delete file

 rm file.txt

cat

Display file

 cat file.txt

less

Read large file

 less file.txt

head

First lines

 head file.txt

tail

Last lines

 tail file.txt

find

Search files

 find /home -name "*.txt"

du

Directory/file size

 du -sh folder

df

Filesystem disk usage

 df -h

lsblk

Show disks/partitions

 lsblk

mount

Show/mount filesystems

 mount

umount

Unmount filesystem

 sudo umount /mnt

26. Understanding ls -l



drwxr-xr-x 1
│ │ │ │   │
│ │ │ │   └── Permissions
│ │ │ └───── Group
│ │ └─────── Owner (w- wright)
│ └──────── File type (r- Readable )
└───────── File information (d- Directory)

Run:

ls -l

Example:

-rw-r--r-- 1 sandeep sandeep 1250 Sep 12 test.txt

Break it down:

-rw-r--r--
│││ │  │
│││ │  └── Permissions
│││ └───── Group
││└─────── Owner
│└──────── File type
└───────── File information ()

More accurately:

-rw-r--r--
│
└── File type + permissions

First character:

CharacterMeaning
-Regular file
dDirectory
lSymbolic link

Example:

drwxr-xr-x

means it is a directory.

27. Hidden Files

Linux hidden files usually begin with ..

Example:

.bashrc
.profile
.gitconfig

Normal:

ls

Hidden files:

ls -a

Detailed:

ls -la

28. File Types in Linux

Linux supports several important file types.

SymbolType
-Regular file
dDirectory
lSymbolic link
cCharacter device
bBlock device
sSocket
pNamed pipe

Example:

ls -l

You might see:

-rw-r--r-- file.txt
drwxr-xr-x documents
lrwxrwxrwx link -> file.txt

29. Linux Filesystem vs Windows File System

Linux

Windows

/ is root

C:\ commonly starts a drive

/home

C:\Users

/etc

Configuration is distributed differently

/var/log

Event Viewer/log locations

/tmp

%TEMP%

/dev

Device handling differs

/mnt

Drive mounting differs

/root

Administrator does not have the same home-directory convention

/ uses forward slash

Windows commonly uses \

30. Practical Lab — Explore Your Linux File System

Since you're using WSL Ubuntu, this is a good practice exercise.

Step 1 — Go to root

cd /
pwd

Expected:

/

Step 2 — List root directories

ls

Better:

ls -lah /

Step 3 — Explore /etc

cd /etc
ls

Check hostname:

cat hostname

Step 4 — Explore /home

cd /home
ls

Step 5 — Go to your home

cd ~
pwd

Step 6 — Create a lab

mkdir -p ~/linux-lab/files

Create files:

touch ~/linux-lab/files/test1.txt
touch ~/linux-lab/files/test2.txt

Check:

ls -l ~/linux-lab/files

Step 7 — Check disk space

df -h

Step 8 — Check directory size

du -sh ~/linux-lab

Step 9 — Check disks

lsblk

Step 10 — Explore processes

ls /proc

Then:

cat /proc/meminfo

31. Linux File System — Admin Perspective ⭐

As a Linux System Administrator, focus especially on these:

AreaWhat to Learn
/etcConfiguration
/var/logLogs/troubleshooting
/homeUser data
/rootRoot user's home
/tmpTemporary files
/usrApplications/utilities
/optThird-party applications
/devDevices/disks
/procProcesses/kernel information
/sysHardware/kernel information
/bootBoot/kernel files
/mntMount points
/mediaRemovable media
dfFilesystem capacity
duDirectory/file usage
lsblkDisk/partition information
mountMount filesystem
fstabPersistent mount configuration

Easy Way to Remember

/        → Everything
│
├── /boot    → Boot Linux
├── /bin     → Basic commands
├── /sbin    → Admin commands
├── /dev     → Devices
├── /etc     → Configuration ⭐
├── /home    → Users ⭐
├── /root    → Root user's home
├── /tmp     → Temporary
├── /usr     → Programs/utilities
├── /var     → Changing data ⭐
│   └── /log → Logs ⭐
├── /opt     → Optional software
├── /mnt     → Mount point
├── /media   → USB/removable media
├── /proc    → Processes/kernel ⭐
├── /sys     → Hardware/kernel
├── /run     → Runtime data
└── /srv     → Service data

Then learn 

permissions → users/groups → processes → services → disks/filesystems → mounting → logs → networking

These topics build directly on the file-system knowledge you're learning now.

No comments:

Post a Comment

File System — Complete Beginner Guide

Unlike Windows, where you commonly see drives such as C:\ , D:\ , etc., Linux uses one main directory tree starting from / (root) . Think ...