Linux Filesystem

From wikinotes

Unix is philosophically a little different from windows. Everything is a file. Your printer, speakers, mouse, keyboard etc are all represented within your filesystem.

Also, connected hard-drives are not exposed as drive letters, instead they are mounted to locations at or below the filesystem root (ex: '/').


Filesystems

A filesystem is the format used on a disk partition to record files.

Where windows typically uses fat32, or ntfs, linux normally uses ext4.

Locations

/boot Boot partition. Contains Kernel, bootloader.
/usr /usr Programs, Libraries, ManPages, Unchanging files. (Designed so it can be stored remotely once all programs are installed)
/var /var Log Files, Spool (news, printers, mail), formatted manual pages, temporary files. User Specific.
/home User Docs


/bin Binaries. For common cli commands ex: cp, mv, chmod
/sbin System Binaries. ex: ifconfig, getty, telinit
/etc /etc Config files and Executables specific to machine (ex: gdm3, xorg.conf, sudoers)
/lib libraries
/dev udev, devfs Devices exposed as files
/proc linux procfs Illusionary filesystem that exists in memory (not on disk). Info about system
/lost+found Files saved during failures
/net Standard Mount point for remote file systems
/opt Extra Third Party Software

File Permissions

See unix filesystem permissions.

capacity/size

df -h         # show all mounts, used/free space
du -h <file>  # show file size

ncdu          # interactive tool to navigate your filesystem, find largest files/directories

filesystem corruption

fsck (filesystem-check) checks the integrity of the filesystem, and attempts to repair it. only run this tool when a filesystem is unmounted