find

find linux command cheatsheet by Thamizhiniyan C S

Introduction

The find command is used to search for files in a directory hierarchy.


Syntax

find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [expression]


Important Flags

FlagDescription

-H

Follow symbolic links on command line only.

-L

Follow all symbolic links.

-P

Never follow symbolic links.

-D

Process debugging option.

-name

Matches files/directories by name.

-type

Matches files by type.

-perm

Matches files by permission.

-user

Matches files by owner.

-mtime

Matches files by modification time.

-atime

Matches files by access time.

-cmin

Matches files by changed minutes ago.

-amin

Matches files by accessed minutes ago.

-size

Matches files by size.

-writable

Matches files that are writable.


Examples

CommandDescription

Read the manual for the find command

find the file named “flag1.txt” in the current directory

find the file names “flag1.txt” in the /home directory

find the directory named config under “/”

find files with the 777 permissions (files readable, writable, and executable by all users)

find executable files

find all files for user “frank” under “/home”

find files that were modified in the last 10 days

find files that were accessed in the last 10 day

find files changed within the last hour (60 minutes)

find files accesses within the last hour (60 minutes)

find files with a 50 MB size

find files that are larger than 100 MB

redirect errors to “/dev/null” and have a cleaner output

Find world-writeable folders

Find world-writeable folders

Find world-writeable folders

Find world-executable folders

Find files/directories named "gcc*"

Find files with setuid, suppress errors

Find setuid files, suppress errors

Find files with the SUID bit

Find files with the SUID bit

Find files based on date accessed

Find files based on date modified

Find files modified after a specific date

Find files based on group name

To perform the search and locate the links that do not work (Find Broken Symbolic Links)

Last updated