psコマンドで、CPU使用率・メモリ使用量でソートする

PSコマンドでは、通常ではプロセスID順に並んでいますが、この並びをCPU使用率・メモリの使用率に変更して表示する事ができます。CPUやメモリ以外の項目でもソートできるので詳し ...
SSHログインでログイン失敗を確認する方法

CentOSでは、SSHログイン・コンソール操作に関するログは「/var/log/secure」に保存されています
Debian, Ubuntuでは、SSHログイン・コンソール操作に関するログは「/var/log/auth ...
javaのバージョンを確認する方法

LinuxでJavaのバージョンを確認するには「java -version」のコマンドで確認できます。但し、Javaがインストールされている場合です
$ java -versionopenjdk version "11.0.17 ...実行中のコマンドをバックグランドで実行する

100G以上ある大きなデータベースをエクスポートしたら数時間かかりそうで、実行中のコマンドをバックグランドに回したくなりました。コマンド実行時に「nohup」を使えばいいですが忘れていました
実行途中でバックグランドで実行 ...
シェルスクリプトでインクリメント(i++)処理をする

シェルスクリプトで、for文やwhile文でよく使う「i++」のインクルメント処理があります。
インクルメント処理は、変数に「1」を加算する処理です。
また、このインク ...
wcコマンドでファイルの行数を取得する

Linuxでファイルの行数を取得したい場合は、「wc -l ファイル名」のコマンドで取得できます。「-l, –lines」のオプションは、ファイルの改行数を出力します
$ cat aaa.txt 12345$ wc ...PostgreSQL(psql)の接続と切断

普段はMySQLを使用しているので、PostgreSQLとはDBへの接続方法やDBの選択や終了などを違うので簡単にまとめてみました
psqlへの接続PostgreSQLへの ...
PostgreSQLで、データベースの一覧を確認する

久しぶりにPostgreSQLを触って、データベース一覧を表示しようと思ったら、以下のようにエラーになりました。
MySQLとコマンドが違うので、「show databases」と叩くと、「ERROR: unrecognize ...
grep で単語単位で一致した行を抽出する方法

grepで検索する単語で一致した行を抽出する時に、以下のようなテキストファイルがある場合、「192.168.0.1」でgrepすると「192.168.0.1、192.168.0.101」等の行も抽出されます
$ cat test ...grep で完全一致した行を抽出する方法

grepで検索文字と完全一致した行を表示するには「x」のオプションを利用します。
manページで確認すると、以下のような説明になります
-x, –line-regexpパターンが行全体とぴったりマッ ...
CPUコア毎のCPU使用率を確認する[mpstat]

CPUのコア毎のCPU使用率を確認するには、「top」コマンドで「1」を入力すれば表示できます
参考記事:topコマンドでコア単位でCPU使用率を確認する
今回はTOPコ ...
Curlでリクエスト中の進行状況を表示しない

curlでWEBページを保存する時に、オプションを指定しない場合は、下記のようにダウンロードできる進捗状況が表示されます。
通常にWEBページをダウンロードする場合はいいですが、シェルスクリプトでプログラムを実行している場 ...
grep コマンドで数字のみを表示する

数字と文字を含むテキストがあり、その中で数字のみを抽出したい場合の「grep -o ‘*’」のようにgrepコマンドを利用すれば利用できます
# grep -o '*'とすれば、数字のみを抽出できます$ ...viエディタでコロン「:」が打てない場合の対処方法

とあるクラウドサーバーで仮想マシンのクローンより新規仮想マシンを作成する作業がありました。
コピー元の仮想マシンが複数のディスクをマウントしており、コピー先のマシ ...
topコマンドでコア単位でCPU使用率を確認する

topコマンドではCPUの使用率が表示されますが、デフォルトでは複数のCPUコアを1つにまとめて表示されます。
これをCPU使用率をコア別に表示するには、topコマンドを叩いてから「1」のキーを押します