<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2-ppt DokuWiki" -->
<?xml-stylesheet href="https://tm.root-n.com/lib/exe/css.php?s=feed" type="text/css"?>
<rss version="2.0">
    <channel>
        <title>Tipsというかメモ unix:command</title>
        <description></description>
        <link>https://tm.root-n.com/</link>
        <lastBuildDate>Tue, 18 Nov 2025 17:20:07 +0900</lastBuildDate>
        <generator>FeedCreator 1.7.2-ppt DokuWiki</generator>
        <image>
            <url>https://tm.root-n.com/lib/images/favicon.ico</url>
            <title>Tipsというかメモ</title>
            <link>https://tm.root-n.com/</link>
        </image>
        <item>
            <title>Unix :: コマンド / apt-{get, cache}</title>
            <link>https://tm.root-n.com/unix:command:apt</link>
            <description>コマンド説明apt-{get,cache}「apt」とはAdvanced Package Toolの略でDebian Projectで開発されたパッケージ管理ツール。パッケージのインストールやアップデートが容易に行えます




アプリケーション(daemon)をインストールするには「apt-get install パッケージ名」と入力します。

パッケージ名が分からないときは、「apt-cache search パッケージ名(正規表現の使用可)」と入力すると検索してくれます。

また、パッケージは日々更新されているので最新のパッケージリストを取得するために「apt-get update」を実行します。

なお、「apt-cache search」で一覧表示されたパッケージ名は、名前だけは用途がわからない場合があります。

そんな時は「apt-cache show パッケージ名」と入力すると、パッケージの説明が画面に表示されます。…</description>
        <category>unix:command</category>
            <pubDate>Thu, 26 Mar 2009 17:02:47 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / awk</title>
            <link>https://tm.root-n.com/unix:command:awk</link>
            <description>コマンド説明awkUNIX上で開発されたフィールド指向のテキスト処理スクリプト言語




条件式と演算


2行目と3行目を表示する (パイプ経由)
% cat hoge.txt | awk 'NR==2,NR==3 { print }'




2行目と3行目を表示する (ファイルから読み込む)</description>
        <category>unix:command</category>
            <pubDate>Sun, 16 Mar 2008 22:48:31 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / curl</title>
            <link>https://tm.root-n.com/unix:command:curl</link>
            <description>コマンド説明curlcurl（カール）は、さまざまなプロトコル（Web 界では主に http/https が多用される）を用いてデータを転送するコマンドラインツールです。curl は cURL のことであり「client for URL」の略である。</description>
        <category>unix:command</category>
            <pubDate>Wed, 08 Aug 2018 16:30:02 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / dig</title>
            <link>https://tm.root-n.com/unix:command:dig</link>
            <description>コマンド説明digdig (domain information groper) は、 DNS (DomainName System) サーバから情報を集めるために使われる柔軟なコマンドラインツールです




ホスト名からIPアドレスを調べる


% dig yahoo.co.jp

; &lt;&lt;&gt;&gt; DiG 9.3.4 &lt;&lt;&gt;&gt; yahoo.co.jp
;; global options:  printcmd
;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 27368
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 2

;; QUESTION SECTION:
;yahoo.co.jp.                   IN      A

;; ANSWER SECTION:
yahoo.co.jp.            300     IN      A       203.216.227.176
yah…</description>
        <category>unix:command</category>
            <pubDate>Sun, 16 Mar 2008 22:48:31 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / expect</title>
            <link>https://tm.root-n.com/unix:command:expect</link>
            <description>コマンド説明expect対話形式のコマンドを自動化する




インストール


sudo yum install expect





cron で expect が動作しない？


cron で expect が期待通りに動かない。それを解決した時のメモ。</description>
        <category>unix:command</category>
            <pubDate>Sun, 13 Oct 2013 19:42:45 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / extundelete</title>
            <link>https://tm.root-n.com/unix:command:extundelete</link>
            <description>コマンド説明extundeleteext3 または ext4 パーテーションから削除されたファイルを復元するユーティリティ。パーテーションのジャーナル情報をもとに復元を試みる

