Linux - Part 1 -
Linux - Part 1 -
$ whereis echo
echo: /bin/echo
/usr/share/man/man1/echo.1.gz
find
find – search a directory tree
• Usage: find <directory> [option]
[expression]
• –i (case insensitive)
• –name (filtered by pattern)
• –user | –uid (filtered by user or UID
• –group | –gid (filtered by group or GID)
• –size (filtered by size)
• –perm (filtered by permission)
• –atime | –mtime | –ctime (by access, mod or
create time)
• –exec | –ok (execute command on output)
The Power of the Linux Find Command (2:43)
find examples
$ find -name car // if has ‘car’ in its name
$ find -name Car // if has ‘Car’ in its name
$ find /tmp –user root // if owned by user=root
$ find /tmp –gid 500 // if owned by group with gid=500
$ find /user/share -size 1024k // if size is exactly 1 mb
$ find /user/share -size +1024k // if size is > 1 mb
$ find /user/share -size -1024k // if size is < 1 mb
$ find /tmp -perm 755 // if mode is exactly 755
$ find /tmp -perm +222 // if anyone can write
$ find /tmp -perm -222 // if no one can write
$ find /tmp -perm -222 // if ‘other’ cannot write
$ find /tmp -mtime -10 // if modified < 10 days ago
$ find /tmp -ctime +20 // if created > 20 days ago