cut, awkコマンドで区切り文字を指定して取り出す

cutコマンド、awkコマンドを利用して、任意の区切り文字で区切られた文字を取り出す方法を紹介します。
以下のファイルでは、「:」で区切りを入れてIPアドレス:ポート番号を記載されています ...
シェルスクリプトを利用して、iptablesに特定のIPを拒否するスクリプト

iptablesのF/Wで特定のIPアドレスを拒否(DROP)したい場合に、その都度コマンドを入力するのが面倒なので、シェルスクリプトで引数に拒否したいIPアドレ ...
SMTP Authを何度も試みててくるIPアドレスをブロックする【postfix】

メールサーバーを運用していると、海外からのSPAM業者がSTMPサーバーにアクセスしてきます。いちようメールサーバーはSMTP認証をし ...
IPアドレスを指定して受信拒否 【postfix】

Postfixでメールサーバーを運用していると迷惑メール・SPAMメール等で対策で特定のIPアドレスからの接続を拒否したいケースがあります。
その場合はPostfixの設定フ ...
SPAMデータベースを利用して迷惑メール対策【postfix】

postfixを利用してメールサーバーを構築してるサーバーがあります。このメールサーバーですが迷惑メール業者からのアクセスが多いので何かしらの対策が必要でしたので、 ...
シェルスクリプトで「Enter」を押さないと処理を進めないようにする

シェルスクリプトで処理を進めていて、変数とか処理に問題なければ処理を進めたいケースがあります。その場合に「エンター(Enter)キー」を押すと処理を進める場合は「read Wait」と ...
postfixで送信・受信・送受信を転送する

送信したメール・受信したメール・送受信したメールを転送(アーカイブ)する仕組みとしてpostfixでは、「always_bcc」、「sender_bcc_maps」、「r ...
dateコマンドで、ファイルのタイムスタンプを取得

指定したファイルの日付・時間等のタイムスタンプを取得するには「date」コマンドを使用すれば取得できます
$ ls -l test.txt-rw-rw-r-- 1 centos ce ...パーティションの拡張されなかったので、resize2fsでディスク容量を増やす

さくらクラウドでディスク容量が少なくなり、ディスクを大きい容量に変更したディスクがありました。さくらクラウドのサイズの大きなディスクの交換手順のようにおこなったのですが ...
ヒアドキュメントでHTML分を出力する [PHP]

phpでHTML分を出力する場合、ヒアドキュメントを使うと便利です。
下記が簡単なサンプルです
PHP ログをファイルに出力する

エラーログなどを任意のファイルに等に出力する場合は「error_log」関数を使用すると便利です。error_log関数は任意のメッセージをログファイルに出力したり、メール送信できます
ディスクのUUID確認(blkidコマンド)

CentOS 6以降、fstabでパーティションをマウントポジションなど設定する時にUUIDが設定するようになっています。OSをインストール時に自動でUUIDは設定されるので普段は意識しなくても大丈夫ですが、ディスクを増設したとき ...
PHPの配列の初期化

array関数を使用して、PHPの配列を初期化します。使い方は簡単は、$array = array() のように使います
$array = array();簡単なサンプルでは、配列に値を挿入 ...
CentOSで、swapのswapの使用率を表示する

Linuxで物理メモリを使い切るとswap領域を使用します。今のメモリ状況は「free」コマンドで確認できます。
下記では、「-m」のオプションでメモリの量をMB単位で表示しています。
Windowsで作成したシェルスクリプトで実行すると、「command not found」エラー

シェルスクリプトを作るときはAtom等のエディタで作ってSCPでアップしていました。macOSからWindowsに変更して ...