exim

What are some tools that I can use to troubleshoot mail delivery issues with Exim on my linux / BSD / unix server?

This article will highlight some of the utilities included with the standard exim installation that assist in troubleshooting mail delivery issues.

Exigrep

Exigrep is very useful when you need to search for specific strings in the exim logfile. The reason for this is that it will look for the search string you specify, match that to a message-ID, and then display all the lines pertaining to that message.

Usage: exigrep /path/to/exim/logfile

Examples:
root@cpdemo [~]# exigrep 1BbLM3-0007fA-0v /var/log/exim_mainlog
2004-06-18 10:32:35 1BbLM3-0007fA-0v <= root@cpdemo.example.com U=root P=local S=1037
2004-06-18 10:32:37 1BbLM3-0007fA-0v => /dev/null <
devnull@cpdemo.example.com> R=system_aliases T=**bypassed**
2004-06-18 10:32:37 1BbLM3-0007fA-0v Completed

-OR-

root@cpdemo [~]# exigrep inspirem@cpdemo.example.com /var/log/exim_mainlog
2004-06-14 00:00:00 1BZjZg-000750-Ch <= inspirem@cpdemo.example.com U=inspirem P=local S=597
2004-06-14 00:00:00 1BZjZg-000750-Ch == example
@yahoo.com R=defer_router defer (-1): All deliveries are handled by MailScanner
2004-06-14 00:00:03 1BZjZg-000750-Ch => example
@yahoo.com R=lookuphost T=remote_smtp H=mx1.mail.yahoo.com [64.157.4.78]
2004-06-14 00:00:03 1BZjZg-000750-Ch Completed

2004-06-15 00:00:01 1Ba63E-0004gD-US <= inspirem@cpdemo.example.com U=inspirem P=local S=597
2004-06-15 00:00:01 1Ba63E-0004gD-US == example
@yahoo.com R=defer_router defer (-1): All deliveries are handled by MailScanner
2004-06-15 00:00:04 1Ba63E-0004gD-US => example
@yahoo.com R=lookuphost T=remote_smtp H=mx1.mail.yahoo.com [64.156.215.19]
2004-06-15 00:00:04 1Ba63E-0004gD-US Completed

Also notice that if you are looking for information that is listed in multple email transactions(ie. email addresses, sending hosts, etc …), exigrep will provide a space in between each email transaction.

Exiwhat

The ‘exiwhat’ command displays what each running exim process is doing at that given moment. This can be helpful in tracking down the cause for hanging exim processes or monitoring exim processes while they perform certain functions during testing.

Example:

root@cpdemo [~]# exiwhat
2118 daemon: -q1h, listening for SMTP on port 25 (IPv4)
2130 daemon: no queue runs, listening for SMTPS on port 465 (IPv4)
31640 handling incoming connection from [67.19.0.37]

Exim -bh

This section describes another usage of the exim mail server binary with special arguments that allow you to simulate a mail delivery from an external IP as the sender from the local server with the exim installation. This can be very useful when you need to recreate the mail delivery issue and you don’t have access to the sender’s machine to do so(ex. mail relaying, blacklists, etc.).

Usage: exim -bh

This will create a fake SMTP session which appears to be from . Not only that, but it also displays what exim is doing behind the scenes, and also what it would normally log. Now, bear in mind that this will not actually inject a message into the queue, nor will it actually log anything. This does however require knowledge of SMTP commands, but they are fairly easy. I have highlighted them in bold below for easier reading. Example:

root@cpdemo [/var/spool/exim/input]# exim -bh 216.87.129.155

**** SMTP testing session as if from host 216.87.129.155
**** but without any ident (RFC 1413) callback.
**** This is not for real!

>>> host in host_lookup? no (option unset)
>>> host in host_reject_connection? no (option unset)
>>> host in sender_unqualified_hosts? no (option unset)
>>> host in recipient_unqualified_hosts? no (option unset)
>>> host in helo_verify_hosts? no (option unset)
>>> host in helo_try_verify_hosts? no (option unset)
>>> host in helo_accept_junk_hosts? yes (matched “*”)
220-cpdemo.domain.com ESMTP Exim 4.34 #1 Fri, 18 Jun 2004 16:05:31 -0500
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
helo bbozo-2.example.com
>>> bbozo-2.example.com in helo_lookup_domains? no (end of list)
250 cpdemo.domain.com Hello bbozo-2.example.com [216.87.129.155]
mail from: ken@bbozo-2.example.com
250 OK
rcpt to: inspirem@cpdemo.domain.com
>>> using ACL “check_recipient”
>>> processing “accept”
>>> check hosts = :
>>> host in “:”? no (end of list)
>>> accept: condition test failed
>>> processing “warn”
>>> check condition = ${if and {{match{$local_part}{(.*)-bounces+.*}} {exists {/usr/local/cpanel/3rdparty/mailman/lists/${lc:$1}/config.pck}}} {yes}{no}}
>>> = no
>>> warn: condition test failed
>>> processing “accept”
>>> check condition = ${if and {{match{$local_part}{(.*)-bounces+.*}} {exists {/usr/local/cpanel/3rdparty/mailman/lists/${lc:$1}/config.pck}}} {yes}{no}}
>>> = no
>>> accept: condition test failed
>>> processing “warn”
>>> check condition = ${if and {{match{$local_part}{(.*)-bounces+.*}} {exists {/usr/local/cpanel/3rdparty/mailman/lists/${lc:$1}_${lc:$domain}/config.pck}}} {yes}{no}}
>>> = no
>>> warn: condition test failed
>>> processing “accept”
>>> check condition = ${if and {{match{$local_part}{(.*)-bounces+.*}} {exists {/usr/local/cpanel/3rdparty/mailman/lists/${lc:$1}_${lc:$domain}/config.pck}}} {yes}{no}}
>>> = no
>>> accept: condition test failed
>>> processing “require”
>>> check verify = sender
>>> ken@bbozo-2.example.com in “nobody@lsearch;/etc/localdomains“? no (end of list)
>>> ken@bbozo-2.example.com in “cpanel@lsearch;/etc/localdomains“? no (end of list)
>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>> routing ken@bbozo-2.example.com
>>> bbozo-2.example.com in “lsearch;/etc/localdomains”? no (end of list)
>>> bbozo-2.example.com in “! +local_domains”? yes (end of list)
>>> calling lookuphost router
>>> 216.87.129.155 in “0.0.0.0 : 127.0.0.0/8 : 64.94.110.0/24”? no (end of list)
>>> routed by lookuphost router
>>> ———– end verify ————
>>> require: condition test succeeded
>>> processing “accept”
>>> check domains = +local_domains
>>> cpdemo.domain.com in “lsearch;/etc/localdomains”? yes (matched “lsearch;/etc/localdomains”)
>>> cpdemo.domain.com in “+local_domains”? yes (matched “+local_domains”)
>>> check verify = recipient
>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>> routing inspirem@cpdemo.domain.com
>>> cpdemo.domain.com in “! +local_domains”? no (matched “! +local_domains” – cached)
>>> cpdemo.domain.com in “! +local_domains”? no (matched “! +local_domains” – cached)
>>> cpdemo.domain.com in “! +local_domains”? no (matched “! +local_domains” – cached)
>>> cpdemo.domain.com in “lsearch;/etc/userdomains”? no (end of list)
>>> cpdemo.domain.com in “! lsearch;/etc/userdomains”? yes (end of list)
>>> cpdemo.domain.com in “lsearch;/etc/localdomains”? yes (matched “lsearch;/etc/localdomains”)
>>> calling virtual_aliases_nostar router
>>> virtual_aliases_nostar router declined for inspirem@cpdemo.domain.com
>>> cpdemo.domain.com in “lsearch;/etc/userdomains”? no (end of list)
>>> cpdemo.domain.com in “lsearch;/etc/userdomains”? no (end of list)
>>> cpdemo.domain.com in “lsearch;/etc/localdomains”? yes (matched “lsearch;/etc/localdomains”)
>>> cpdemo.domain.com in “lsearch;/etc/localdomains”? yes (matched “lsearch;/etc/localdomains”)
>>> calling virtual_aliases router
>>> virtual_aliases router declined for inspirem@cpdemo.domain.com
>>> calling system_aliases router
>>> system_aliases router declined for inspirem@cpdemo.domain.com
>>> calling local_aliases router
>>> local_aliases router declined for inspirem@cpdemo.domain.com
>>> cpdemo.domain.com in “! lsearch;/etc/userdomains”? yes (end of list)
>>> cpdemo.domain.com in “! lsearch;/etc/userdomains”? yes (end of list)
>>> calling localuser router
>>> routed by localuser router
>>> ———– end verify ————
>>> accept: condition test succeeded
250 Accepted
Data
354 Enter message, ending with “.” on a line by itself
From: Ben bozo <ken@bbozo-2.example.com>
Subject: Test
>>> host in ignore_fromline_hosts? no (option unset)

