Linux-admin-grep-command

提供:Dev Guides
移動先:案内検索

Linux Admin-grepコマンド

*grep* は一般的に管理者によって使用されます-
  • 特定のテキスト文字列を持つファイルを検索する
  • ログでテキスト文字列を検索する *特定の文字列に焦点を合わせて、コマンドを除外する

以下は、grepで使用される一般的なスイッチのリストです。

Switch Action
-E* Interpret pattern as a regular expression
-G * Interpret pattern as a basic regular expression
-c Suppress normal output, only show the number of matches
-l List files with matches
-n Prefix each
-m Stop reading after the number of matching lines
-o Print only the matching parts of matching lines, per line (useful with pattern matches)
-v Invert matches, showing non-matches
-i Case insensitive search
-r Use grep recursively
*Xorg* ログでエラー *X* サーバーエラーを検索します-
[root@centosLocal log]# grep error ./Xorg*.log
   ./Xorg.0.log:   (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
   ./Xorg.1.log:   (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
   ./Xorg.9.log:   (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
[root@centosLocal log]#

インポートされたWindows ServerファイアウォールログでRDP攻撃の可能性を確認します。

[root@centosLocal Documents]# grep 3389 ./pfirewall.log | grep " 146." | wc -l
326
[root@centosLocal Documents]#

上記の例に見られるように、24時間以内にIPv4クラスA範囲から326回のリモートデスクトップログイン試行がありました。 問題のIPアドレスは、プライバシー上の理由から隠されています。 これらはすべて同じIPv4アドレスからのものでした。 それとしてすぐに、ファイアウォールのIPv4範囲をブロックする明確な証拠があります。

grepはかなり複雑なコマンドです。 ただし、Linux管理者はしっかりと把握する必要があります。 Linuxシステム管理者は、平均して1日に数十種類のgrepを使用できます。