Day 4 – Linux Directory Structure & Critical Configuration Files

Understanding the Foundation of Enterprise Linux Systems

Linux administrators spend a lot of time working with files, directories, configuration files, logs, and services.

Understanding where Linux stores important files makes troubleshooting much easier.

This knowledge is useful for:

  • Linux Administration

  • Production Troubleshooting

  • Cloud Administration

  • DevOps

  • Security Hardening

  • Disaster Recovery

This applies to Linux distributions such as RHEL, Rocky Linux, and Ubuntu.


1. Linux Directory Structure

Linux uses a standard filesystem hierarchy.

The top-level directory is:

/

This is called the root directory.

All other directories exist below /.

For example:

/
├── bin
├── boot
├── dev
├── etc
├── home
├── opt
├── proc
├── root
├── sys
├── tmp
├── usr
└── var

Think of / as the main building and the directories below it as different rooms.


2. Important Linux Directories

/bin – Essential Commands

Contains essential commands used by Linux users and scripts.

Examples:

/bin/ls
/bin/cp
/bin/mv

These commands are required for basic system operation.

Note: On newer RHEL and Rocky Linux releases, /bin may be a symbolic link to /usr/bin.


/sbin – System Administration Commands

Contains system administration utilities.

Examples:

/sbin/reboot
/sbin/shutdown

These commands are generally used by administrators or privileged processes.

On modern Linux systems, /sbin may also be linked to /usr/sbin.


3. /etc – Important Configuration Files

/etc is one of the most important directories for a Linux administrator.

It contains system and application configuration files.

Examples:

/etc/passwd
/etc/shadow
/etc/group
/etc/ssh/sshd_config
/etc/hosts
/etc/fstab

Enterprise Example

If users cannot connect to a server through SSH, an administrator may check:

/etc/ssh/sshd_config

After making configuration changes, always validate and restart/reload the service carefully.


4. /home – User Home Directories

Normal users generally have their personal directories under /home.

Example:

/home/john
/home/admin
/home/user1

User files, scripts, and personal configuration are commonly stored here.

Enterprise Example

When an employee leaves an organization:

  1. Backup required data.

  2. Archive the user's files.

  3. Remove or disable access according to company policy.


5. /root – Root User's Home Directory

/root is the home directory of the root user.

Example:

/root
/root/.bashrc
/root/.ssh/

It is different from /.

  • / = filesystem root

  • /root = root user's home directory


6. /var – Variable Data

/var contains data that changes frequently.

Common examples include:

/var/log
/var/tmp
/var/spool

The /var/log directory is especially important for administrators.

Enterprise Scenario – Disk Full

An application may stop working because a filesystem becomes full.

Check:

df -h

Then investigate large directories:

