Results 1 to 7 of 7
  1. #1

    Find command : Linux

    Sometimes we need to find the file in server which we do not know where exactly it is located:


    ·Search and list all files from current directory and down for the string ABC:

    find ./ -name "*" -exec grep -H ABC {} \;
    find ./ -type f -print | xargs grep -H "ABC" /dev/null
    egrep -r ABC *

    ·Find all files of a given type from current directory on down:

    find ./ -name "*.conf" –print

    ·Find all user files larger than 5Mb:

    find /home -size +5000000c –print

    ·Find all files owned by a user (defined by user id number) on
    the system: (could take a long time)

    find / -user 501 –print

    ·Find all files created or updated in the last five minutes: (Great for finding effects of make install)

    find / -cmin -5

    ·Find all world writable directories:

    find / -perm -0002 -type d –print

    ·Find all world writable files:

    find / -perm -0002 -type f -print
    find / -perm -2 ! -type l -ls

    ·Find files with no user:

    find / -nouser -o -nogroup –print

    ·Find files modified in the last two days:

    find / -mtime 2 -o -ctime 2



  2. #2
    Useful for newbie...!!! Good

  3. #3
    Join Date
    Jan 2005
    Posts
    2,171
    thanks, useful

  4. #4
    Great stuff. The find command is extremely powerful and has so many excellent uses.

    You might want to consider showing how you can apply immediate changes (using exec) to the results of a find. Of course, all that is to be used at one's own risk -- but that's what I find most practical about the command.

    Here's one practical use - finding files in a directory that are older than 3 days and deleting them:

    # find /directoryname -type f -mtime +3 -exec rm {} \;


  5. #5
    Join Date
    Feb 2003
    Location
    North Hollywood, CA
    Posts
    2,548
    Applications that have the suid bit set can masquerade as one user,
    possibly a very powerful one such as root, and yet can be run
    by regular users. You should review what programs have
    suid bit set and decide if it is appropriate.
    The following command will provide a list of SUID/SGID programs.

    find / -type f \( -perm -04000 -o -perm -02000 \) \-exec ls -l {} \;

    from >> http://webcp.hostinghacks.net/redhat/secure-compilers/
    Remote Hands and Your Local Tech for the Los Angeles area.

    (310) 573-8050 - LinkedIn

  6. #6
    Join Date
    Jul 2005
    Posts
    56
    it can be occasionally useful in fixing certain file permissions
    find . -type d -exec chmod 755 {} \;
    find . -type f -exec chmod 644 {} \;

    an example scenario would be you accidentally recursively chmod'd to 644 yet forgot there were a lot of folders in that directory. or, you copy files from a location that has the permissions all screwed up (from a CD or a zip/tar file, etc).

  7. #7
    thank you very much dear .......

  8. Newsletters

    Subscribe Now & Get The WHT Quick Start Guide!

Related Posts from theWHIR.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •