findコマンド
-name ファイル名
-atime 最終アクセス時間
-mtime 最終更新時間
-perm アクセス権限
-size ファイルサイズ
-type ファイルの種類
-user ファイルの所有者
-print マッチしたファイルを表示(省略可能)
-exec マッチしたファイルに対して,コマンド実行
RPMファイルを検索
[root@localhost ~]# find /home -name “*.rpm”
/home/admin/mysql-5.0.45-1.fc6.remi.x86_64.rpm
[root@localhost ~]#
一日以内に更新されたファイル
[root@localhost ~]# find /home/ -type f -mtime -1
/home/admin/right/umaskconfirm
/home/admin/linktest/red.log
/home/admin/linktest/error.log
/home/admin/linktest/test.log
/home/admin/linktest/cp_red_sym.log
/home/admin/linktest/test2.log
/home/admin/linktest/red_hard.log
/home/admin/linktest/test1.log
/home/admin/linktest/test3.log
/home/admin/.bash_history
[root@localhost ~]#
SUIDが設定されたファイルを検索
[root@localhost ~]# find /usr/bin/ -type f -perm -u+s
/usr/bin/rsh
/usr/bin/newgrp
/usr/bin/kon
/usr/bin/rcp
/usr/bin/chsh
/usr/bin/gpasswd
/usr/bin/rlogin
/usr/bin/Xorg
/usr/bin/at
/usr/bin/passwd
/usr/bin/sudo
/usr/bin/chfn
/usr/bin/sudoedit
/usr/bin/newvc
/usr/bin/newrole
/usr/bin/crontab
/usr/bin/chage
[root@localhost ~]#
/tmp/から所有者がadminのファイルやディレクトリー検索
[root@localhost ~]# find /tmp/ -user admin
/tmp/gconfd-admin
/tmp/mapping-admin
[root@localhost ~]#
365日アクセスされていないファイルを検索
[root@localhost ~]# find /home/admin/ -atime +365
/home/admin/.gtkrc
/home/admin/1.txt
[root@localhost ~]# ls /home/admin/1.txt
/home/admin/1.txt
[root@localhost ~]# ls -l /home/admin/1.txt
-rw-r–r– 1 root root 25 5月 29 2006 /home/admin/1.txt
365日アクセスされていないファイルを検索して削除
[root@localhost ~]# find /home/admin/ -atime +365 -exec rm {} \;
[root@localhost ~]# find /home/admin/ -atime +365
[root@localhost ~]#
LOCATE(ファイルデータベースに基づいて検索:データベースを更新する為にはupdatedb)
[root@localhost ~]# locate “*.rpm”
/home/admin/mysql-5.0.45-1.fc6.remi.x86_64.rpm
/usr/share/doc/vim-common-7.0.042/Changelog.rpm
/var/cache/alchemist/printconf.rpm
[root@localhost ~]#
WHICH(コマンドを探して,コマンドの絶対パスを表示します)
[root@localhost ~]# which ifconfig
/sbin/ifconfig
[root@localhost ~]# which route
/sbin/route
[root@localhost ~]# which vi
/bin/vi
[root@localhost ~]#
* whichコマンドは,パスが通っていないと検索出来ません。
WHEREIS (指定されたコマンドのバイナリーファイル,ソースコード,マニュアルファイルの場所を検索)
[root@localhost ~]# whereis ifconfig
ifconfig: /sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz
[root@localhost ~]# whereis route
route: /sbin/route /usr/share/man/man8/route.8.gz
[root@localhost ~]# whereis vi
vi: /bin/vi /usr/share/man/man1p/vi.1p.gz /usr/share/man/man1/vi.1.gz
[root@localhost ~]#