extundelete、神のツールです。</description>
        <category>unix:command</category>
            <pubDate>Sun, 17 May 2015 15:04:28 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / find</title>
            <link>https://tm.root-n.com/unix:command:find</link>
            <description>コマンド説明findfind ユーティリティは、指定ディレクトリツリーを再帰的に下って、ツリー上の各ファイルについてオプションで指定された処理を実行します。




単純な検索


ファイルのみ検索</description>
        <category>unix:command</category>
            <pubDate>Tue, 28 Jan 2014 14:18:50 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / ftp</title>
            <link>https://tm.root-n.com/unix:command:ftp</link>
            <description>コマンド説明fptFTP(File Transfer Protocol)を利用してファイルを転送します。






以下の例では、
ホストexample.comユーザーftpuser
としてログインします。(適宜、読み替えてください)




FTPログイン

	*  ホスト、ユーザーの指定</description>
        <category>unix:command</category>
            <pubDate>Tue, 27 Oct 2009 12:45:02 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / git</title>
            <link>https://tm.root-n.com/unix:command:git</link>
            <description>インストール

	*  インストールと設定



操作の備忘録

	*  git add の取り消し
		*  git pull の取り消し
		*  git commit の取り消し
		*  git commit をやり直す
		*  git push の取り消し
		*  git rm で削除したファイルを復活させる
		*  git 管理下から外す
		*  未 push のコミットを表示する
		*  ブランチを指定して clone する
		*  ブランチ間の diff を見る
		*  リモートへのブランチの push ／ ローカルへのブランチ checkout
		*  特定ファイルの変更履歴(diff)を見る
		*  リモートリポジトリとワーキングツリー(作業ツリー)の差分を見る
		*  ハッシュ値を元に、特定ファイルをその時の状態に戻す
		*  手元(working directory)の変更を commit せずに、pull したい時
		*  過去(特定のリビジョン)の状態を閲覧する
		*  リビジョン間の diff をとる
		*  マシンAで作成した…</description>
        <category>unix:command</category>
            <pubDate>Mon, 05 Nov 2018 13:19:55 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / gzip・gunzip</title>
            <link>https://tm.root-n.com/unix:command:gzip-gunzip</link>
            <description>コマンド説明gzipファイルの圧縮を行なうgunzipファイルの伸長を行なう




圧縮
% gzip -c hoge &gt; hoge.gz -c : 標準出力し、元のファイルを削除しない



伸長
% gunzip -c hoge.gz &gt; hoge -c : 標準出力し、元のファイルを削除しない</description>
        <category>unix:command</category>
            <pubDate>Sun, 16 Mar 2008 22:48:32 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / locate・updatedb</title>
            <link>https://tm.root-n.com/unix:command:locate-updatedb</link>
            <description>コマンド説明locateファイル名を高速に検索するupdatedblocate データベースの更新




locate
% locate hoge※. これは『find / -name '*hoge*'』とまったく同じ意味である



updatedb
% sudo updatedb※. root権限で実行する必要がある。通常cronで定期的に実行する。</description>
        <category>unix:command</category>
            <pubDate>Sun, 16 Mar 2008 22:48:32 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / lsof</title>
            <link>https://tm.root-n.com/unix:command:lsof</link>
            <description>コマンド説明lsofオープン中のファイルやそのファイルをオープンしているプロセスのリストを出力するコマンド。lsof(エルエスオーエフ)は「list open files」を意味する




リッスンしているポートとプロセスを調べる


% sudo lsof -i -nP</description>
        <category>unix:command</category>
            <pubDate>Sun, 10 Aug 2014 14:50:50 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / lv</title>
            <link>https://tm.root-n.com/unix:command:lv</link>
            <description>コマンド説明lv多国語に対応したテキストファイルビューアで、lessの代わりに使われることが多い。また、文字コードの変換にも利用できる。 
インストール

CentOS6 から lv コマンドが外されたようです。

以下は、rpm インストールした時のメモになります。</description>
        <category>unix:command</category>
            <pubDate>Thu, 12 Sep 2019 17:53:50 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / nkf</title>
            <link>https://tm.root-n.com/unix:command:nkf</link>
            <description>コマンド説明nkfNetwork Kanji Filterの略で、ネットワーク用漢字コード変換フィルタのことです




カレントディレクトリにある全てのファイルを UTF-8 LF に変換する
% for f in `ls`
nkf -w -Lu $f &gt; $f.utf8