Test.
.
>>> using ACL “check_message”
>>> processing “require”
>>> check verify = header_sender
>>> verifying From: header address Ben bozo <ken@bbozo-2.example.com>
>>> ken@bbozo-2.example.com in “nobody@lsearch;/etc/localdomains“? no (end of list)
>>> ken@bbozo-2.example.com in “cpanel@lsearch;/etc/localdomains“? no (end of list)
>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>> routing ken@bbozo-2.example.com
>>> bbozo-2.example.com in “lsearch;/etc/localdomains”? no (end of list)
>>> bbozo-2.example.com in “! +local_domains”? yes (end of list)
>>> calling lookuphost router
>>> 216.87.129.155 in “0.0.0.0 : 127.0.0.0/8 : 64.94.110.0/24”? no (end of list)
>>> routed by lookuphost router
>>> require: condition test succeeded
>>> processing “accept”
>>> accept: condition test succeeded
LOG: 1BbQZP-00005P-Gg <= ken@bbozo-2.example.com H=(bbozo-2.example.com) [216.87.129.155] P=smtp S=264
250 OK id=1BbQZP-00005P-Gg

**** SMTP testing: that is not a real message id!

SMTP/Exim debug mode
Description

To test verbose mail-delivery and debugging via the Exim SMTP server in @Mail, you can use the following command:

/usr/local/atmail/mailserver/bin/exim -d -v ‘user@localdomain.com’
^D ( control D )

This will step through each router in Exim, until the message is delivered or bounced.

This command can be useful for debugging, ( to test why a message cannot be delivered, database connection details, exim router reports, aliases and catch-all delivery )

For a more simple version use the command:

# /usr/local/atmail/mailserver/bin/exim -bt ‘username@localdomain.com’

username@localdomain.com
router = spamcheck_router, transport = spamcheck

This will emulate message-delivery and report which router can handle the message. The above message reports the message is accepted within @Mail.

For accounts that do not exist the following is returned:

username@localdomain.com is undeliverable:
Unrouteable address

Asagidaki howto bu adresden alintidir.
tarafimdan bir takim ekler yapilmistir.

1) Create a mysql db via direct admin. I called mine admin_webmail (you should all know how to do this!)

2) Download and unpack the package:

code:

cd /var/www/html

wget http://easynews.dl.sourceforge.net/...20051007.tar.gz

tar xvfz roundcube_webmail_0.1-20051007.tar.gz

EK: bu versyon turkce kullanmaya kalkinca pek cok sorun cikartiyor.
O yuzden SVN versyonunu tercih etmeli
SVN versyonuna su sekilde sahip oluyoruz:

Linux konsolumuzda:

svn checkout https://svn.roundcube.net/trunk

————–


3) Ensure proper permissions of the folders:

code:
chown -R root.root roundcubemail

cd roundcubemail

chown -R apache logs temp

4) Import their SQL file:

code:
cd SQL

//replace the following with the database
username and password you created in step 1

mysql -u admin_webmail -p
Enter Password: *******

Once in, import their SQL file:

code:
use admin_webmail

SOURCE mysql.initial.sql

EK: mysql5 icin farkli bir dosyamiz var

SOURCE mysql5.initial.sql
—-
now the import should be complete.

5) Setup db config variables

code:
cd ../config/

nano db.inc.php


all you have to do here is change the “$rcmail_config[‘db_dsnw’] = ” config information, mine looks like this:

code:
$rcmail_config['db_dsnw'] =
'mysql://admin_webmail:myPasswordHere@localhost/admin_webmail';

the format is: mysql://:

@host/database_namesave that file and close it.

6) Setup the application config:

code:
nano main.inc.php

find this line:

code:
$rcmail_config['enable_caching'] = TRUE;

Replace with:

code:
$rcmail_config['enable_caching'] = FALSE;

next find:

code:
$rcmail_config['default_host'] = '';

replace with:

code:
$rcmail_config['default_host'] = 'localhost';

EK: Turkce destegi icin main.inc.php nin en altina

php tagindan once

$rcmail_config[‘charset’] = ‘ISO-8859-9’;

eklememiz lazim

———

7) *optional* you may want to setup an apache alias, you can overwrite your current webmail one with the following:

