Finding Files - Paiet/Tech-Journal-for-Everything GitHub Wiki

  • which command
    • Returns ONLY the 1st match it finds by default
    • which xterm
  • whereis command
    • whereis ls
    • whereis ifconfig
  • type command
    • Displays how a command is interpreted
    • type type
    • type cat
    • type exit
  • locate command
    • Locates any file by name
    • locate README
    • Relies on a database that can be outdated
      • /etc/updatedb.conf
      • updatedb
  • find command
    • find [path...] [expression...]
    • Redirect stderr to /dev/null to mask permission denied
      • 2> /dev/null
    • Search by filename
      • find / -name README.txt 2>/dev/null
      • find / -name '*.txt'
    • Search by File Size
      • Find files larger than 20MB
      • find /usr -size +20M
    • Search by User ID
      • find /home/nicholas -user nicholas
    • Additional options
      • -not and -or
      • -ls
        • Displays files in longer ls form
      • find /var/ -not -user joe -ls
  • grep command
    • Searches inside of files
      • grep <string> <location>
      • Options
        • -i case insensitive
        • -v exclude string
        • -r perform a recursive search
        • --color highlights search term in red
      • grep -ri --color ishmael ~/
⚠️ **GitHub.com Fallback** ⚠️