Back to blog
Linux

Linux File Systems and Storage: Permissions, Links, and Disk Analysis

Introduction

After working with processes and system behavior, the next step is understanding how Linux handles files, storage, and permissions. In this post, I focus on a few key concepts: how permissions actually control access, the difference between symbolic and hard links, how archiving works, and how to analyze disk usage in a practical way.

File Permissions in Practice

Instead of just setting permissions, I tested what they actually do.

chmod 754 permissions.txt

This means the owner has read, write, and execute access; the group has read and execute; and others have read only. The important part is not the number, but the behavior.

When I switched to another user and tried to modify the file:

echo "test" >> permissions.txt

It failed with a Permission denied error. Permissions are enforced strictly by the OS. Only the owner had write access, so even though another user could read the file, they could not modify it. This is the foundation of Linux security.

Symbolic vs Hard Links

This is one of the most important file system concepts. I created both a symbolic link and a hard link, then modified the original file and checked both.

Both links showed the updated content after changes to the original, but the difference is in how they work internally. A symbolic link, or soft link, points to the file path. If the original file is deleted, the link breaks. A hard link points to the same underlying data, called an inode. Even if the original file is deleted, the data still exists through the hard link.

In short, hard links are the actual data reference. Symbolic links are just shortcuts.

Archiving and Compression

I created a directory with multiple files, then archived it, compressed it, and extracted it back.

tar -cvf archive.tar archive_lab
gzip archive.tar

gunzip archive.tar.gz
tar -xvf archive.tar

tar groups files together while preserving structure. gzip reduces size. Extraction restores the exact original layout. Together, archiving and compression are used constantly for backups and file transfers.

Disk Usage Analysis

To understand where space is being used:

du -h ~ | sort -h

This shows disk usage sorted from smallest to largest. To find the single largest file:

find ~ -type f -exec du -h {} + | sort -rh | head -n 1

du shows usage, sort helps prioritize, and find locates specific files. This combination is useful when diagnosing storage issues.

Automating with a Script

Instead of running commands manually, I created a script that takes a directory as input, counts files and subdirectories, lists large files, and creates a timestamped archive.

DIR=$1

find $DIR -type f | wc -l
find $DIR -type d | wc -l
find $DIR -type f -size +1M

tar -cvf "${DIR}_$(date +%Y%m%d%H%M%S).tar" "$DIR"

This shows how Linux commands can be combined into automation. Small scripts replace repetitive tasks, and this is how real system tools are built.

Why This Matters

These concepts come up constantly in real systems. Permissions control security and access. Links affect how data is stored and referenced. Archiving is used for backups and deployment. Disk analysis helps troubleshoot storage issues. Scripts turn manual work into automation.

Conclusion

This builds on earlier system concepts by focusing on how Linux handles files and storage. The key difference here is not just running commands, but understanding what they actually do behind the scenes. Permissions enforce access, links define how data is referenced, and tools like du, tar, and scripting make it possible to manage systems efficiently.