Edit httpd.conf:

code:
nano /etc/httpd/conf/httpd.conf

Find this line:

code:
Alias /webmail /var/www/html/webmail/

Replace with:

code:
Alias /webmail /var/www/html/roundcubemail/

then restart apache

code:
/usr/sbin/service httpd restart

You are done!

Login @ http://www.domain.com/webmail/

My Install Guide V4 – Debian 3.1 (VHCS2.4.7.1)

Install Steps Debian 3.1 base install – manual and clean
Follow these instructions exactly with a clean install and you can’t go wrong.

On install of Debian, select no packages to be installed, allow it to connect to the internet and let it download anything
it needs, usually its libs etc. Exim is most likely installed at this point so dont worry it will be removed shortly.

I would at this stage edit your host file to so that it picks up everything during install

vi /etc/hosts and add your server hostname with the IP, example

Code:

192.168.1.1       myhostname.domain.com myhostname

Lets being the install
———————————————————-

1.vi /etc/apt/sources.list (add the following sources, ive had no problems with this mirror)

Code:

deb ftp://ftp.uk.debian.org/debian/ stable main
deb-src ftp://ftp.uk.debian.org/debian/ stable main
deb http://security.debian.org/ stable/updates main

2. apt-get install postfix postfix-tls proftpd-mysql courier-authdaemon courier-base courier-imap courier-maildrop courier-pop libberkeleydb-perl libc-dev libcrypt-blowfish-perl libcrypt-cbc-perl libcrypt-passwdmd5-perl libdate-calc-perl libdate-manip-perl libdbd-mysql-perl libdbi-perl libio-stringy-perl libmail-sendmail-perl libmailtools-perl libmd5-perl libmime-perl libnet-dns-perl libnet-netmask-perl libnet-perl libnet-smtp-server-perl libperl5.8 libsnmp-session-perl libterm-readkey-perl libtimedate-perl perl perl-base perl-modules bind9 diff gzip iptables libmcrypt4 mysql-client-4.1 mysql-common-4.1 mysql-server-4.1 patch php4 php4-mcrypt php4-mysql php4-pear procmail libterm-readpassword-perl libsasl2-modules libsasl2 sasl2-bin apache2 apache2-common apache2-mpm-prefork libapache2-mod-php4 gawk libgd1g bzip2 wget make gcc

(when you get to the courier screen screen select no to web directories)
(when you get to the postfix screen select internet site and then type root for mail. If you set debian up correctly on install your domain should be already on screen. Select no to force sync updates.)
(when you get to the proftpd screen, select standalone)

3. mysql -u root (no password at this stage, change it later!)

Code:


create database vhcs2;
use vhcs2; grant all privileges on *.* to 'vhcs2'@'localhost' identified by 'vhcs2' with grant option;
\q (quit program)

4. apt-get remove apache-common (if installed – not needed)

5. wget http://kent.dl.sourceforge.net/sourceforge/vhcs/vhcs2-2.4.7.1.tar.bz2

6. tar -xjvf vhcs2-2.4.7.1.tar.bz2

7. cd vhcs2-2.4.7.1

8. cd configs

9. vi vhcs2.conf (make the changes to match your requirements, dont forget to change database name, username and password, these are what you need to change)

Code:


DEFAULT_ADMIN_ADDRES = your email
SERVER_HOSTNAME = your hostname
BASE_SERVER_IP = your ip
DATABASE_TYPE = mysql
DATABASE_HOST = localhost
DATABASE_NAME = vhcs2
DATABASE_PASSWORD = vhcs2
DATABASE_USER = vhcs

10. cd .. (back to the root of the vhcs2 directory)

11. make install (if command not found run ‘apt-get install make’)

12. cd /tmp/vhcs*

13. cp -R * /

14. cd /var/www/vhcs2/engine/setup

15. ./vhcs2-setup (install script)

Code:


Wlecome to VHCS2 '2.4 Spartacus' Setup Dialog.
This program will set up VHCS2 system on your server.
Please press 'Enter' to continue.
Please enter system hostname (Enter for defaults) [debian]: yourhostname
Please enter system network address (Enter for defaults) [192.168.0.128]: your ipaddress
Please enter SQL server host (Enter for defaults) [localhost]:
Please enter system SQL database (Enter for defaults) [vhcs2]: vhcs2
Please enter system SQL user (Enter for defaults) [root]: vhcs2
Please enter system SQL password (Enter for defaults) [none]: vhcs2
Please repeat system SQL password: vhcs2
Please enter VHCS ftp SQL user (Enter for defaults) [vftp]: vftp
Please enter VHCS ftp SQL user password (Enter for defaults) [none]: vftp
Please repeat VHCS ftp SQL user password: vftp
Please enter administrator login name (Enter for defaults) [admin]:
Please enter administrator password: your password
Please repeat administrator password: your password
Please enter admininistrator email address: your email address