カレントディレクトリ以下のすべてのPHPファイルの改行コードを LF に変換する
% find . -name '*.php' | xargs nkf --overwrite -Lu


文字コード変換のオプション
オプション説明-joutput 7-bit JIS code.  This is a default.-soutput MS-kanji (shifted-JIS) code.-eoutput EUC (AT&amp;T) code.-woutput UTF-8 (Unicode 8bit form).
改行コード変換のオプション
オプション説明-Luunix (LF)-Lwwindows (CRLF)-Lmmac (CR)…</description>
        <category>unix:command</category>
            <pubDate>Sun, 16 Mar 2008 22:48:32 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / od</title>
            <link>https://tm.root-n.com/unix:command:od</link>
            <description>コマンド説明od8進, 10進, 16進, ASCIIでのダンプ




主に改行コードを調べるときに使っています
% od -c hoge.txt

次の特殊文字は C エスケープで表現されます
特殊文字CエスケープNUL\0警告\aバックスペース\b改行\n復改\rタブ\t垂直タブ\v</description>
        <category>unix:command</category>
            <pubDate>Sun, 16 Mar 2008 22:48:32 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / openssl</title>
            <link>https://tm.root-n.com/unix:command:openssl</link>
            <description>コマンド説明opensslインターネットで標準的に利用される暗号通信プロトコルである SSL および TLS を実装し、暗号化関連の機能を幅広く提供するコマンド




SSL関連ファイルの整合性を確認する（ペアの確認）

有効期限、CN（コモンネーム）、SANs の確認


% sudo openssl x509 -text -noout -in ＜CRTファイル＞ -noout -dates | less

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
    Signature Algorithm: sha256WithRSAEncryption
        Issuer: C=US, O=GeoTrust Inc., CN=GeoTrust SSL CA - G3
        Validity
            Not Before: Nov 18 0…</description>
        <category>unix:command</category>
            <pubDate>Mon, 16 Jul 2018 19:09:59 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / paco</title>
            <link>https://tm.root-n.com/unix:command:paco</link>
            <description>コマンド説明pacoソースからインストールしたプログラムを管理します。プログラムの概要に「the source code pacKAGE oRGANIZER」とあるように、”pac”kage “o”rganizer を文字って、paco と命名されました。
paco の概要


yum でパッケージ化されていないプログラムをインストールする場合、ソースを自前でコンパイルしてインストールすることになります。

この時、何も考えずにインストール、すなわち「make install」してしまうと、後々後悔するかもしれません。

例えばアンインストールが必要になった場合、「make uninstall」が用意されていないプログラムがほとんどなので、完全にアンインストールできません。

そこで paco の利用をお奨めします。…</description>
        <category>unix:command</category>
            <pubDate>Fri, 11 Oct 2013 10:55:19 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / peco</title>
            <link>https://tm.root-n.com/unix:command:peco</link>
            <description>コマンド説明pecopython のツールである percol がベースのコマンド。標準出力(STDOUT)に対してフィルタリング機能が提供され、インタラクティブ（インクリメンタル）に操作が可能になる
peco の概要


標準出力(STDOUT)に対してフィルタリング機能を提供します。

インクリメンタルに絞り込めるので、現在の表示を見ながら直感的に操作できます。

バイナリファイル単体で動作するため、/usr/local/bin/ などの PATH の通っているディレクトリに配置するだけで、すぐに動作します。…</description>
        <category>unix:command</category>
            <pubDate>Thu, 09 Apr 2015 14:49:35 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / renice</title>
            <link>https://tm.root-n.com/unix:command:renice</link>
            <description>コマンド説明renice実行中のプロセスのプライオリティー(優先度)を変更する




プロセスID「2928」のプロセスのnice値(優先度)を「-10」に変更する
% sudo renice -10 -p 2928

top コマンドで確認してみる


 PID USER PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
2928 alias 8 -10 21104  19m 2868 R 34.3  1.9 259:50.40 /usr/local/bin/hoge</description>
        <category>unix:command</category>
            <pubDate>Sun, 16 Mar 2008 22:48:32 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / rsync</title>
            <link>https://tm.root-n.com/unix:command:rsync</link>
            <description>コマンド説明rsyncリモートホストのファイルやディレクトリの同期を行うアプリケーションソフトウェア




