差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
| linux:commands [2013/02/04 13:44] – ともやん | linux:commands [2024/04/19 14:56] (現在) – ↷ 移動操作に合わせてリンクを書き換えました。 非ログインユーザー | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| ====== よく使うLinuxコマンド ====== | ====== よく使うLinuxコマンド ====== | ||
| - | [[linux:commands:package_management|パッケージ管理関連]]\\ | + | ===== Linux の基本コマンド ===== | 
| - | [[linux:commands: | + | 本家: | 
| + | ソースコード: [[https:// | ||
| + | GitHub: | ||
| + | 開発者ブログ: [[http:// | ||
| + | 改定履歴: | ||
| + | < | ||
| + | function curlGet($url) { | ||
| + | $curl = curl_init(); | ||
| + | |||
| + | curl_setopt($curl, | ||
| + | curl_setopt($curl, | ||
| + | curl_setopt($curl, | ||
| + | curl_setopt($curl, | ||
| + | |||
| + | $response = curl_exec($curl); | ||
| + | curl_close($curl); | ||
| + | |||
| + | return $response; | ||
| + | } | ||
| + | $res = curlGet(' | ||
| + | $lines = explode(" | ||
| - | ==== 圧縮ファイルの圧縮/ | + | echo '最新バージョン: '.$lines[0]; | 
| - | === tar.gz(圧縮) === | + | </php>\\ | 
| - | < | + | |
| - | $ tar zcvf filename.tar.gz targetdir/ | + | |
| - | </ | + | |
| - | === tar.gz(解凍) === | + | |
| - | < | + | |
| - | $ tar zxvf filename.tar.gz | + | |
| - | </ | + | |
| - | === tar.bz2(圧縮) === | + | |
| - | < | + | |
| - | $ tar jcvf filename.tar.bz2 targetdir/ | + | |
| - | </ | + | |
| - | === tar.bz2(解凍) === | + | |
| - | < | + | |
| - | $ tar jxvf filename.tar.bz2 | + | |
| - | </ | + | |
| - | === split (ファイルの分割) === | + | |
| - | < | + | |
| - | $ split -b " | + | |
| - | </ | + | |
| - | ※ ファイルのバイト数で変換したい場合 -b 数値 を使用。 数値の最後にmをつけるとメガバイト、kをつけるとキロバイトで数値指定可能 | + | |
| - | 例) split -b 8m " | + | |
| - | 参考URL: | + | |
| - | === 特定のディレクトリやファイルを除外 === | + | |
| - | < | + | |
| - | $ tar jcvf filename.tar.bz2 targetdir/ --exclude / | + | |
| - | </ | + | |
| - | ===== ファイル&ディレクトリ関連 ===== | + | |
| - | ==== ディレクトリの作成[mkdir] ==== | + | |
| - | 書式: | + | |
| - | < | + | |
| - | $ mkdir [-pv] [-m mode] [--help] [--version] [--] directory... | + | |
| - | </ | + | |
| - | ^オプション^説明^ | + | |
| - | |-p  |directory に指定されたパスに存在しない親フォルダが含まれる場合はエラーとせずに作成する。 | + | |
| - | |-v  |作成したディレクトリごとにメッセージ表示。-p と一緒に使用する。 | + | |
| - | |-m // | + | |
| - | 実行例: | + | |
| - | <code bash> | + | |
| - | $ mkdir tmp | + | |
| - | $ mkdir -m 755 cgi-bin | + | |
| - | $ mkdir -pv usr/bin | + | |
| - | mkdir: created directory `usr' | + | |
| - | mkdir: created directory `usr/ | + | |
| - | </ | + | |
| - | + | ||
| - | ==== ファイルの削除[rm] ==== | + | |
| - | <code bash> | + | |
| - | $ rm fileName.ext | + | |
| - | rm: remove 通常ファイル ' | + | |
| - | </ | + | |
| - | ==== ファイルの削除(確認なし) [rm -f] ==== | + | |
| - | <code bash> | + | |
| - | $ rm -f fileName.ext | + | |
| - | </ | + | |
| - | + | ||
| - | ==== ディレクトリをサブディレクトリを含めて削除[rm -r] ==== | + | |
| - | <code bash> | + | |
| - | $ rm -r directoryName | + | |
| - | rm: descend into directory ' | + | |
| - | rm: descend into directory ' | + | |
| - | ... | + | |
| - | </code> | + | |
| - | + | ||
| - | ==== ディレクトリをサブディレクトリを含めて削除(確認なし)[rm -rf] ==== | + | |
| - | <code bash> | + | |
| - | $ rm -rf directoryName | + | |
| - | </ | + | |
| - | + | ||
| - | ==== ディレクトリの容量 ==== | + | |
| - | < | + | |
| - | $ du -h -s dir_name | + | |
| - | 1.6G dir_name | + | |
| - | </ | + | |
| - | + | ||
| - | ==== シンボルリンクをはる[ln] ==== | + | |
| - | < | + | |
| - | $ ln -s [src] [dist] | + | |
| - | </ | + | |
| - | 例: | + | |
| - | < | + | |
| - | $ ln -s /var/www www_root | + | |
| - | $ ls -al | + | |
| - | lrwxrwxrwx | + | |
| - | + | ||
| - | $ ln -s /var/www | + | |
| - | $ ls -al | + | |
| - | lrwxrwxrwx | + | |
| - | </ | + | |
| - | ==== 前方/ | + | |
| - | lessコマンドはmoreコマンドに似ているが、とても高機能なページャである。\\ | + | |
| \\ | \\ | ||
| - | 書式: | + | Linux の基本コマンドは **util-linux** パッケージに収められており、どの Linux にも標準でインストールされている。\\ | 
| - | < | + | |
| - | less -? | + | |
| - | less --help | + | |
| - | less -V | + | |
| - | less --version | + | |
| - | less [-[+]aBcCdeEfgGiImMnNqQrsSuUVWwXZ] | + | |
| - | [-b bufs] [-h lines] [-j line] [-k keyfile] | + | |
| - | [-K character set] [-{oO} logfile] | + | |
| - | [-p pattern] [-P prompt] [-t tag] | + | |
| - | [-T tagsfile] [-x tab] [-y lines] [-[z] lines] | + | |
| - |  | + | |
| - | </ | + | |
| - | オプションの詳細は、man lessを参照。\\ | + | |
| - | \\ | + | |
| - | 実行例: | + | |
| - | < | + | |
| - | $ less filename.txt | + | |
| - | 〜省略〜 | + | |
| - | (END) q <- 表示を終了するにはqキーを入力する。 | + | |
| - | $ ls -al | less <- コマンドの出力結果を、↑↓キーで移動表示ができる。 | + | ===== カテゴリー別 (util-linux 以外も含む) | 
| - | 〜省略〜 | + | [[linux:commands:package_management|パッケージ管理関連]]\\ | 
| - | (END) q <- 表示を終了するにはqキーを入力する。 | + | [[linux:commands:manage_user_group|ユーザー・グループ管理]]\\ | 
| - | + | [[linux:commands:login|ログイン管理関連]]\\ | |
| - | $ less /usr <- ls -al | less と同じ。 | + | [[linux:commands:disk_manage|ディスク管理関連]]\\ | 
| - | 合計 408 | + | [[linux:commands:file_directory|ファイル&ディレクトリ関連]]\\ | 
| - | drwxr-xr-x | + | [[linux:commands:job|ジョブ関連]]\\ | 
| - | drwxr-xr-x | + | [[linux:commands:process|プロセス関連]]\\ | 
| - | drwxr-xr-x | + | [[linux:commands:system_log|システムログ関連]]\\ | 
| - | drwxr-xr-x | + | [[linux:commands:network|ネットワーク関連]]\\ | 
| - | 〜省略〜 | + | [[linux:commands:service|サービス関連]]\\ | 
| - | /usr (END) q <- 表示を終了するにはqキーを入力する。 | + | [[linux:commands:hardware|ハードウェア関連]]\\ | 
| - | </ | + | [[linux:commands: | 
| - | + | ||
| - | ==== ファイルのみ、ディレクトリのみに chmod ==== | + | |
| - | ファイルのみ | + | |
| - | < | + | |
| - | $ sudo sh -c 'find . -type f -print | xargs chmod 644' | + | |
| - | </ | + | |
| - | + | ||
| - | ディレクトリのみ | + | |
| - | < | + | |
| - | $ sudo sh -c 'find . -type d -print | xargs chmod 755' | + | |
| - | </ | + | |
| - | + | ||
| - | ==== メール | + | |
| - | === メールを読む === | + | |
| - | < | + | |
| - | + | ||
| - | Heirloom Mail version 12.4 7/ | + | |
| - | "/ | + | |
| - | >   1 Cron Daemon | + | |
| - | 2 logwatch@monster | + | |
| - | 3 logwatch@monster | + | |
| - | 4 logwatch@monster | + | |
| - | 5 Mail Delivery Su  Fri Jun 26 00:52  77/ | + | |
| - | 6 logwatch@monster | + | |
| - | 7 logwatch@monster | + | |
| - | 8 logwatch@monster | + | |
| - | 9 logwatch@monster | + | |
| - | 10 logwatch@monster | + | |
| - | 11 logwatch@monster | + | |
| - | 12 logwatch@monster | + | |
| - | 13 logwatch@monster | + | |
| - | & t <- メッセージの表示は t コマンドを入力 | + | |
| - | Message | + | |
| - | From root@monster.fireball.local | + | |
| - | Return-Path: < | + | |
| - | Date: Tue, 23 Jun 2009 01:01:36 +0900 | + | |
| - | From: root@monster.fireball.local (Cron Daemon) | + | |
| - | To: root@monster.fireball.local | + | |
| - | Subject: Cron < | + | |
| - | Content-Type: text/plain; charset=UTF-8 | + | |
| - | Auto-Submitted: auto-generated | + | |
| - | X-Cron-Env: < | + | |
| - | X-Cron-Env: < | + | |
| - | X-Cron-Env: < | + | |
| - | X-Cron-Env: < | + | |
| - | X-Cron-Env: < | + | |
| - | X-Cron-Env: < | + | |
| - | Status: RO | + | |
| - | + | ||
| - | / | + | |
| - | + | ||
| - | cat: / | + | |
| - | + | ||
| - | & q <- mailコマンドを終了するには q コマンドを入力 | + | |
| - | </ | + | |
| - | + | ||
| - | ===== 参考文献 ===== | + | |
| - | [[http:// | + | |