2017年1月26日木曜日

linux ファイル検索

○特定の名前のファイルを探す

・ルート配下のhttpd.confのファイルを探す
find / -name "httpd.conf"

・ルート配下の拡張子confのファイルを探す
find / -name "*.conf"

・大文字小文字を区別しない
find / -iname "*.conf"

・ルート配下のファイルで、"PermitRootLogin"の文字列を含むファイルを探す
grep -lr  "PermitRootLogin" /

・ルート配下のconfigで終るファイルで、"PermitRootLogin"の文字列を含む行を表示する
※ファイル名に複数箇所ある場合はその数分表示されます。
find / -type f -name "*config" | xargs grep "PermitRootLogin"