linux:commands

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
linux:commands [2013/02/04 13:42] ともやんlinux:commands [2024/04/19 14:56] (現在) – ↷ 移動操作に合わせてリンクを書き換えました。 非ログインユーザー
行 1: 行 1:
 ====== よく使うLinuxコマンド ====== ====== よく使うLinuxコマンド ======
  
-[[linux:commands:package_management|パッケージ管理関連]]\\+===== Linux の基本コマンド ===== 
 +本家: [[https://www.kernel.org/pub/linux/utils/util-linux/|util-linux - kernel.org]]\\ 
 +ソースコード[[https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git|util-linux/util-linux.git - The util-linux code repository.]]\\ 
 +GitHub: [[https://github.com/karelzak/util-linux|karelzak/util-linux]]\\ 
 +開発者ブログ: [[http://karelzak.blogspot.com/|Karel Zak's blog]]\\ 
 +改定履歴: [[http://git.kernel.org/?p=utils/util-linux/util-linux.git;a=log|util-linux - ChangeLog]]\\ 
 +<php> 
 +function curlGet($url) { 
 +  $curl = curl_init(); 
 +   
 +  curl_setopt($curl, CURLOPT_URL, $url); 
 +  curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET'); 
 +  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 証明書の検証を行わない 
 +  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);  // curl_execの結果を文字列で返す 
 +   
 +  $response = curl_exec($curl); 
 +  curl_close($curl); 
 +   
 +  return $response; 
 +}
  
-===== ログイン関連 ===== +$res curlGet('https://raw.githubusercontent.com/karelzak/util-linux/master/NEWS'); 
-==== 一時的にユーザを切り替える[su -] ==== +$lines = explode("\n"$res);
-suコマンドはユーザを切り替えて新たなシェルを起動する。\\ +
-\\ +
-<html><span style="color: red"> +
-注意:<br/+
- rootになる際に[su -]の[-]を付け忘れると、現在のユーザの環境が引き継がれてrootに切り替わる。<br/+
- その為、スーパーユーザなのにcommand not foundと言われることになる。<br/> +
-</span></html>\\ +
-書式: +
-<code> +
-su [-flmp] [-c command] [-s shell] [-] [--help] [--version] [user [arg...]] +
-</code> +
-^オプション^説明^ +
-|-//command//|ユーザ切り替え後に//command//を実行して元のシェルに戻る。| +
-|-f|スタートアップファイル(.cshrc)を読み込まない。| +
-|--l|ログインシェルを使用しユーザを切り替える。指定したユーザの環境がロードされる。| +
-|-m, -p|環境変数‘HOME’、‘USER’、‘LOGNAME’、‘SHELL’を変更しない。| +
-|-s //shell//|/etc/passwdに設定されたuserのシェルの代わりに//shell//を実行する。| +
-|--help|使用方法を表示する。| +
-|--version|バージョンを表示する。| +
-|//user// [//arg//...]|//user//を指定する。//arg//はログインシェルに渡す引数を指定する。|+
  
-実行例: +echo 'ージョン: '.$lines[0]; 
-<code> +</php>\\
-$ su -                 <- userが未指定なのでrootになる。 +
-パスワード: ********** <- パスワードは表示されない。 +
-# exit                 <- 終了するには exit または logout を入力する。 +
-logout +
-</code> +
- +
-==== 圧縮ファイルの圧縮/解凍[tar] ==== +
-=== tar.gz(圧縮) === +
-<code> +
-$ tar zcvf filename.tar.gz targetdir/ +
-</code> +
-=== tar.gz(解凍) === +
-<code> +
-$ tar zxvf filename.tar.gz +
-</code> +
-=== tar.bz2(圧縮) === +
-<code> +
-$ tar jcvf filename.tar.bz2 targetdir/ +
-</code> +
-=== tar.bz2(解凍) === +
-<code> +
-$ tar jxvf filename.tar.bz2 +
-</code> +
-=== split (ファイルの分割) === +
-<code> +
-$ split -b "数値" "分割したいfile名" "変更後のファイルの接頭語" +
-</code> +
-※ ファイルのバイト数で変換したい場合 -b 数値 を使用。 数値の後にmをつけるとメガイト、kをつけるとキロバイトで数値指定可能 +
-例) split -b 8m "分割したいfile名" "変更後のファイルの接頭語" → 8メガバイトで分割 +
-参考URL: http://www.k4.dion.ne.jp/~mms/unix/linux_com/split.html +
-=== 特定のディレクトリやファイルを除外 === +
-<code> +
-$ tar jcvf filename.tar.bz2 targetdir/ --exclude /exclude/dirname +
-</code> +
-===== ファイル&ディレクトリ関連 ===== +
-==== ディレクトリの作成[mkdir] ==== +
-書式: +
-<code> +
-$ mkdir [-pv] [-m mode] [--help] [--version] [--] directory... +
-</code> +
-^オプション^説明^ +
-|-p  |directory に指定されたパスに存在しない親フォルダが含まれる場合はエラーとせずに作成する。 +
-|-v  |作成したディレクトリごとにメッセージ表示。-p と一緒に使用する。 +
-|-m //mode//  |作成されるディレクトリのアクセス権を指定する。mode は chmod と同じ。 +
-実行例: +
-<code bash> +
-$ mkdir tmp +
-$ mkdir -m 755 cgi-bin +
-$ mkdir -pv usr/bin +
-mkdircreated directory `usr' +
-mkdir: created directory `usr/bin' +
-</code> +
- +
-==== ファイルの削除[rm] ==== +
-<code bash> +
-$ rm fileName.ext +
-rm: remove 通常ファイル 'fileName.ext'? y[Enter] +
-</code> +
-==== ファイルの削除(確認なし) [rm -f] ==== +
-<code bash> +
-rm -f fileName.ext +
-</code> +
- +
-==== ディレクトリをサブディレクトリを含めて削除[rm -r] ==== +
-<code bash> +
-$ rm -r directoryName +
-rm: descend into directory 'directoryName'? y[Enter] +
-rm: descend into directory 'directoryName/subDirectory'? y[Enter] +
-... +
-</code> +
- +
-==== ディレクトリをサブディレクトリを含めて削除(確認なし)[rm -rf] ==== +
-<code bash> +
-$ rm -rf directoryName +
-</code> +
- +
-==== ディレクトリの容量 ==== +
-<code> +
-$ du -h -s dir_name +
-1.6G    dir_name +
-</code> +
- +
-==== シンボルリンクをはる[ln] ==== +
-<code> +
-$ ln -s [src] [dist] +
-</code> +
-例: +
-<code> +
-$ ln -s /var/www www_root +
-$ ls -al +
-lrwxrwxrwx  1 tomoyan tomoyan 42 11月  1 13:15 2012 www_root-> /var/www +
- +
-$ ln -s /var/www +
-$ ls -al +
-lrwxrwxrwx  1 tomoyan tomoyan 42 11月  1 13:15 2012 www-> /var/www +
-</code> +
-==== 前方/後方移動が可能なファイル表示[less] ==== +
-lessコマンドはmoreコマンドに似ているが、とても高機能なページャである。\\+
 \\ \\
-書式: +Linux の基本コマは **util-linux** パッケージに収められておりどの Linux にも標準でンストールされてる。\\
-<code> +
-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] +
-     [+[+]cmd] [--] [filename]... +
-</code> +
-オプショの詳細は、man lessを参照。\\ +
-\\ +
-実行例: +
-<code> +
-$ 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  16 root root   4096 2008-12-08 14:47 ./ +[[linux:commands:job|ジョブ関連]]\\ 
-drwxr-xr-x  25 root root   4096 2009-01-22 21:10 ../ +[[linux:commands:process|プロセス関連]]\\ 
-drwxr-xr-x   2 root root   4096 2007-06-08 17:07 X11R6/ +[[linux:commands:system_log|システムログ関連]]\\ 
-drwxr-xr-x   2 root root  94208 2009-01-19 21:53 bin/ +[[linux:commands:network|ネットワーク関連]]\\ 
-〜省略〜 +[[linux:commands:service|サービス関連]]\\ 
-/usr (END) q         <- 表示を終了するにはqキーを入力する。 +[[linux:commands:hardware|ハーウェア関連]]\\ 
-</code> +[[linux:commands:mail|メール関連]]\\
- +
-==== ファイルのみ、ディレクトリのみに chmod ==== +
-ファイルのみ +
-<code> +
-$ sudo sh -c 'find . -type f -print | xargs chmod 644' +
-</code> +
- +
-ディレクトのみ +
-<code> +
-$ sudo sh -c 'find . -type d -print | xargs chmod 755' +
-</code> +
- +
-==== メール ==== +
-=== メールを読む === +
-<code> +
-# mail +
-Heirloom Mail version 12.4 7/29/08.  Type ? for help. +
-"/var/spool/mail/root"13 messages +
->   1 Cron Daemon       Tue Jun 23 12:10  27/1028  "Cron <root@monster> run-part" +
-    2 logwatch@monster  Tue Jun 23 13:27  44/1622  "Logwatch for monster (Linux)" +
-    3 logwatch@monster  Thu Jun 25 11:04  59/1953  "Logwatch for monster (Linux)" +
-    4 logwatch@monster  Thu Jun 25 12:37  59/1953  "Logwatch for monster (Linux)" +
-    5 Mail Delivery Su  Fri Jun 26 00:52  77/2443  "Returned mail: see transcrip" +
-    6 logwatch@monster  Fri Jun 26 03:10 148/4540  "Logwatch for monster (Linux)" +
-    7 logwatch@monster  Sat Jun 27 11:06 115/3263  "Logwatch for monster (Linux)" +
-    8 logwatch@monster  Sun Jun 28 03:45 142/4391  "Logwatch for monster (Linux)" +
-    9 logwatch@monster  Tue Jul  7 03:17  88/2575  "Logwatch for monster (Linux)" +
-   10 logwatch@monster  Wed Jul  8 03:13 105/3058  "Logwatch for monster (Linux)" +
-   11 logwatch@monster  Thu Jul  9 03:26  97/2783  "Logwatch for monster (Linux)" +
-   12 logwatch@monster  Fri Jul 10 03:13  78/2304  "Logwatch for monster (Linux)" +
-   13 logwatch@monster  Sat Jul 11 06:49 102/2945  "Logwatch for monster (Linux)" +
-& t    <- メージの表示は t コマンドを入力 +
-Message  1: +
-From root@monster.fireball.local  Tue Jun 23 12:10:53 2009 +
-Return-Path<root@monster.fireball.local> +
-DateTue, 23 Jun 2009 01:01:36 +0900 +
-Fromroot@monster.fireball.local (Cron Daemon) +
-Toroot@monster.fireball.local +
-SubjectCron <root@monster> run-parts /etc/cron.hourly +
-Content-Typetext/plain; charset=UTF-8 +
-Auto-Submittedauto-generated +
-X-Cron-Env<SHELL=/bin/bash> +
-X-Cron-Env<PATH=/sbin:/bin:/usr/sbin:/usr/bin> +
-X-Cron-Env<MAILTO=root> +
-X-Cron-Env<HOME=/> +
-X-Cron-Env<LOGNAME=root> +
-X-Cron-Env<USER=root> +
-StatusRO +
- +
-/etc/cron.hourly/0anacron+
- +
-cat/var/spool/anacron/cron.dailyNo such file or directory +
- +
-& q    <- mailコマンドを終了するには q コマンを入力 +
-</code> +
- +
-===== 参考文献 ===== +
-[[http://www.atmarkit.co.jp/flinux/rensai/linuxtips/012easycd.html|特定のディレクトリ間を素早く移動するには]]\\+
  • linux/commands.1359952925.txt.gz
  • 最終更新: 2019/05/18 02:23
  • (外部編集)