The Unix Filesystem - noyage/redhat GitHub Wiki
- a logical database that is used to store files and directories.
- Each system is created in a separate partition or logical volume
- a typical RHEL system usually has many file systems
- 2 are created by default on RHEL
- / and /boot
- others created after installation; /home , /opt, /tmp , /var, /usr
 
- Several types of file systems
- 3 basic groups
- disk-based
- For hard disks using SCSI, iSCSi, SAS, SATA, USB, Fibre Channel
 
- network-based
- disk-based file systems shared over a network for remote access
 
- memory-based
- virtual. Created automatically at system setup
 
- The first 2 types store information persistently ; any data in virtual file systems are lost upon system reboot.
- RedHat-based linuxes (RHEL/Rocky/Alma/...) all use XFS by default
- Debian-based linuxes (includes Ubuntu) use EXT4 by default
- $ df -h
- $ mount
- $ mount -t xfs
- $ mount -t ext4
- 
$ cat /etc/fstab<-- filesystems mounted at boot time
- note for VM's, it's ok to create a filesystem on the whole disk (/dev/sdbetc)
- for physical machines, create partitions on a disk and then put a fs on the partition
- Partition the hard drive (optional if a VM)
- make sure drive exists in lsblk
- use formatorpartedto partition a disk:- parted /dev/sdb
- format /dev/sdb
 
- Create an ext4orxfsfilesystem on the partition (or entire disk)
- 
mkfs.xfs /dev/sdb1(where 1 is the partition number)
- mkfs.ext4 /dev/sdb1
- to use entire disk, use /dev/sdbinstead of/dev/sdbX
- In unix, everything is a file
- data files
- compiled code (system binaries such as/usr/bin/ls)
- directories (folder)
- devices (keyboard, mouse, disk drives, screen, printers,...)
 
- files have a user and group defined
- files have 3 sets permissions for user/group/other
- each permission set is represented by 3 binary digits
- root directory "/" at top
- The Unix File System
- all files have an owner and a group
- 
lsorstatcommand
$ ls -l /etc/passwd
-rw-r--r--. 1 root root 2645 Dec 19 13:58 /etc/passwd
---
$ stat /etc/passwd
  File: /etc/passwd
  Size: 2645      	Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 201326853   Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: system_u:object_r:passwd_file_t:s0
Access: 2025-04-12 16:01:01.335299886 -0400
Modify: 2024-12-19 13:58:26.510758416 -0500
Change: 2024-12-19 13:58:26.511758513 -0500
 Birth: 2024-12-19 13:58:26.510758416 -0500
- user + group + other + selinux
- the trailing dot indicates SELinux security context
- user, group and other have read-write-execute permissions
- 
rwxhas a different meaning for directories than for files
- specify via ugoor bits (4+2+1)- chmod g+x (filename)
- chmod 770 (filename
 
- chown user:group (filename)