16.

Code:

echo "Include /etc/apache2/sites-available/vhcs2.conf" >> /etc/apache2/httpd.conf


(forgotten in install script)

17. sh /etc/init.d/apache2 restart

18. vi /etc/init.d/courier-authdaemon

(change this line) ${libexecdir}/authlib/authdaemon stop

Code:

killall authdaemond.plain


19. sh /etc/init.d/courier-authdaemon restart

21. vi /etc/resolv.conf (and add to the top)

add this

Code:

nameserver your ip


(this removes errors about virtual hosts when starting apache)

22 Vhcs2 does not start automatically on reboot so we need to add it as a startup script.

First, you must get the startup runlevel by the command “runlevel” in the bash. You’ll get something like N 2, N means there was no previous runlevel, 2 is the actual runlevel.

For those who don’t have an N, you know what you’re doing, simply look in your inittab, then go in the folder /etc/rc2.d (if 2 is your startup runlevel)

Make an ls -al to see how it works, it isn’t hard to understand. At startup everthing from S01xx to S99xx is started in that order.

This should do most people for runlevel 2, replace rc.2 with rc.3 if on runlevel 3

Code:

ln -s /etc/init.d/vhcs2_daemon /etc/rc2.d/S98vhcs

23. (You may need to change permissions on the tools folder)

Code:


chmod -R 766 /var/www/vhcs2/gui/tools


24. Thats about it, your should be ready to go

Original URL of this Document: http://vhcs.net/new/modules/newbb/viewtopic.php?topic_id=6840&forum=2

BU HEPSINI ASTI GITTI UCTU BITTI GITTI 🙂

[root@xxxxxx ~]# w
17:59:48 up 39 days, 22:34, 2 users, load average: 776.45, 774.29, 778.61
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 85.xx.181.xx 17:59 15.00s 0.17s 0.15s w

dokumani hazirladiktan sonra elbette benden once baskalarinin bu isle ugrastigini ve hazirladigini gordum

onlarida not ettim dokumanin icine.

IRC kurulumu

1- unreal ircd nin .tar.gz guncel versyonunu http://www.unrealircd.com/?page=downloads adresinden indirin
2- ftp ile unreal ircd kurulum yapilacak hesaba girin
3- ana dizin altinda IRC diye bir klasor olusturun
4- indirdiginiz .tar.gz dosyayi buraya upload edin
5- ssh ile putty kullanarak servera baglanin
6- sirayla yapilmasi gereken putty komutlari

# cd IRC
# tar zxvf Unreal3.2.5.tar.gz
# cd Unreal3.2
# ./Config

burada What is the hostname of the server running your IRCd?
sorusuna kadar entera basin bu soru yazdiginda ekrana irc serverin adini yazin.

ornegin

irc.geyikhane.com

NOT: daha onceden bu isimi DNS kaydini serverda acmis olmaniz lazim
veyahut bu isimde bir subdomain acmis olmaniz lazim.

geri kalan sorularida enter enter diye gecebilirsiniz.

config islemi bittikten sonra

# make

# make install

diyoruz bu son komutta hata verme olasiligi yuksek bu dosyayi konfig dosyasi icindeki yerine kopyalamadigina yonelik bi hata ama zaten biz ozel bir yol belirtmedigimiz icin ciddiye almaya gerek yok

unreal irc serverimiz su an calismaya hazir

ama calismadan once bir konfigurasyon dosyasi hazirlamaliyiz.

standart olarak bu dosya

unrealircd.conf adinda olmali ve kurulumu yaptigimiz

/home/kullaniciadi/IRC/Unreal3.2 dizini icinde yer almali

bu ayni dizin icinde zaten irc serverimizi baslatmak ve durdurmak icin kullanacagimiz
./unreal program kisayoluda var

konfigurasyon dosyamizi ayarladiktan sonra

