Main Menu

friends

Latest articles

Install PHP for Apache (Fedora 12)
31/03/2010 | mad mad mod

This article describes how to install PHP for Apache on Linux (Fedora 12).
 Step 1: Install PHP  run the following command as root:

# yum install php


 Setting up Install Process
Resolving Depende [ ... ]


ASCII-art process hierarchy with ps
05/12/2010 | mad mad mod

I always used the ps command with the -ef switches to slist all processes on y system. Recently, I came across a new ps-parameter:   # ps -e f (It is "f" not "-f")   With this option ps pri [ ... ]


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