Exploring the Linux File Hierarchy: A Beginner's Guide
Last Blog Review →
In the last blog, we learned on how to create a group and add multiple user’s in the group at once, which typically helps user’s working in the same department as they can be added in the same group with same set of permissions provided to each one of them.
Linux File Hierarchy System →
In Linux, everything is stored as a file including hardware program. Every file is stored in a place called as Directory (folder in terms of Windows OS). So, the files are stored in a form of tree like structure in a Directory and this is called as “Linux File Hierarchy System“.
Linux uses single rooted inverted tree like structure.
The root directory is represented by “/” forward slash, which represents the highest level of directory in Linux OS.
The base of the “Linux File System Hierarchy” starts with Root directory.
Some of the Important Directory you must know →
/root →
It is the home directory of the root user also called as Superuser.
/bin →
It is called as “User Binaries“.
It contains binary executables.
Common Linux command you need to use in single-user modes are stored under this directory.
Commands used by all the user’s of the system are located here.
/sbin →
It is called as “System Binaries”.
Just like /bin, /sbin also contains the “Binary executables”.
The commands located under this directory are used by “System administrator” used for system maintenance purpose.
Ex. iptables, reboot, fdisk, ifconfig, swapon.
Question →
Write a bash script to delete the files in a directory that are older than 30 days ?
\=>
- Deleting using find with exec.
#!/bin/bash
dir = "/yourdirectorypath"
find "$dir" -type f -mtime +30 -exec rm -f {} \;
echo "Hooola, files older (modified) more than 30 days are deleted"
- Deleting using find and delete
#!/bin/bash
dir = "/yourdirectorypath"
find "$dir" -type f -mtime +30 -delete
Conclusion →
In this blog, we understood what is File System Hierarchy in Linux, how the Tree like structure working in Linux, how the File system Hierarchy starts with “/” and base of the File System Hierarchy. Also, some important directories in the Linux File System Hierarchy which plays the important role in the learning Linux.
Subscribe to my newsletter
Read articles from Mihir Suratwala directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Mihir Suratwala
Mihir Suratwala
Hi, How are you !! Hope you doing good.... I got introduced to Cloud initially. As I went ahead learning what is cloud and how it works, then got to know a field which is DevOps that makes Cloud model more effective. So, as I started working & got good experience on AWS. I have been learning the DevOps tool and technologies on how to use it with the Cloud, which will give me good understanding on how Cloud and DevOps go hand in hand to deploy my applications.