Main Menu

friends

Banner

Latest articles

FLOSS weekly
30/09/2009 | mad mad mod

FLOSS weekly FLOSS is an acronym for free/libre/open source software. Floss weekly is a podcast from the TWiT Network. The show contains interviews with prominent developers from the open so [ ... ]


setting up a very simple apache webserver on Linux (Fedora 12)
03/08/2009 | mad mad mod

 The following article describes how to setup a very simple apache webserver on Linux  (Fedora 12). Step 1: Install Apache run the following command as root:  # yum install httpd

  Se [ ... ]


Other Articles
Facebook MySpace Twitter Digg Delicious Stumbleupon Google Bookmarks 

Designed by:
SiteGround web hosting Joomla Templates
How to find files in Linux E-mail
sysadmin

This article describes how to find files in Linux.

 

locate

The fastest way to find a file on Linux is by using the "locate" command. If you know the name of the file or just a part of the name you can use the locate utility to list all files / directories that contain this pattern.

 

example:

# locate myfile
warning: locate: warning: database /var/lib/slocate/slocate.db' is more than 8 days old
/data/myfile.txt

 

What is this: "warning: locate: warning: database /var/lib/slocate/slocate.db' is more than 8 days old" ?

Locate will only find files which have been added to the slocate database. To make sure all files are added to the slocate database we can run 'updatedb' from a shell:

# updatedb

 

or as a cronjob:

 

# crontab -l

0 0 * * * /usr/bin/updatedb

 

You can also run updatedb with the "-l 0" option:

 

# updatedb -l 0

If FLAG is 0 or no, locate outputs the database entries even if the user running locate could not have read the directory necessary to find out the file described by the database entry. I would not do that on a server but it is very nice on a Desktop system.

 

 

find

With "find" you can search for files based on some user-specified criteria. Here are some nice examples:

 

find a file named test.txt and start at "/":

 

# find / -name test.txt

 

search the current directory:

 

# find -name test.txt

 --> If no paths are given, the current directory is  used

 

find all files containing test and start at "/":

 

# find / -name "*test.txt*"

 

find all files larger than 1 Megabyte (1024kb) and start at "/":

 

# find / -size +1024k

 

find all files larger than 1 Megabyte (1024kb), start at "/" and only search in the "/" filesystem (don't descend directories on other filesystems):

 

# find / -xdev -size +1024k

 

find all files in your HOME folder that have NOT been modified in the last year:

 

# find /home/myuser -mtime +365

 

Comments (0)
Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:D:angry::angry-red::evil::idea::love::x:no-comments::ooo::pirate::?::(
:sleep::););)):0
Security
Please input the anti-spam code that you can read in the image.

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

 
mad mad mod, Powered by Joomla! and designed by SiteGround web hosting