Understanding Linux File System Hierarchy and Configuration

The Linux file system hierarchy standard (FHS) defines the main directories and their contents.

  • /bin: Essential user command binaries.
  • /boot: Boot loader files and the Linux kernel.
  • /dev: Device files.
  • /etc: System-wide configuration files.
  • /home: User home directories.
  • /lib: Essential shared libraries and kernel modules.
  • /lib64: Essential 64-bit shared libraries and kernel modules.
  • /media: Mount point for removable media.
  • /mnt: Temporary mount point for file systems.
  • /opt: Optional application software packages.
  • /proc: Virtual file system containing process and kernel information (lost on reboot).
  • /root: Home directory for the root user.
  • /run: Runtime variable data.
  • /sbin: Essential system binaries.
  • /srv: Data for services provided by the system.
  • /sys: Virtual file system providing information about devices.
  • /tmp: Temporary files (often cleared on reboot).
  • /usr: User applications and data.
  • /var: Variable datta files (e.g., logs).

Mounting File Systems

To mount a storage device, such as a CD-ROM drive, perform the following steps:

  1. Ensure the device is accessible: For a CD-ROM, this means having a disc loaded.
  2. Identify the device file: Use ls -l /dev/cdrom to find the device node.
  3. Mount the device: Create a mount point directory (e.g., /mnt) if it doesn't exist, then use the mount command:
    mount /dev/cdrom /mnt
    
    To unmount, use umount:
    umount /mnt/
    

Network Configuration

Network interface configuration is typically found in /etc/sysconfig/network-scripts/. The ifcfg-eth0 file contains parameters like:

  • TYPE: Network type (e.g., Ethernet).
  • BOOTPROTO: IP address assignment method (none, static, dhcp).
  • NAME: Logical interface name (e.g., eth0).
  • DEVICE: Physical interface name (e.g., eth0).
  • ONBOOT: Whether the interface is enabled on boot (yes or no).
  • IPADDR: Static IP address.
  • PREFIX: Subnet mask prefix length.
  • GATEWAY: Default gateway address.
  • DNS1: Primary DNS server address.

To apply changes:

  • Restart the network service: systemctl restart network.
  • Or, restart specific inetrface: ifdown eth0 && ifup eth0.

DNS resolution information is stored in /etc/resolv.conf.

Hostname Configuration

  • CentOS 7:
    • Temporary: hostname new_hostname
    • Permanent: hostnamectl set-hostname new_hostname (also sets temporarily)
    • To view the file for permanent configuration (though hostnamectl is preferred): cat /etc/hostname.
  • CentOS 6:
    • Temporary: hostname new_hostname
    • Permanent: Edit /etc/sysconfig/network.

To check the OS version, use cat /etc/redhat-release.

Host File Mapping

The /etc/hosts file provides local IP address to hostname mapping. This is checked before DNS resolution.

Automatic Mounts

The /etc/fstab file defines file systems to be mounted automatically at boot time.

Startup Scripts

The /etc/rc.local script is executed at the end of the boot process. Ensure it has execute permissions (chmod +x /etc/rc.d/rc.local). Commands placed here will run on startup.

System Runlevels

Runlevels define the system's operating state. In modern systems (systemd), these are referred to as 'targets'.

  • CentOS 6 Runlevels:

    • 0: Halt
    • 1: Single-user mode (rescue)
    • 2: Multi-user mode, without networking
    • 3: Full multi-user mode, with networking (standard CLI)
    • 4: Unused
    • 5: Graphical multi-user mode
    • 6: Reboot
  • CentOS 7 Targets:

    • poweroff.target (0)
    • rescue.target (1)
    • multi-user.target (2, 3, 4)
    • graphical.target (5)
    • reboot.target (6)
  • View current runlevel: runlevel.

  • Switch runlevel temporarily: init <runlevel>.

  • Set default target permanently (CentOS 7): systemctl set-default <target_name>.target.

  • Check default target: systemctl get-default.

Environment Variables

  • Temporary variables: Set using VARIABLE_NAME=value. Access with echo $VARIABLE_NAME.
  • Permanent variables: Add export VARIABLE_NAME=value to /etc/profile and run source /etc/profile.
  • The PATH variable defines directories searched for executable commands. To modify PATH permanently, edit /etc/profile and add the desired directories using export PATH=....

Aliases

Aliases create shortcuts for commands. Syntax: alias new_name='original_command'. Example: alias catnet='cat /etc/sysconfig/network-scripts/ifcfg-eth0'. To remove an alias: unalias new_name.

Login Banners

  • Message of the Day (MOTD): The /etc/motd file's content is displayed after a successful login.
  • Pre-login Banners: The /etc/issue and /etc/issue.net files display messages before login. To clear a file, use echo "" > /path/to/file or > /path/to/file.

Tags: Linux File System CLI configuration System Administration

Posted on Tue, 06 Oct 2026 16:23:43 +0000 by mordeith