Main Menu

friends

Banner

Latest articles

backup MBR (master boot record) with dd
13/04/2010 | mad mad mod

The first 512 bytes of a partitioned storage device is called the MBR (master boot record). The main reason why I think you should backup the MBR is because it contains the disks primary partition tab [ ... ]


Iphone on Linux
11/10/2009 | mad mad mod

Many Linux users would like to use their iPhone on Linux (synchronize mp3's, podcasts, appz, pictures, movies, ...). Because Apple does not have iTunes for Linux (its only available for Microsoft Win [ ... ]


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