File placement and search

From Mintarc Forge

Filesystem Hierarchy Standard (FHS)

The Filesystem Hierarchy Standard (FHS) defines the directory structure and directory contents in Linux and other Unix-like operating systems. Here's an overview of important file locations, directory purposes, and commands for file placement and search:

  • /bin: Essential command binaries for all users
  • /boot: Boot loader files and kernels
  • /etc: Host-specific system configuration files
  • /home: User home directories
  • /lib: Essential shared libraries and kernel modules
  • /media: Mount points for removable media
  • /mnt: Temporary mount points for filesystems
  • /opt: Optional application software packages
  • /root: Home directory for the root user
  • /sbin: System binaries (system administration commands)
  • /tmp: Temporary files
  • /usr: Secondary hierarchy for read-only user data
  • /var: Variable data files (logs, spool files, temporary e-mail files)

find: Search for files in a directory hierarchy

Examples:

  • find /home -name "*.txt": Find all .txt files in /home
  • find / -type d -name "log": Find directories named "log"
  • find /var -size +10M: Find files larger than 10MB in /var

locate: Find files by name, using a previously built database

Examples:

  • locate filename.txt: Find all instances of filename.txt
  • locate -i "*.conf": Case-insensitive search for .conf files

updatedb: Update the file name database used by locate

Example:

  • sudo updatedb: Update the database (typically run daily via cron)

/etc/updatedb.conf: Configuration file for updatedb

Example content:

  • PRUNEPATHS="/tmp /var/spool /media"

type: Display information about command type

Examples:

  • type ls: Show the type of the ls command
  • type -a python: Show all locations of the python command

whereis: Locate the binary, source, and manual page files for a command

Example:

  • whereis gcc: Find locations of gcc binary, source, and man pages

which: Locate a command's executable

Example:

  • which python3: Show the path of the python3 executable