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
└── varThink 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/mvThese commands are required for basic system operation.
Note: On newer RHEL and Rocky Linux releases,
/binmay be a symbolic link to/usr/bin.
/sbin – System Administration Commands
Contains system administration utilities.
Examples:
/sbin/reboot
/sbin/shutdownThese commands are generally used by administrators or privileged processes.
On modern Linux systems,
/sbinmay 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/fstabEnterprise Example
If users cannot connect to a server through SSH, an administrator may check:
/etc/ssh/sshd_configAfter 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/user1User files, scripts, and personal configuration are commonly stored here.
Enterprise Example
When an employee leaves an organization:
Backup required data.
Archive the user's files.
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/spoolThe /var/log directory is especially important for administrators.
Enterprise Scenario – Disk Full
An application may stop working because a filesystem becomes full.
Check:
df -hThen 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:
/tmpDo 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/shareOn 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/myapplicationEnterprise Example
A company application may be installed as:
/opt/appIts 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 configurationCheck the filesystem:
df -h /bootEnterprise 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/randomFor example:
ls -l /dev/sdaDisk 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/loadavgUseful commands:
cat /proc/cpuinfo
cat /proc/meminfoEnterprise 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
| File | Purpose |
|---|---|
/etc/passwd | User account information |
/etc/shadow | Password and account aging information |
/etc/group | Group information |
/etc/gshadow | Group security information |
For example:
cat /etc/passwdTo check password aging:
chage -l username15. Network Configuration
Network configuration differs between Linux distributions and releases.
RHEL/Rocky Linux
Modern RHEL-based systems commonly use NetworkManager.
Useful command:
nmcli connection showOlder RHEL systems may have configuration files under:
/etc/sysconfig/network-scripts/Ubuntu
Ubuntu systems commonly use:
/etc/netplan/Example:
/etc/netplan/01-netcfg.yamlEnterprise 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.serviceCheck a service:
systemctl status nginxAfter creating or modifying a unit file:
systemctl daemon-reloadThen start the service:
systemctl start appEnable it during boot:
systemctl enable app17. Linux Logs
Most system logs are stored under:
/var/log/Examples can include:
/var/log/messages
/var/log/secure
/var/log/auth.logThe exact log files depend on the Linux distribution and logging configuration.
On systemd systems, journalctl is also extremely important.
Example:
journalctl -xeCheck logs for a specific service:
journalctl -u nginx18. SSH Configuration
SSH configuration is normally located at:
/etc/ssh/sshd_configCheck the SSH service:
systemctl status sshdBefore restarting SSH after a configuration change, validate the configuration:
sshd -tEnterprise 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 firewalldCheck firewall rules:
firewall-cmd --list-allConfiguration data may be stored under:
/etc/firewalld/Enterprise Example
A production server may allow:
443 – HTTPS
22 – SSH from approved networkswhile 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 appStep 2 – Check Service Logs
journalctl -u appStep 3 – Check Application Configuration
For example:
/etc/app/config.ymlStep 4 – Check Disk Space
df -hStep 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 startResolution
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_configApplication Deployment
A custom application may be deployed to:
/opt/appLogs
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
| Directory | Main Purpose |
|---|---|
/ | Root of the filesystem |
/bin | Essential user commands |
/sbin | System administration commands |
/etc | Configuration files |
/home | Normal user home directories |
/root | Root user's home |
/var | Variable data and logs |
/tmp | Temporary files |
/usr | Applications, libraries and shared resources |
/opt | Optional/third-party applications |
/boot | Kernel and boot files |
/dev | Device files |
/proc | Process and kernel information |
/sys | Kernel and hardware interface |
23. Day 4 – Practical Commands
Try these commands on your Linux lab server:
pwdls /ls -l /etcdf -hdu -sh /var/log/*cat /etc/passwdcat /etc/groupcat /etc/hostssystemctl status sshdjournalctl -u sshdfree -hcat /proc/meminfocat /proc/cpuinfoDay 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