Linux: Search Cheat Sheet

# Find files and directories by name

locate name

# Search for pattern in file

grep pattern file

# Search recursively for pattern in directory

grep -r pattern directory

# Find files in /home/ that start with “filename”.

find /home/owner -name filename*

# Find files owner by “filename” in /home/

find /home/ -user filename

# Find files modifed less than “number” minutes ago in home

find /home/ -mmin number

# Search files larger than 100MB in /home

find /home -size +100M

# Search for pattern in files

grep pattern files

# Case insens­itive search

grep -i

# Recursive search

grep -r

# Inverted search

grep -v

# Show matched part of file only

grep -o

# Find binary / source / manual for command

whereis command

Leave a Reply

Your email address will not be published. Required fields are marked *