This is a very practical topic and it shows up a lot in a real sysadmin life. Filesystem Hierarchy Standard (FHS) in Linux is something every Linux admin should have knowledge of. I tend to forget things very easy. So, after brewing a fine single origin specialty coffee from Latin America I put this practical tutorial together.

Linux File Hierarchy (FHS) and Finding Files

The FHS defines where files should go in Linux, so all distros are consistent. Here’s the essential map you need to know as a sysadmin.

DirectoryPurpose
/Root of the filesystem, everything starts here.
/binEssential user commands (ls, cp, mv, rm, cat). Available even if /usr isn’t mounted.
/sbinEssential system binaries (reboot, fsck, ip, mount).
/bootKernel and bootloader files (vmlinuz, initramfs, grub/).
/devDevice files (/dev/sda, /dev/null, /dev/tty).
/etcSystem-wide configuration (/etc/passwd, /etc/ssh/sshd_config).
/homeUser home directories.
/lib, /lib64Shared libraries needed by binaries in /bin and /sbin.
/mediaMount point for removable media (USB, CD-ROM).
/mntTemporary mount point for filesystems.
/optOptional software (third-party apps, not from the distro).
/procVirtual filesystem, process and kernel info (/proc/cpuinfo).
/rootRoot user’s home directory.
/runRuntime data since boot (like PID files, sockets).
/srvData served by the system (e.g., websites /srv/www).
/sysKernel objects and hardware info.
/tmpTemporary files (cleaned at reboot).
/usrUser programs and libraries (non-essential at boot).
/varVariable data (logs in /var/log, spool, caches).

Finding Files and Commands in Linux

You can locate commands. The below shows the path of a command in $PATH.

which ls
# /bin/ls

type tells you if it’s an alias, shell builtin, or binary:

type ls
ls is aliased to `ls --color=auto'

whereis gives binary + manpage location:

whereis bash
bash: /usr/bin/bash /usr/share/man/man1/bash.1.gz /usr/share/info/bash.info.gz

Locate files

Find the SSH config file under /etc.

find /etc -name sshd_config

Uses a prebuilt database (fast, but may need updatedb):

locate passwd

Find log files larger than 100 MB:

find /var/log -type f -size +100M

Identify which package provides a file

On Debian-based:

dpkg -S /bin/ls

On RedHat based:

rpm -qf /bin/ls

Linux Sysadmin Rule of Thumb:

  • Config files → /etc
  • Logs → /var/log
  • Binaries → /bin, /usr/bin, /sbin, /usr/sbin
  • User data → /home, /root
  • Temporary → /tmp, /var/tmp
  • Device nodes → /dev

I also put together the below table for the most used commands to find things in the Filesystem Hierarchy in Linux.

CommandScopeChecks Real FS?Fast?Use Case
findFiles anywhere✅ Yes❌ SlowerDeep, real-time search with conditions (size, time, perms)
locateFiles anywhere❌ Uses DB✅ Very fastQuick search, less accurate if DB not updated
whichExecutables in $PATH✅ Yes✅ FastFind which binary runs when typing command
whereisExecutable + manpages✅ Yes✅ FastFind binary + man page
typeCommands✅ Shell check✅ FastIdentify alias, builtin, function, or binary

It is important to know the Filesystem Hierarchy Standard (FHS) in Linux, including the file locations and directory classifications. Let me know what you think.

Leave a comment

Your email address will not be published. Required fields are marked *