StudyLover
  • Home
  • Study Zone
  • Profiles
  • Typing Tutor
  • Contact us
  • Sign in
StudyLover Linux Filesystem Overview
Download
  1. Linux
Shell : WSL or VirtualBox setup
Linux

1) Big picture: one tree, rooted at /

·         Linux organizes everything in a single tree that starts at / (called root).

·         Drives/partitions (C:, D: in Windows) are mounted as folders inside this tree (e.g., /home, /mnt/data).

·         Case-sensitive: Report.txt ≠ report.txt.

/

├─ bin/    ─ programs used by everyone

├─ sbin/   ─ admin/system programs

├─ etc/    ─ system-wide config files

├─ usr/    ─ userland apps & libraries

├─ var/    ─ variable data (logs, caches)

├─ home/   ─ users’ personal folders

├─ root/   ─ home of the root user

├─ tmp/    ─ temporary files (auto-cleaned)

├─ boot/   ─ bootloader, kernel, initramfs

├─ dev/    ─ device files (disks, tty, usb)

├─ proc/   ─ process & kernel info (virtual)

├─ sys/    ─ devices/driver info (virtual)

├─ run/    ─ runtime state since boot

├─ media/  ─ auto-mount (USB, DVDs)

└─ mnt/    ─ manual mounts (you mount here)

Quick meanings (FHS essentials)

·         /bin, /usr/bin: normal commands; modern distros often link /bin → /usr/bin.

·         /sbin, /usr/sbin: admin commands.

·         /usr/lib, /lib, /lib64: shared libraries.

·         /usr/local: software you install manually (won’t clash with distro).

·         /opt: optional, large third-party apps.

·         /var/log logs, /var/spool queues, /var/lib app state.


2) “Everything is a file”

Linux exposes many resources as files:

·         Regular files (text, binaries)

·         Directories (folders)

·         Device files in /dev:

o    Block devices (disks: /dev/sda, NVMe: /dev/nvme0n1)

o    Character devices (serial/tty)

·         Links:

o    Hard link = another name for the same inode

o    Symbolic link (soft link) = pointer to a path

·         Sockets (inter-process comms), FIFOs/pipes

·         Virtual files (/proc, /sys, /dev) reflect live kernel/device state

Check a file’s type:

file something

stat something


3) Inodes & blocks (how Linux tracks files)

·         A file’s data lives in blocks on disk; its metadata (owner, size, timestamps, permissions, where blocks are) lives in an inode.

·         A directory maps names → inode numbers.

·         Hard links point multiple names to the same inode; deleting one name doesn’t delete the data until the link count hits zero.

·         Symlinks point to a path (can break if target path disappears).

Try:

ls -li           # show inode numbers

ln file A        # hard link (same inode as file)

ln -s file B     # soft link (B → path "file")


4) Mounting: how disks appear as folders

·         A filesystem (on a partition, LVM LV, RAID, USB) becomes accessible when you mount it at a mount point (an existing empty directory).

lsblk                 # view block devices & mountpoints

sudo mount /dev/sdb1 /mnt

sudo umount /mnt

·         Autoload at boot via /etc/fstab (advanced, but good to know).


5) Common filesystem types

·         ext4 (default on many distros): stable, journaling.

·         XFS: great for large files and parallel I/O.

·         Btrfs: snapshots, checksums, subvolumes (advanced).

·         FAT32/exFAT: for USB sticks; max compatibility (limited features).

·         NTFS: Windows drives (Linux can read/write via ntfs-3g).

·         tmpfs: stored in RAM (fast; volatile).

·         procfs /proc, sysfs /sys: virtual info from kernel/devices.


6) Permissions & ownership (quick recap)

·         Owner (user), group, others each have r/w/x.

·         View:

ls -l

# -rwxr-x--- 1 alice devs  12K Mar  1 10:00 run.sh

·         Change:

chmod u+x run.sh          # add execute for owner

chmod 750 run.sh          # u=rwx,g=rx,o=-

chown alice:devs run.sh   # change owner/group (sudo)

Special bits (you’ll see these):

·         setuid (s on user): run with file owner’s privileges (e.g., /bin/passwd)

·         setgid (s on group): new files inherit directory’s group

·         sticky (t on dir): only file owner can delete inside shared dirs (e.g., /tmp)

chmod 4755 binfile   # setuid

