🐧💻 Linux Directories & Config Files Demystified - What Every DevOps Should Know
Ever wondered what all those directories and config files in Linux actually do? This comprehensive guide breaks down the Linux filesystem hierarchy, explaining every important directory, subdirectory, and configuration file—along with their purposes and functions. Whether you're a Linux newbie or a seasoned sysadmin, this post will help you master the Linux filesystem!
🐧💻 Linux Directories & Config Files Demystified - What Every DevOps Should Know
📂 Linux Directory Structure and Important Configuration Files
Linux Directory Structure (Filesystem Hierarchy Standard)
Root Directory (/)
The base of the filesystem hierarchy. All other directories and files are contained within it.
Essential System Directories
- /bin - Essential command binaries
- Contains fundamental user command binaries (like
ls,cp,mv,rm, etc.) - Needed for single-user mode and system repair
- Contains fundamental user command binaries (like
- /sbin - System binaries
- Contains binaries for system administration (like
fdisk,fsck,ifconfig, etc.) - Typically requires root privileges
- Contains binaries for system administration (like
- /boot - Boot loader files
- Contains files needed to boot the system (kernel, initramfs, GRUB files)
- Important files:
vmlinuz- The Linux kernelinitrd.img- Initial RAM diskgrub/- GRUB bootloader configuration
- /dev - Device files
- Contains special device files that represent hardware components
- Examples:
/dev/sda(first hard disk),/dev/tty(terminals),/dev/null(null device)
- /etc - System configuration files
- Contains host-specific system-wide configuration files
- Most important configuration directory (covered in detail below)
- /home - User home directories
- Contains personal directories for each user
- Each user has their own subdirectory (e.g.,
/home/username)
- /lib - Essential shared libraries
- Contains libraries needed by binaries in
/binand/sbin /lib32and/lib64for 32-bit and 64-bit libraries respectively
- Contains libraries needed by binaries in
- /media - Removable media mount points
- Automatic mount points for removable devices (USB drives, CDs, etc.)
- /mnt - Temporary mount points
- Traditionally used for temporarily mounting filesystems
- /opt - Optional application software
- Contains add-on applications from third parties
- /proc - Process and kernel information
- Virtual filesystem providing process and system information
- Important files:
/proc/cpuinfo- CPU information/proc/meminfo- Memory information/proc/mounts- Mounted filesystems
- /root - Root user’s home directory
- Home directory for the root user (not in
/homefor recovery purposes)
- Home directory for the root user (not in
- /run - Runtime variable data
- Contains system information since last boot (process IDs, lock files, etc.)
- /srv - Service data
- Contains data for services provided by the system (web, FTP, etc.)
- /tmp - Temporary files
- Stores temporary files that may be deleted between reboots
- /usr - User utilities and applications
- Secondary hierarchy containing most user utilities and applications
- Important subdirectories:
/usr/bin- Non-essential command binaries/usr/sbin- Non-essential system binaries/usr/lib- Libraries for binaries in/usr/binand/usr/sbin/usr/local- Locally installed software/usr/share- Architecture-independent data
- /var - Variable data files
- Contains files that change frequently (logs, spool files, caches)
- Important subdirectories:
/var/log- System log files/var/cache- Application cache data/var/spool- Queued files (print jobs, mail, etc.)/var/www- Default web server root (on some distributions)
Important Configuration Files
System Configuration Files (/etc)
- /etc/passwd - User account information
- Contains user account details (username, UID, GID, home directory, shell)
- Format:
username:x:UID:GID:comment:home_dir:shell
- /etc/shadow - Secure user account information
- Contains encrypted passwords and password aging information
- Only readable by root
- /etc/group - Group information
- Defines system groups and their members
- /etc/fstab - Filesystem table
- Defines how disk partitions and other storage should be mounted
- Used during system boot to mount filesystems
- /etc/hosts - Static hostname resolution
- Maps hostnames to IP addresses before DNS
- Can override DNS lookups
- /etc/resolv.conf - DNS resolver configuration
- Configures DNS nameservers and search domains
- Often managed dynamically by network services
- /etc/hostname or /etc/hostname - System hostname
- Contains the system’s hostname
- /etc/network/interfaces or /etc/sysconfig/network-scripts/ - Network configuration
- Configures network interfaces (Debian/Ubuntu vs RHEL/CentOS)
- /etc/ssh/sshd_config - SSH server configuration
- Configures the OpenSSH server daemon
- Controls authentication methods, ports, etc.
- /etc/sudoers - Sudo configuration
- Defines who can run what commands as root via sudo
- Should always be edited with
visudo
- /etc/crontab - System-wide cron jobs
- Defines scheduled tasks run by the system
- User-specific crontabs are in
/var/spool/cron/
- /etc/apt/sources.list (Debian/Ubuntu) or /etc/yum.repos.d/ (RHEL/CentOS) - Package repositories
- Defines software repositories for package management
- /etc/ld.so.conf - Shared library configuration
- Lists directories to be included in the library search path
- /etc/sysctl.conf - Kernel parameters
- Configures kernel parameters at boot time
- /etc/modprobe.d/ - Kernel module configuration
- Configuration files for kernel modules
- /etc/security/limits.conf - User process limits
- Sets resource limits (number of processes, file handles, etc.)
- /etc/default/grub - GRUB bootloader configuration
- Main configuration file for GRUB bootloader
- Changes require running
update-grub(Debian) orgrub2-mkconfig(RHEL)
Service-Specific Configuration Files
- /etc/nginx/ - Nginx web server configuration
nginx.conf- Main configuration filesites-available/- Available website configurationssites-enabled/- Enabled website configurations
- /etc/apache2/ (Debian) or /etc/httpd/ (RHEL) - Apache web server configuration
apache2.conf/httpd.conf- Main configuration filesites-available/andsites-enabled/(Debian)conf.d/- Additional configuration files
- /etc/mysql/ - MySQL configuration
my.cnf- Main MySQL configuration file
- /etc/postgresql/ - PostgreSQL configuration
- Contains configuration for PostgreSQL database server
- /etc/php/ - PHP configuration
- Contains PHP configuration files for different versions
Log Files (/var/log)
- /var/log/syslog or /var/log/messages - General system messages
- Primary system log file (name varies by distribution)
- /var/log/auth.log - Authentication logs
- Records authentication events (logins, sudo usage, etc.)
- /var/log/kern.log - Kernel logs
- Kernel-specific messages and errors
- /var/log/dmesg - Kernel ring buffer
- Contains messages from the kernel during boot
- /var/log/apt/ or /var/log/yum.log - Package manager logs
- Records package installation and updates
- /var/log/nginx/ or /var/log/apache2/ - Web server logs
- Contains access and error logs for web servers
- /var/log/mysql/ - MySQL logs
- Contains error logs and slow query logs for MySQL
User Configuration Files (in home directories)
- ~/.bashrc - Bash shell configuration
- Executed for interactive non-login shells
- Contains aliases, functions, and shell options
- ~/.bash_profile or ~/.profile - Login shell configuration
- Executed for login shells
- Typically sets environment variables and paths
- ~/.ssh/ - SSH client configuration
config- SSH client configurationknown_hosts- Known SSH hostsauthorized_keys- Keys allowed for authentication
- ~/.gitconfig - Git configuration
- User-specific Git settings
- ~/.vimrc - Vim configuration
- Configuration for the Vim text editor
- ~/.config/ - Application configuration
- Modern location for user-specific application configurations
Special Files
- /etc/motd - Message of the day
- Displayed after successful login
- /etc/issue - Pre-login message
- Displayed before the login prompt
- /etc/os-release - OS identification
- Contains operating system identification data
This post is licensed under CC BY 4.0 by the author.