Showing posts with label Linux Training: Day-4. Show all posts
Showing posts with label Linux Training: Day-4. Show all posts

Day 4 – Linux Directory Structure & Critical Configuration Files

 Understanding the Foundation of Enterprise Linux Systems


Introduction

Day 4 focuses on one of the most important yet often underestimated topics in Linux administration — Directory Structure and Configuration File Locations.

In enterprise environments, knowing where files reside is essential for:

  • Troubleshooting production issues

  • Performing audits

  • Hardening servers

  • Managing services

  • Disaster recovery

  • Cloud deployments

Whether servers run on:

  • Red Hat Enterprise Linux

  • Ubuntu

  • Rocky Linux

Understanding the Linux file system hierarchy is foundational.


1️⃣ Linux Directory Structure – Navigating the Root (/)

Linux follows a standardized layout known as the Filesystem Hierarchy Standard (FHS).

At the top sits the root directory:

/

Everything in Linux begins from /.


2️⃣ Common Top-Level Directories (Enterprise View)

📁 /bin

Contains essential user binaries.

Example:

/bin/ls
/bin/cp

🏢 Enterprise Scenario

If /bin is corrupted, the system may not boot properly — this is why it's mounted early during boot.


📁 /sbin

System binaries used by administrators.

Example:

/sbin/reboot
/sbin/iptables

Used primarily by root or sudo users.


📁 /etc – The Heart of Configuration

This is one of the most critical directories.

Contains:

  • Network configs

  • User configs

  • Service configs

  • Security settings

🏢 Production Scenario

When troubleshooting SSH failure:

/etc/ssh/sshd_config

When checking user accounts:

/etc/passwd
/etc/shadow

📁 /home

User home directories.

Example:

/home/john

🏢 Enterprise Scenario

When an employee leaves:

  • Backup /home/user

  • Archive data

  • Remove access


📁 /root

Home directory for root user.

Highly restricted.


📁 /var

Variable data such as:

  • Logs

  • Mail

  • Spool files

  • Database files

🏢 Real-World Scenario: Disk Full Issue

Application down due to /var full:

du -sh /var/log/*

Log rotation required.


📁 /tmp

Temporary files.

Cleared during reboot (in most systems).

Security best practice:

  • No sensitive data stored here.


📁 /usr

User-installed applications and libraries.

Example:

/usr/bin
/usr/lib

📁 /opt

Optional software installations.

🏢 Enterprise Example

Custom enterprise applications installed under:

/opt/app

📁 /boot

Contains:

  • Kernel

  • Initramfs

  • Bootloader files

🏢 Scenario: Boot Failure

If /boot partition is full, system updates may fail.


📁 /dev

Device files.

Example:

/dev/sda
/dev/null

Used during disk management and troubleshooting.


📁 /proc

Virtual filesystem showing process & kernel info.

Example:

/proc/cpuinfo
/proc/meminfo

Used for performance diagnostics.


📁 /sys

Interface to kernel subsystems and hardware.

Important in advanced troubleshooting and performance tuning.


3️⃣ Important Configuration Files in Enterprise Linux


🔐 User & Authentication Files

FilePurpose
/etc/passwdUser account details
/etc/shadowEncrypted passwords
/etc/groupGroup details
/etc/gshadowGroup passwords

🏢 Scenario: Account Locked Investigation

Admin checks:

chage -l username

If password expired, update policy.


🌐 Network Configuration Files

On RHEL-based systems:

/etc/sysconfig/network-scripts/

On Ubuntu:

/etc/netplan/

🏢 Enterprise Scenario: Static IP Assignment

Production database server requires fixed IP:

  • Load balancer dependency

  • Firewall rules

  • Monitoring tools integration


🔥 Service Configuration

With systemd:

/etc/systemd/system/

Service files:

/usr/lib/systemd/system/

Example:

systemctl status nginx

🏢 Scenario: Custom Application Service

Enterprise app installed under /opt/app
Custom systemd service created:

/etc/systemd/system/app.service

Ensures service auto-start after reboot.


📜 Logging Configuration

Logs stored in:

/var/log/

Important logs:

  • /var/log/messages

  • /var/log/secure

  • /var/log/auth.log

  • /var/log/dmesg


🏢 Incident Example

Security team investigating failed SSH attempts:

grep "Failed password" /var/log/secure

Immediate brute-force detection.


🔒 SSH Configuration

/etc/ssh/sshd_config

Enterprise hardening includes:

  • Disable root login

  • Disable password authentication

  • Allow specific users

  • Change default port (optional)


🛡 Firewall Configuration

On RHEL:

firewalld

Config location:

/etc/firewalld/

🏢 Enterprise Firewall Example

Allow only:

  • Port 443 (HTTPS)

  • Port 22 (restricted IP)

Blocks all unnecessary ports.


Real-World Enterprise Troubleshooting Walkthrough

🚨 Case: Application Not Starting After Reboot

Steps:

  1. Check service:

    systemctl status app
    
  2. Check logs:

    journalctl -xe
    
  3. Verify config:

    /etc/app/config.yml
    
  4. Check disk space:

    df -h
    

Root cause:

  • /var partition full due to log accumulation.

Resolution:

  • Clean logs

  • Configure logrotate


Importance in Cloud & DevOps

In cloud environments:

  • Configuration stored in /etc

  • Logs under /var/log

  • Applications under /opt

  • Automation scripts in /usr/local/bin

Infrastructure automation tools rely on this predictable structure.

Example:

  • Ansible modifies /etc/ssh/sshd_config

  • Terraform deploys VM

  • CI/CD pipelines push app to /opt


Day 4 Recap

We covered:

  • Linux root directory structure

  • Purpose of key directories

  • Critical configuration file locations

  • Log management

  • Service configuration

  • Enterprise troubleshooting scenarios


Conclusion

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

Without knowing:

  • Where configurations live

  • Where logs are stored

  • Where services are defined

You cannot effectively manage production systems.

Day 4 builds the structural knowledge required for:

  • Advanced system administration

  • Cloud engineering

  • DevOps automation

  • Security hardening

  • Production troubleshooting