chmod 2755 somedir   # setgid on directory

chmod 1777 /tmp      # sticky

(Understand conceptually for first year; use carefully.)


7) Disk usage & finding files

·         Space on filesystems:

df -h            # free/used per mountpoint

·         Which folders are big:

du -sh *         # sizes in current dir

du -h --max-depth=1 /

·         Find files:

find . -name "*.log" -size +100M

·         Search text:

grep -R "ERROR" /var/log


8) Partitions, GPT/MBR, LVM, RAID (just awareness)

·         Disks are split into partitions (MBR or GPT—modern/safer).

·         LVM (Logical Volume Manager) layers:

o    PV (physical volume) → VG (volume group) → LV (logical volume)

o    Lets you resize, snapshot, and manage storage flexibly.

·         RAID (software via mdadm): combine disks for redundancy/speed (e.g., RAID1 mirror, RAID5/6 parity). (Admin topics; know terms.)


9) Good places to put things

·         Your files: /home/<you>/...

·         Custom scripts for yourself: ~/bin (add to PATH)

·         Software you compile yourself (system-wide, admin): /usr/local

·         Temporary scratch: /tmp (can be cleared on reboot)

Avoid dropping random files in /, /bin, /sbin, /usr/bin—use /usr/local or your home.


10) Safety habits

·         Quote paths with spaces: "/home/you/My Files"

·         Use rm -ri (confirm) for deletions while learning.

·         Don’t sudo random commands from the internet.

·         Back up before formatting or changing partitions/mounts.

·         Be cautious in virtual filesystems: never try to “edit” /proc or /sys randomly.


11) Everyday commands you’ll actually use

pwd                       # where am I

ls -la                    # list with details (shows links/permissions)

tree -L 2                 # directory tree (sudo apt install tree)

file <name>               # guess type

stat <name>               # inode, perms, timestamps

 
df -h                     # disk free by filesystem

du -sh *                  # sizes of items in current dir

lsblk                     # block devices + mount points

mount | column -t         # what is mounted where

 
find . -name "*.py"       # locate files by pattern

grep -R "TODO" .          # search text across files


12) Mini-labs (hands-on, ~45–60 min)

Lab A: Tour the tree

cd /

sudo ls -ld bin sbin etc usr var home root tmp dev proc sys boot

tree -L 1 /usr

tree -L 1 /var

Write 3–4 lines describing what you saw in /usr vs /usr/local.

Lab B: Inodes & links

cd ~ && mkdir -p fs_lab && cd fs_lab

echo "hello" > a.txt

ln a.txt hardlink.txt

ln -s a.txt softlink.txt

ls -li

rm a.txt

cat hardlink.txt      # still works (same inode)

cat softlink.txt      # broken symlink (points to a path)

Lab C: Space detectives

df -h

du -h --max-depth=1 ~ | sort -h

Find your largest folder; clean safely (e.g., old caches).

Lab D: Mount a USB (read-only example)

1.   Plug a USB; run:

2. lsblk

3.   Identify partition (e.g., /dev/sdb1), then:

4. mkdir -p ~/usb && sudo mount -o ro /dev/sdb1 ~/usb

5. ls ~/usb | head

6. sudo umount ~/usb


13) Exam/Interview-ready bullets

·         Linux uses a single rooted tree /; devices and partitions are mounted into it.

·         FHS defines standard dirs: /etc, /var, /usr, /home, /tmp, /proc, /sys, /dev, /boot.

·         Everything is a file: regular, dir, link, device, socket, pipe; check via ls -l, file, stat.

·         Inode stores metadata + block pointers; dirs map name → inode.

·         Hard vs soft links: hard = same inode; soft = path reference.

·         Permissions: user/group/others with rwx; special bits (setuid, setgid, sticky).

·         Common FS types: ext4, XFS, Btrfs, FAT/exFAT, NTFS; proc/sys/tmpfs are virtual/in-RAM.


If you want, I can turn this into a printable 2-page cheat sheet or add diagram slides for classroom use.

 

Shell WSL or VirtualBox setup
Our Products & Services
  • Home
Connect with us
  • Contact us
  • +91 82955 87844
  • Rk6yadav@gmail.com

StudyLover - About us

The Best knowledge for Best people.

Copyright © StudyLover
Powered by Odoo - Create a free website