同期を行う

以下の条件で同期を取る設定

	*  同期元ディレクトリ：exsample.com:/path/to/sync (この例ではリモートホスト)
	*  同期先ディレクトリ：/path/to/sync (この例ではローカルホスト)
	*  除外ファイル、ディレクトリ：「hoge」が含まれるファイル、ディレクトリは同期対象から外す…</description>
        <category>unix:command</category>
            <pubDate>Sat, 09 Sep 2017 17:11:12 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / scp</title>
            <link>https://tm.root-n.com/unix:command:scp</link>
            <description>コマンド説明scpSSHプロトコルを使用して、ホスト間でセキュアにファイルをコピーするためのコマンド




Must be connected to a terminal.

scp でファイルをコピーしようとすると「 Must be connected to a terminal. 」でエラーになる場合の対処方法です。</description>
        <category>unix:command</category>
            <pubDate>Sat, 23 Jun 2012 11:42:06 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / screen</title>
            <link>https://tm.root-n.com/unix:command:screen</link>
            <description>コマンド説明screen仮想端末マネージャ(virtual terminal manager)




screen とは

screen とは、ひとつの端末で複数の端末画面を持つことができるソフトウェアです。また、リモートホストに screen 経由でログインしている場合、回線が突然切れたり、ローカルマシンが落ちたとしても、リモートホストとのセッションは自動的にデタッチ状態に入るので、もう一度ログインすれば、アタッチして再度前回の続きから作業が可能になります。…</description>
        <category>unix:command</category>
            <pubDate>Sat, 23 Jun 2012 11:38:20 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / sed</title>
            <link>https://tm.root-n.com/unix:command:sed</link>
            <description>コマンド説明sedStream EDitor の略で、定型的なテキストデータの処理を行うプログラム




複雑な置換処理でよく使います




置換いろいろ

`&amp;'記号：マッチした文字列全体を挿入する
% echo abc def ghi | sed 's/def/&amp;DEF/'
abc defDEF ghi


`g'オプション：(global)マッチした部分を全て置換する
% echo abc def abc ghi | sed 's/abc/ABC/g'
ABC def ABC ghi
`g'オプションを使用しない場合echo abc def abc ghi | sed 's/abc/ABC/'
ABC def abc ghi
２回目に出現する「abc」は置換されない…</description>
        <category>unix:command</category>
            <pubDate>Mon, 14 Jan 2013 11:37:23 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / sort</title>
            <link>https://tm.root-n.com/unix:command:sort</link>
            <description>コマンド説明sortテキストファイル中の行を文字や数値に基づいて昇順(または降順)に並べ替えるオプション説明-M, --month-sort`JAN' &lt; ... &lt; `DEC' のように比較します-n, --numeric-sort数字列として比較します-r, --reverse比較結果を逆順にします-c, --check入力がソートされているかチェックします。ソートしません-k, --key=POS1[,POS2]キーを POS1 から開始し、POS2 までとします-t, --field-separator=SEPフィールドセパレータを非空白文字から空白文字への変わり目ではなく、SEP を使用します…</description>
        <category>unix:command</category>
            <pubDate>Wed, 29 Oct 2008 11:54:36 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / ssh</title>
            <link>https://tm.root-n.com/unix:command:ssh</link>
            <description>コマンド説明sshssh = Secure Shell（セキュアシェル）は、暗号や認証の技術を利用して、安全にリモートコンピュータと通信するためのプロトコル。パスワードなどの認証部分を含むすべてのネットワーク上の通信が暗号化される。</description>
        <category>unix:command</category>
            <pubDate>Thu, 26 Mar 2020 22:17:45 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / tar</title>
            <link>https://tm.root-n.com/unix:command:tar</link>
            <description>コマンド説明tarTape ARchive の略で、多数のファイルを一つのファイルにまとめることが出来る。その際、ファイルのユーザ情報とグループ情報、パーミッション、作成日時、ディレクトリ構造などを同時にアーカイブすることが出来る

