If you are new to Linux, the first thing that feels strange is the folder layout. There is no C:\ drive. Everything starts from a single root directory: /.

This is Part 1 of a series where I walk through the Linux filesystem one directory at a time. In this post we cover the root directory and /etc.

The Filesystem Hierarchy Standard (FHS)

Most Linux distributions follow the Filesystem Hierarchy Standard (FHS), a convention that defines which kind of file lives where. Once you learn it, every Linux server feels familiar.

See it yourself

ls / 
bin boot dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var 

Your output may differ slightly depending on the distribution.

Quick map of /

Directory Purpose
/bin Essential user commands (ls, cp, cat)
/sbin System administration commands
/etc System-wide configuration files
/home Personal folders for regular users
/root Home folder of the root user
/var Variable data: logs, caches, mail
/tmp Temporary files
/usr Installed programs and libraries
/dev Device files
/proc Virtual files with process and kernel information
/boot Bootloader and kernel files
/opt Optional third-party software

On many modern distributions, /bin, /sbin, and /lib are symbolic links to the matching folders inside /usr. You can check with:

ls -ld /bin /sbin /lib 

We will cover each of these in later parts.

Deep dive: /etc

/etc holds system-wide configuration files. Most of them are plain text, so you can read them with cat or less and edit them with a text editor.

ls /etc | head -n 10 

Important files in /etc

File What it does
/etc/passwd List of user accounts
/etc/group List of groups
/etc/hosts Local hostname to IP mapping
/etc/resolv.conf DNS resolver settings
/etc/fstab Filesystems mounted at boot
/etc/hostname The name of the machine
/etc/ssh/sshd_config SSH server settings
/etc/os-release Distribution name and version

Example 1: Read the hosts file

cat /etc/hosts 
127.0.0.1 localhost 127.0.1.1 my-machine 

You can map a name to an IP here, which is handy for local testing:

echo "192.168.1.50 myserver.local" | sudo tee -a /etc/hosts 

Example 2: Check your Linux distribution

cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.4 LTS" NAME="Ubuntu" VERSION_ID="22.04" 

Example 3: See user accounts

cut -d: -f1 /etc/passwd | head -n 5 
root daemon bin sys sync 

Each line in /etc/passwd has fields separated by colons: username, password placeholder, user ID, group ID, description, home directory, and shell. Despite the name, real password hashes are stored in /etc/shadow, which only root can read.

Example 4: Check DNS settings

cat /etc/resolv.conf 

This shows which DNS servers your system uses. It connects nicely to the dig and nslookup posts in my Linux Networking Commands series.

Good practice when editing /etc

  1. Back up first: sudo cp /etc/hosts /etc/hosts.bak
  2. Use sudo only when you really need it.
  3. Validate the config when the tool supports it, for example sudo sshd -t for SSH.
  4. Never delete files in /etc unless you know exactly what they do.

Summary

  • / is the top of the whole directory tree.
  • Each top-level directory has a specific purpose defined by the FHS.
  • /etc stores system configuration, mostly as editable text files.
  • Always back up before you change anything.

Next in the series: Part 2, /home, /root, and /tmp.

Did I miss anything or get something wrong? Leave a comment below.