Linux may seem intimidating at first, especially
when you're greeted with folders like /etc, /var, /dev, and more. But once you
understand the directory structure and file system hierarchy, navigating and
managing your Linux system becomes much easier.
In the previous post we discussed Linux boot process
and system workflow and in this post, we’ll break down the Linux File System
Hierarchy Standard (FHS), explain what each major directory is for, and guide
you through common commands used to explore the file system.
1. What is the Linux File System?
2. The Root Directory and File System
Hierarchy
3. File System Types in Linux
4.
Why
Understanding the File System Matters
5.
What
is File Permissions in Linux?
6. How to change File Permissions Using chmod
7. Special Permissions
8. Security Tips
1.
What is the Linux File System?
The Linux file system is a structured and
standardized method of storing and organizing files on your Linux-based
operating system. Unlike Windows, where drives like C:\ or D:\ represent
partitions, Linux uses a single-rooted
directory tree starting from / (called the root). Everything in Linux —
files, directories, devices, and even processes — is treated as a file.
2. The Root
Directory / and the File System Hierarchy
The top of the
Linux file system is the root directory, denoted by /. All other files
and directories stem from this root. Here's a breakdown of the most common
directories you'll encounter.
2.1 / - Root Directory
This is the
base of the file system. Every single file and directory starts from here.
2.2 /boot Directory
This is one of the
most important directories in the Linux file system. The boot directory
contains Linux boot files as the bootloader, kernel and its related files.
Image of Linux kernel stays here in the form of a compressed file.
2.3 /bin — Essential User Binaries
Contains basic
Linux commands needed for system boot and recovery, available to all users.
2.4 /sbin — System Binaries
It is like a
/bin directory but contains essential system binaries meant for root or
administrative users.
2.5 /etc — Configuration Files
This directory
holds system-wide configuration files and scripts used to initialize settings
for programs and services.
2.6 /home — User Home Directories
Each user gets
a personal folder under /home. This is where personal documents, downloads, and
settings are stored.
2.7 /root — Root User’s Home
Directory
This is the
home directory of the root user, not to be confused with / (the file system
root).
2.8 /var — Variable Files
Used for data
that changes frequently, such as logs, spool files, caches, etc.
2.9 /usr — User System Resources
Contains
read-only user applications, documentation, libraries, and binaries.
2.10 /tmp — Temporary Files
Temporary data used by applications or the system. Files
are typically deleted after a reboot.
2.11 /dev — Device
Files
Represents hardware devices like hard drives, terminals,
USBs as files.
2.12 /proc and /sys —
Virtual File system
These directories contain runtime system information,
generated on-the-fly.
/proc includes process
data and kernel parameters.
/sys exposes hardware
information.
2.13 /lib — Essential
Shared Libraries
Libraries required by binaries in /bin and /sbin. They’re
similar to DLLs in Windows.
2.14 /media and /mnt
— Mount Points
/media: automatically
mounted removable devices (USB drives, CDs).
/mnt: used for manually
mounting file systems or drives.
3. File System Types
in Linux
Linux supports various file systems. Here are some common
ones:
File System Description
Ext4 Default
modern Linux file system; robust and fast
xfs High-performance
journaling file system
btrfs Next-gen
file system with snapshots and checksums
Vfat/fat32 Used
in USB drives and dual-boot environments
ntfs Windows
file system, supported via drivers
4. Why Understanding
the File System Matters
·
Helps
in troubleshooting system errors
·
Makes
you confident using terminal-based tools
·
Crucial
for Linux administration, DevOps and certification exams
·
Prevents
accidental deletion of critical files
·
Helps
in partitioning and backup strategies
5. What is File
Permissions in Linux?
In Linux, everything is a file — whether it’s a document,
a device, or a program. Each file or directory has permissions that define who
can read, write, or execute that file.
These permissions are applied to three categories:
·
Owner
– the user who owns the file
·
Group
– a group of users assigned to the file
·
Others
– everyone else
Types of Permissions
Symbol Permission Description
r Read View file
content or list directory
w Write Modify
file content or directory files
x Execute Run
file as a program or enter directory
File Permission
Examples
1. -rwxr--r--
·
Owner:
can read, write, and execute
·
Group:
read-only
·
Others:
read-only
2. drwxr-xr-x
·
Directory
·
Everyone
can enter the directory
·
Only
owner can modify contents
6. How to Change File
Permissions Using chmod
The chmod command is used to change file modes or access
permissions.
Symbolic Method
·
chmod
u+x file.sh # Add execute permission
for user
·
chmod
g-w file.sh # Remove write
permission for group
·
chmod
o=r file.txt # Set
others to read-only
Numeric (Octal)
Method
Each permission type has a value:
Permission Value
·
Read
(r) 4
·
Write
(w) 2
·
Execute
(x) 1
Directory Permissions
File permissions also apply to directories, but they work
slightly differently:
Permission Effect
on Directory
r List contents of
the directory
w Create or delete
files in the directory
x Access files and
subdirectories inside
7. Special Permissions
Set UID (s)
When set on executables, the program runs with the
owner’s privileges, not the users.
·
chmod
u+s program
Set GID (s)
When set on directories, new files inherit the group of
the directory.
·
chmod
g+s /data/shared
Sticky Bit (t)
Only the file owner or root can delete files in that
directory.
Used commonly in /tmp:
·
chmod
+t /tmp
8. Security Tips
·
Avoid
giving 777 permissions — it gives full access to everyone
·
Use
chmod -R cautiously — it applies changes recursively
·
Use
groups to manage access to shared files
Please keep visiting seeklinux for more information and updates.
Post a Comment