シェルスクリプトで変数が空文字であるか調べる

シェルスクリプトで変数に値が入っているか調べるには、testコマンドやif分で変数の値を比較して調べることができます。
testコマンドで変数が空文字であるか調べるtestコマンド ...
nginxに変更したらメモリ不足なったので、php-fpmを設定を見直し

VPSをサーバーをLightsailに変更した際に、Apacheを使っていたWEBサーバーをnginxに変更しました。始めは問題なく動作していたのですが、しばらくするとNe ...
CentOSで、swapのswapの使用率を表示する

Linuxで物理メモリを使い切るとswap領域を使用します。今のメモリ状況は「free」コマンドで確認できます。
下記では、「-m」のオプションでメモリの量をMB単位で表示しています。
vsftpdでパッシブモードを設定する

FTPサーバーのvsftpdでパッシブモードも有効にして、F/W(iptables)でパッシブモードで利用するポートを開放する手順を説明します
vsftpdでパッシブモードを有効 ...sedコマンドで空行を削除する

sedコマンドで空行の削除して表示するには、以下のように「sed ‘/^$/d’ (ファイル名)」で表示できます
$ cat test123456789$ sed '/ ...設定ファイルのコメントアウトを空行を除外して表示

Apacheの設定ファイルなどで「#」でコメントアウトしている設定は除外して表示するには「cat」,「grep」コマンドを利用すれば表示できます。
コマンド:cat (設定ファ ...
digコマンドでネームサーバを調べる

ドメインのネームサーバを何処に設定したかdigコマンドで調べる場合は「ns」のオプションを使用します。NSのオプションを使用するとドメイン名に対応するNSレコードを取得する事ができます
$ dig onamae.com ns; ...シェルスクリプトで変数内の改行を有効にする

シェルスクリプトを改行を含まれる変数をechoコマンドなどで表示した場合に、下記のように改行がスペースに変換される場合があります。
$ cat test.sh#!/bin/bashTEST="1 ...ApacheでCGIを動かす

最近、滅多に使うことがなくなったCGIの設置依頼が久しぶりに来ました。CGI設定て何年ぶりだろう。
お客様ではWor ...
findで古いファイルを削除・移動・圧縮する方法

findとxargsを使用して、古いファイルを削除・移動・圧縮する方法を紹介します。個人的にはログファイル等をメンテナンス時によく使うコマンドです。
findで、n日より古いファイルを削除する特定の日数以上のファイルを「- ...
grep の結果でファイル名のみ表示する

grepで検索した結果で、ファイル名のみ表示したい場合は「grep -l pattern file1 file2…」とすれば、ファイル名のみ表示します
$ grep ...ユーザーをグループに追加する方法(usermod -aG )

Linuxでユーザーを特定のグループに追加する場合は、「usermod」を使いますが、このコマンドでオプションを間違うと思っていたようにグループ追加ができない場合があります。
digコマンドでMXレコードを確認

digコマンドMXレコードを確認する方法を紹介します。digコマンドではドメイン情報をDNSサーバーから取得する時に使用します。
Windowsの場合は、nslookupコマンドを利用します。nslookupを利用する ...
CentOS ハードウェア情報の取得

他のディストリビューションでも使用できると思いますが、LinuxのCentOSでCPUやメモリ等のハードウェア情報を取得したい場合に使用するコマンドを紹介します
CPU情報 取得CPU情報を取得するには「/proc/c ...
findのAND検索・OR検索 [ 論理演算子 ] NOT検索(特定のファイルを含まない)

findコマンドは、で絞り込み検索のAND検索、複数条件での検索(OR検索)、特定の条件などを除外(NOT検索)の方法を紹介します
動作確認用に以下のようなファイルを配置しています
$ ls |egrep "ex|h ...