du -sh /var/log/*

Log rotation and appropriate cleanup can help prevent this problem.


7. /tmp – Temporary Files

/tmp is used for temporary files.

Applications and users may create temporary data here.

Example:

/tmp

Do not store important or sensitive information in /tmp unless there is a specific controlled requirement.

The exact cleanup behavior of /tmp depends on the Linux distribution and configuration.


8. /usr – Applications and Libraries

/usr contains many standard applications, commands, libraries, and other system resources.

Examples:

/usr/bin
/usr/sbin
/usr/lib
/usr/share

On modern Linux systems, many directories traditionally associated with the root filesystem are integrated with /usr.


9. /opt – Optional or Custom Applications

/opt is commonly used for optional or third-party software.

Example:

/opt/app
/opt/oracle
/opt/myapplication

Enterprise Example

A company application may be installed as:

/opt/app

Its configuration could be:

/opt/app/config/

and application logs might be stored under:

/opt/app/logs/

The exact layout depends on the application.


10. /boot – Boot Files

/boot contains files required during system startup.

Examples include:

Kernel
Initramfs
Bootloader configuration

Check the filesystem:

df -h /boot

Enterprise Scenario

If /boot becomes full, a kernel update may fail.

Therefore, administrators should monitor /boot on systems where it is a separate filesystem.


11. /dev – Device Files

Linux represents many hardware and virtual devices as files under /dev.

Examples:

/dev/sda
/dev/null
/dev/random

For example:

ls -l /dev/sda

Disk and device troubleshooting frequently involves /dev.


12. /proc – Process and Kernel Information

/proc is a virtual filesystem.

It provides information about running processes and the Linux kernel.

Examples:

/proc/cpuinfo
/proc/meminfo
/proc/loadavg

Useful commands:

cat /proc/cpuinfo
cat /proc/meminfo

Enterprise Use

Administrators can use /proc when investigating:

  • CPU information

  • Memory usage

  • Running processes

  • Kernel information

  • System performance


13. /sys – Kernel and Hardware Information

/sys is another virtual filesystem.

It provides an interface to information about:

  • Hardware

  • Devices

  • Kernel subsystems

  • Drivers

It is commonly used during advanced Linux troubleshooting.


14. Important Configuration Files

Knowing important configuration files is a key Linux administration skill.

User and Authentication Files

FilePurpose
/etc/passwdUser account information
/etc/shadowPassword and account aging information
/etc/groupGroup information
/etc/gshadowGroup security information

For example:

cat /etc/passwd

To check password aging:

chage -l username

15. Network Configuration

Network configuration differs between Linux distributions and releases.

RHEL/Rocky Linux

Modern RHEL-based systems commonly use NetworkManager.

Useful command:

nmcli connection show

Older RHEL systems may have configuration files under:

/etc/sysconfig/network-scripts/

Ubuntu

Ubuntu systems commonly use:

/etc/netplan/

Example:

/etc/netplan/01-netcfg.yaml

Enterprise Example

A production database server may require a static IP because:

  • Firewall rules depend on the IP

  • Monitoring uses the IP

  • Applications connect to a fixed address

  • Load balancers may depend on the address


16. Systemd Service Configuration

Linux systems using systemd store service definitions in different locations.

Common locations include:

/etc/systemd/system/
/usr/lib/systemd/system/

For example:

/etc/systemd/system/app.service

Check a service:

systemctl status nginx

After creating or modifying a unit file:

systemctl daemon-reload

Then start the service:

systemctl start app

Enable it during boot:

systemctl enable app

17. Linux Logs

Most system logs are stored under:

/var/log/

Examples can include:

/var/log/messages
/var/log/secure
/var/log/auth.log

The exact log files depend on the Linux distribution and logging configuration.

On systemd systems, journalctl is also extremely important.

Example:

journalctl -xe

Check logs for a specific service:

journalctl -u nginx

18. SSH Configuration

SSH configuration is normally located at:

/etc/ssh/sshd_config

Check the SSH service:

systemctl status sshd

Before restarting SSH after a configuration change, validate the configuration:

sshd -t

Enterprise SSH hardening may include:

  • Disabling direct root login

  • Using key-based authentication

  • Restricting permitted users

  • Disabling unnecessary authentication methods

Changes should always follow the organization's security policy.


19. Firewall Configuration

RHEL and Rocky Linux commonly use firewalld.

Check the service:

systemctl status firewalld

Check firewall rules:

firewall-cmd --list-all

Configuration data may be stored under:

/etc/firewalld/

Enterprise Example

A production server may allow:

443 – HTTPS
22  – SSH from approved networks

while blocking unnecessary access.


20. Real-World Troubleshooting Example

🚨 Application Not Starting After Reboot

Suppose an application was working before a reboot but does not start afterward.

An administrator can follow a structured approach.

Step 1 – Check the Service

systemctl status app

Step 2 – Check Service Logs

journalctl -u app

Step 3 – Check Application Configuration

For example:

/etc/app/config.yml

Step 4 – Check Disk Space

df -h

Step 5 – Check /var

du -sh /var/*

Suppose the investigation shows that /var is full because application logs have accumulated.

Root Cause

/var filesystem full
        ↓
Application cannot write logs/temp files
        ↓
Application fails to start

Resolution

  • Identify unnecessary files.

  • Follow the organization's log-retention policy.

  • Configure log rotation.

  • Monitor filesystem utilization.


21. Linux Directory Structure in Cloud & DevOps

Linux directory knowledge is also important in cloud and DevOps environments.

For example:

Ansible

Ansible may modify:

/etc/ssh/sshd_config

Application Deployment

A custom application may be deployed to:

/opt/app

Logs

Application and system logs may be stored under:

/var/log/

Scripts

Local administrative scripts are often placed under:

/usr/local/bin/

Terraform

Terraform can provision the virtual machine, while configuration management tools such as Ansible can configure the operating system.


22. Quick Reference Table

DirectoryMain Purpose
/Root of the filesystem
/binEssential user commands
/sbinSystem administration commands
/etcConfiguration files
/homeNormal user home directories
/rootRoot user's home
/varVariable data and logs
/tmpTemporary files
/usrApplications, libraries and shared resources
/optOptional/third-party applications
/bootKernel and boot files
/devDevice files
/procProcess and kernel information
/sysKernel and hardware interface

23. Day 4 – Practical Commands

Try these commands on your Linux lab server:

pwd
ls /
ls -l /etc
df -h
du -sh /var/log/*
cat /etc/passwd
cat /etc/group
cat /etc/hosts
systemctl status sshd
journalctl -u sshd
free -h
cat /proc/meminfo
cat /proc/cpuinfo

Day 4 Recap

Today we learned:

  • Linux filesystem hierarchy

  • Purpose of important directories

  • Important configuration files

  • User and authentication files

  • Network configuration

  • Systemd service configuration

  • Linux logging

  • SSH configuration

  • Firewall configuration

  • Basic production troubleshooting

  • Linux directory structure in Cloud and DevOps


Conclusion

Understanding Linux directory structure is like understanding the blueprint of a building.

When troubleshooting a production server, you should quickly know:

Configuration → /etc
Logs          → /var/log
Users         → /home
Root home     → /root
Applications  → /opt
Boot files    → /boot
Devices       → /dev
Kernel info   → /proc and /sys


No comments:

Post a Comment