πΎ Linux/Unix: Storage, Archiving & Compression β Tools, Mounting, Disk Space & Compression Explained
π§² Introduction β Master Storage & Space Management in Linux
Linux and Unix systems offer powerful tools for managing disks, mounting partitions, tracking disk usage, and compressing files for archiving or transmission. Whether you’re a developer, sysadmin, or power user, understanding these commands is essential for effective space management and backup strategies.
π― In this guide, youβll learn:
- How to inspect drives and partitions
- How to mount and unmount storage volumes
- How to track file and directory disk usage
- How to compress and extract files using tar,gzip,zip, and more
π Topics Covered
| π΅ Subtopic | π Description | 
|---|---|
| Storage Tools ( lsblk,blkid, etc.) | Identify disks, partitions, and their properties | 
| Mounting ( mount,umount) | Attach or detach filesystems to directories | 
| Disk Usage ( df,du) | Check space availability on filesystems and usage by files/directories | 
| Compression Tools ( tar,gzip, etc.) | Archive, compress, or extract files with popular formats | 
π΅ Linux/Unix: Storage Tools (lsblk, blkid, fdisk, parted)
πΉ lsblk β List Block Devices
lsblk
β Shows all connected disks and partitions in a tree-like format.
πΉ blkid β View Partition UUIDs & File Systems
blkid
πΉ fdisk β Partition Table Editor (MBR)
sudo fdisk /dev/sda
β Useful for viewing and editing MBR partition tables.
πΉ parted β Manage GPT & Large Drives
sudo parted /dev/sda
π΅ Linux/Unix: Mounting (mount, umount)
πΉ mount β Mount a File System
sudo mount /dev/sdb1 /mnt
β
 Attaches the partition /dev/sdb1 to /mnt.
πΉ umount β Unmount a Mounted Volume
sudo umount /mnt
πΉ View All Mounts
mount | column -t
πΉ Create and Mount ISO
sudo mount -o loop file.iso /mnt
π΅ Linux/Unix: Disk Usage (df, du)
πΉ df β View Filesystem Disk Space
df -h
β Shows space usage on each mounted partition in human-readable format.
πΉ du β Estimate File/Folder Space
du -sh /home/user/*
β Useful for identifying large directories.
π΅ Linux/Unix: Compression Tools (tar, gzip, zip, bzip2, xz, 7z)
πΉ tar β Archive Multiple Files
tar -cvf archive.tar file1 file2
tar -xvf archive.tar
πΉ gzip / gunzip β Compress Single File
gzip file.txt
gunzip file.txt.gz
πΉ zip / unzip β Portable Compression
zip archive.zip file1 file2
unzip archive.zip
πΉ bzip2 / xz β Better Compression Ratios
bzip2 file.txt
xz file.txt
πΉ 7z β High-Ratio Archiving (needs p7zip package)
7z a archive.7z file1 file2
7z x archive.7z
π Summary β Recap & Next Steps
Linux provides an efficient suite of commands for analyzing storage, managing disk usage, and archiving data. These tools are essential for system maintenance, backups, and keeping your file systems optimized and organized.
π Key Takeaways:
- Use lsblkandblkidto identify drives and partitions.
- Use mountandumountto attach or detach volumes.
- Monitor space with dfand inspect heavy files withdu.
- Compress and extract files using tar,gzip,zip,xz, and7z.
βοΈ Real-World Applications:
- Back up a project directory with tar.gz
- Mount external drives or ISO files
- Analyze disk usage to prevent system overload
- Share files efficiently using compressed archives
β Frequently Asked Questions
β What is the difference between df and du?
β
 df shows disk space for mounted filesystems. du shows space used by individual files or directories.
β Which compression tool gives the best compression?
β
 xz and 7z often give higher compression than gzip or zip, but may take longer.
β How can I mount an ISO file in Linux?
β
 Use:
sudo mount -o loop file.iso /mnt
β Can I extract .zip files without a GUI?
β
 Yes, use the unzip command in the terminal.
β Is fdisk safe to use on a running system?
β
 Itβs safe for viewing partitions, but avoid changes unless you understand the risks.
Share Now :