./unreal star diyerek serverimizi calistirabilir
./unreal stop diyerek durdurabilir
./unreal restart diyerek calisan serveri bastan baslatabilir
./unreal rehas diyerek calisan serveri durdurmadan konfigurasyon dosyalarini yeniden sisteme tanitabiliriz.

simdi gelelim konfigurasyon dosyasina:

gene putty ustunden su komutlari yaziyoruz

# cp doc/example.conf unrealircd.conf

konfigurasyon dosyamizi yerine attik

simdi dosyamizi irc serverimizin ayarlarina gore ayarlamamiz lazim

# nano unrealircd.conf

diyoruz

acilan nano metin editoru ile dosyamizda gerekli degisiklikleri yapiyoruz

unrealin konfigurasyon dosyasinda yapilabilecek 10larca degisiklik var

server ip adresi izin verilen port adresleri eger varsa servis konfigurasyonlari oper izinleri sifreleri vb vb

bu konfigurasyon detaylarina bu belgede girmek cok vakit alacagi icin bu adrese goz atabilirsiniz:

http://www.goodmax.net/unreal/unrealircd.conf

ornek konfigurasyon dosyasi

ve

burada da unreal ile ilgili ileri duzey bilgi var

http://www.mirchane.com/unrealircd.php

ve bu adresdede bu yukaridaki yazdigim herseyin resimli anlatimi ve fazlasi var

http://www.frmtr.com/showthread.php?t=87480

—————

konfigurasyon dosyamizi editleyip canimizin istedigi gibi hazirladiktan sonra
tek yapmamiz gereken

./unreal start

irc serveriniz hazirdir

gule gule kullanin

Find is a versatile tool which can be used to locate files and directories satisfying different user criteria. But the sheer number of options for this command line tool makes it at the same time both powerful and encumbering for the user. Here I will list a few combinations which one can use to get useful results using find command.

Find all HTML files starting with letter ‘a’ in your current directory (Case sensitive)
$ find . -name a\*.html

Same as above but case insensitive search.
$ find . -iname a\*.html

Find files which are larger than 5 MB in size.
$ find . -size +5000k -type f

Here the ‘+’ in ‘+5000k’ indicates greater than and k is kilobytes. And the dot ‘.’ indicates the current directory. The -type option can take any of the following values:

f – file
d – directory
l – symbolic link
c – character
p – named pipe (FIFO)
s – socket
b – block device

Find all empty files in your directory
$ find . -size 0c -type f

… Which is all files with 0 bytes size. The option -size can take the following:

c – bytes
w – 2 byte words
k – kilo bytes
b – 512 byte blocks

Note: The above command can also take the -empty parameter.

Find is very powerful in that you can combine it with other commands. For example, to find all empty files in the current directory and delete them, do the following:

$ find . -empty -maxdepth 1 -exec rm {} \;

To search for a html file having the text ‘Web sites’ in it, you can combine find with grep as follows:

$ find . -type f -iname \*.html -exec grep -s “Web sites” {} \;

… the -s option in grep suppresses errors about non-existent or unreadable files. And {} is a placeholder for the files found. The semicolon ‘;’ is escaped using backslash so as not to be interpreted by bash shell.

Note: You can use the -exec option to combine any command in Linux with the find command. Some of the useful things you can do with it are as follows:

Compress log files on an individual basis
$ find /var -iname \*.log -exec bzip {} \;

Find all files which belong to user lal and change its ownership to ravi
# find / -user lal -exec chown ravi {} \;

Note: You can also use xargs command instead of the -exec option as follows:
$ find /var -iname \*.log | xargs bzip –

Find all files which do not belong to any user:
$ find . -nouser

Find files which have permissions rwx for user and rw for group and others :
$ find . -perm 766

… and then list them.

$ find . -perm 766 -exec ls -l {} \;

Find all directories with name music_files
$ find . -type d -iname \*music_files\*

Suppose you want to find files of size between 700k and 1000k, do the following:
$ find . \( -size +700k -and -size -1000k \)

And how about getting a formatted output of the above command with the size of each file listed ?

$ find . \( -size +700k -and -size -1000k \) -exec du -Hs {} \; 2>/dev/null

… here, the ‘2>/dev/null’ means all the error messages are discarded or suppressed.

You can also limit your search by file system type. For example, to restrict search to files residing only in the NTFS and VFAT filesystem, do the following:

$ find / -maxdepth 2 \( -fstype vfat -or -fstype ntfs \) 2> /dev/null

These are the most common uses of the find command. You can see additional uses by reading the find manual.

]]>