thegeekscope.com                        http://w w w .thegeekscope.com/find-files-in-linux-using-find-                    ...
Find Files Based on Modification Time in DaysSyntax: find <SEARCH_PATH> -mtime <x>          Integer <x> indicates days    ...
<x> along with ‘+’ sign indicates, modified before x mins          <x> along with ‘-’ sign indicates, modified within last...
# find /etc -size 20015cExample: Search /root folder for files/folders having size greater than 2 megabytes # find /etc -s...
Example: Find all files/folders owned by user ‘kam’ # find / -user kamFind Files Owned by a Specific GroupSyntax: find <SE...
Upcoming SlideShare
Loading in...5
×

Thegeekscope.com find files-in_linux_using_find_command

408

Published on

In Linux, find Command is used to search for specific files and folders. The beauty of the linux find command lies in its ability to perform complex searches. Find command provides plenty of options to specify size, modification date, type, owner, permission while performing a search operation.

This article describes some of the most useful options availble with the linux find command with the help of examples.

For more articles like this, visit www.thegeekscope.com

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
408
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Thegeekscope.com find files-in_linux_using_find_command"

  1. 1. thegeekscope.com http://w w w .thegeekscope.com/find-files-in-linux-using-find- command/Find Files in Linux using Find CommandIn Linux, find Command is used to search for specific files and folders. The beauty of the linux findcommand lies in its ability to perform complex searches. Find command provides plenty of options tospecify size, modification date, type, owner, permission while performing a search operation.This article describes some of the most useful options availble with the linux find command with thehelp of examples.Find Files Based on Filename PatternSyntax: find <SEARCH_PATH> -type [f|d] -name "<PATTERN>"type ‘f’ indicates that search for filestype ‘d’ indicates that search for directories The Geek ScopeExample: Search for files in the /root folder which contains the string “monitor” in the filename # find /root -type f -name "*monitor*" /root/monitor_script.sh /root/monitor_script.sh.v2 /root/monitor_script.sh.v1Example: Search for folders in the /root folder which contains the string “monitor” in the foldername # find /root -type d -name "*monitor*" /root/test/test_monitor123Example: Search for files/folders in the /root folder which contains the string “monitor” in the name # find /root -name "*monitor*" /root/test/test_monitor123 /root/monitor_script.sh /root/monitor_script.sh.v2 /root/monitor_script.sh.v1 www.thegeekscope.com
  2. 2. Find Files Based on Modification Time in DaysSyntax: find <SEARCH_PATH> -mtime <x> Integer <x> indicates days <x> along with ‘+’ sign indicates, modified before x days <x> along with ‘-’ sign indicates, modified within last x days <x> with no sign indicates, modified exactly x days agoExample: Search /etc folder for files/folders modified exactly 7 days ago # find /etc -mtime 7Example: Search /etc folder for files/folders modified before 7 days # find /etc -mtime +7 The Geek ScopeExample: Search /etc folder for files/folders modified in last 7 days # find /etc -mtime -7You can use ‘atime‘ in place of ‘mtime’ to find files and folders based on last access time in days.Example: Search /etc folder for files/folders accessed in last 7 days # find /etc -atime -7Find Files Based on Modification Time in MinsSyntax: find <SEARCH_PATH> -mmin <x> Integer <x> indicates minutes www.thegeekscope.com
  3. 3. <x> along with ‘+’ sign indicates, modified before x mins <x> along with ‘-’ sign indicates, modified within last x mins <x> with no sign indicates, modified exactly x mins agoExample: Search /home folder for files/folders modified exactly 60 minutes ago # find /home -mmin 60Example: Search /home folder for files/folders modified before 60 minutes # find /home -mmin +60Example: Search /home folder for files/folders modified in last 60 minutes # find /home -mmin -60You can use ‘amin‘ in place of ‘mmin’ to find files and folders based on last access time in mins. The Geek ScopeExample: Search /etc folder for files/folders accessed in last 60 mins # find /etc -amin -60Find Files Based on SizeSyntax: find <SEARCH_PATH> -size <x>Integer <x> indicates size in bytes/kilobytes/megabytes/gigabytes <x> along with ‘+’ sign indicates size larger than x <x> along with ‘-’ sign indicates size smaller than x <x> with no sign indicates, size exactly equal to xExample: Search /etc folder for files/folders having size exactly equal to 20015 bytes www.thegeekscope.com
  4. 4. # find /etc -size 20015cExample: Search /root folder for files/folders having size greater than 2 megabytes # find /etc -size +2MExample: Search /home folder for files/folders having size less than 1 kilobytes # find /etc -size -1kFind Files Based on PermissionsSyntax: find <SEARCH_PATH> -perm <permission>Example: Search /etc folder for files/folders with permission 755 (read,write,execute for owner andread,execute for group owner and others) The Geek Scope # find /etc -type f -perm 664Find Empty files and FoldersSyntax: find -emptyExample: Find all empty files/folders available in a system # find / -emptyFind Files Owned by a Specific UserSyntax: find <SEARCH_PATH> -user <username> www.thegeekscope.com
  5. 5. Example: Find all files/folders owned by user ‘kam’ # find / -user kamFind Files Owned by a Specific GroupSyntax: find <SEARCH_PATH> -group <groupname>Example: Find all files/folders owned by group account ‘projectx’ # find / -group projectxUse ‘-and’ and ‘-or’ qualifier to join search patternsExample: Search /root folder for files/folders modified in last 7 days and having size less than 200kB The Geek Scope # find /etc -mtime -7 -and -size -200kExample: Search /home folder for files/folders accessed in last 2 hours or having size greater than10MB # find /etc -amin -120 -or -size +10MTagged as: Find Command, Find Files, Find files in LInux, Find files in Unix, Linux Find Command,Search Files, Using Find Command www.thegeekscope.com

×