tarが行うのはアーカイブ、すなわち複数のファイルをまとめることのみで、圧縮の機能は無い。そのため、compressやgzip、bzip2などの圧縮方法を用いて同時に圧縮を行うのが普通である。これにより、ファイルの拡張子はそれぞれ .tar.Z、.tar.gz、.tar.bz2 となる。特に .tar.Z、.tar.gz は古くから使われており、それぞれ略して .taz、.tgz とされることも多い。…</description>
        <category>unix:command</category>
            <pubDate>Sun, 16 Mar 2008 22:48:33 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / tig</title>
            <link>https://tm.root-n.com/unix:command:tig</link>
            <description>コマンド説明tigCUI の git リポジトリブラウザです。リポジトリに対しての log/diff/検索 の操作が柔軟かつスピーディーに行えます。
	*  インストール


% wget http://jonas.nitro.dk/tig/releases/tig-1.1.tar.gz
% tar -xvf tig-1.1.tar.gz
% cd tig-1.1
% ./configure
% make
% sudo make install</description>
        <category>unix:command</category>
            <pubDate>Mon, 30 Apr 2018 19:02:28 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / uniq</title>
            <link>https://tm.root-n.com/unix:command:uniq</link>
            <description>コマンド説明uniqファイル内の重複行の報告または、フィルタ出力オプション説明-f N比較する時に、各入力行の先頭から N 個のフィールドを無視します。最初のフィールドを 1 として数えます-u重複していない行を抽出する-d重複している行のみ抽出する-c行が入力中に続けて出現した回数を表示し、空白一つあけてその行の内容を表示します</description>
        <category>unix:command</category>
            <pubDate>Sun, 16 Mar 2008 22:48:33 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / useradd・passwd</title>
            <link>https://tm.root-n.com/unix:command:useradd-passwd</link>
            <description>コマンド説明useradd新規ユーザを作成するpasswdユーザのパスワードを作成・更新する





	*  UID:      10001
	*  LOGIN:    superman
	*  GROUP:    supergroup
	*  HOME:     /home/superman
	*  SHELL:    /bin/bash
	*  subGROUP: group1, group2</description>
        <category>unix:command</category>
            <pubDate>Tue, 06 Jul 2010 12:57:25 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / vim</title>
            <link>https://tm.root-n.com/unix:command:vim</link>
            <description>コマンド説明vimvim は vi improved の略で、標準的テキストエディタ vi に「色づけ」や「スクリプト」など、機能を追加した「改良版 vi」です
	*  vim のインストール
	*  readonly のファイルを sudo で強制的に保存する
	*  vimrc の中で他のファイルを読み込む
	*  syntastic を使って、python の文法チェックを pylint で行う</description>
        <category>unix:command</category>
            <pubDate>Wed, 21 Jun 2017 18:35:50 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / wget</title>
            <link>https://tm.root-n.com/unix:command:wget</link>
            <description>コマンド説明wgetコマンドラインで HTTP や FTP 経由のファイル取得を行えるツール






取得したソースを標準出力に吐く
% wget -q -O - http://example.com/-q : quiet_mode (通信ステータスのログを表示しない)

-O : output_document (出力ファイル名の指定) ※ - を指定すると、標準出力に出力される</description>
        <category>unix:command</category>
            <pubDate>Mon, 26 Jul 2010 18:52:10 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / xargs</title>
            <link>https://tm.root-n.com/unix:command:xargs</link>
            <description>コマンド説明xargs標準入力でリストを受け取り、単一の引数に分割して各引数に対しコマンドを実行する






条件にヒットしたファイルを ~/backup にコピーする
% find . -name '*.php' | xargs -i cp {} ~/backup-i : {} を引数リストに置き換える</description>
        <category>unix:command</category>
            <pubDate>Sat, 27 Mar 2021 18:17:03 +0900</pubDate>
        </item>
        <item>
            <title>Unix :: コマンド / zip・unzip</title>
            <link>https://tm.root-n.com/unix:command:zip</link>
            <description>コマンド説明zip複数ファイルを１ファイルにまとめてZIP圧縮します。ZIP は Windowsで一般的に利用されている圧縮形式で、パスワードを設定することも可能です。なお、圧縮率はそれほど高くありません。unzipzip 圧縮されたファイルを解凍します。</description>
        <category>unix:command</category>
            <pubDate>Tue, 11 Aug 2015 20:04:21 +0900</pubDate>
        </item>
    </channel>
</rss>
