find

Limiting the search to n levels within the directory structure (must be placed before other options):

find -maxdepth n

Searches for files that are eqaul (n), larger (+n) or smaller (-n) than n:

find . -size [+-]n

n should be followed by c (bytes), k (1000), M (megabyte), G(gigabyte).

More size options can be combined to set an interval for files greater than n but smaller than m:

find . -size +n -size -m

Searches for a certain type:

find -type t

Where t is:

f = file

d = directory

l = symbolic link

b = block file

c = char file

p = named pipe

s = socket

Search by modify date:

Search for files/folders modified exactly 7 days ago (0 for today):

find -daystart -mtime 7

Search for files/folders modified at most 7 xdays ago:

find -daystart -mtime -7

Search for files/folders modified more than 7 days ago:

find -daystart -mtime +7

Instead of mtime can be used atime (access) or ctime (status change). The -daystart option is needed so that find will start counting from now as day 1 instead of day 0 (so 1 would be for today).

Instead of mtime for days can be used mmin for minutes etc.

Searching by permisions

Searching for the exact permissions (octal):

find -perm xxx

Searching for at least xxx permissions:

find -perm -xxx

Searching for any of xxx:

find -perm +xxx

or

find -perm /xxx

Searching by ownership

Search after user x

find -user x

Search after members of group x

find -group x

Other options

To find for all files cu n hard links:

find -links n

To find all files/folders newer than file:

find -newer file

To search after inode n:

find -inum n

To search for empty files or folders:

find -empty

To find files/folders that don’t correspond to any user/group:

find -nouser

find -nogroup

To negate a option prefix it with !

Uncategorized