linux:commands

差分

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

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
linux:commands [2012/11/01 13:19] – [シンボルリンクをはる[ln]] ともやんlinux:commands [2024/04/19 14:56] (現在) – ↷ 移動操作に合わせてリンクを書き換えました。 非ログインユーザー
行 1: 行 1:
 ====== よく使うLinuxコマンド ====== ====== よく使うLinuxコマンド ======
-===== パッケージ管理関連 ===== 
-==== パッケージ インストール/アップデート/アンインストール [yum] ==== 
-=== インストール済パッケージの一覧表示 === 
-<code> 
-# yum list installed 
-読み込んだプラグイン:fastestmirror, refresh-packagekit 
-Loading mirror speeds from cached hostfile 
- * fedora: ftp.iij.ad.jp 
- * livna: rpm.livna.org 
- * rpmfusion-free: mirror.yandex.ru 
- * rpmfusion-free-updates: mirror.yandex.ru 
- * rpmfusion-nonfree: mirror.yandex.ru 
- * rpmfusion-nonfree-updates: mirror.yandex.ru 
- * updates: ftp.iij.ad.jp 
-インストール済みパッケージ 
-389-admin.x86_64                      1.1.8-4.fc11                      @updates        
-389-admin-console.noarch              1.1.4-1.fc11                      @updates        
-389-admin-console-doc.noarch          1.1.4-1.fc11                      @updates        
-~省略~ 
-</code> 
  
-=== ンスル === +===== Linux の基本コマド ===== 
-<code+本家: [[https://www.kernel.org/pub/linux/utils/util-linux/|util-linux - kernel.org]]\\ 
-# yum install package_name +ソード: [[https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git|util-linux/util-linux.git - The util-linux code repository.]]\\ 
-</code>+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'); 
-<code> +$lines explode("\n", $res);
-# yum update package_name +
-</code>+
  
-=== アンインストル === +echo '最新バージョン: '.$lines[0]; 
-<code> +</php>\\
-# yum remove package_name +
-</code> +
- +
-=== 一時的にリポトリを有効化 === +
-<code> +
-# yum --enablerepo=remi install package_name +
-</code> +
-==== パッケージ インストール/アップデート/アンインストール [rpm] ==== +
-=== インストール済パッケージの一覧表示 === +
-<code> +
-$ rpm -qa +
-</code> +
- +
-grep との組み合わせ +
-<code> +
-$ rpm -qa | grep kernel +
-kernel-headers-2.6.19-1.2911.fc6 +
-kernel-2.6.19-1.2911.fc6 +
-kernel-devel-2.6.19-1.2911.fc6 +
-</code> +
- +
-=== インストール === +
-<code> +
-$ rpm -ivh filename.rpm +
-</code> +
-vhオプションは処理状況を表示する。 +
- +
-=== アップデート === +
-<code> +
-$ rpm -Uvh filename.rpm +
-</code> +
- +
-=== アンインストール === +
-<code> +
-$rpm -e filename.rpm +
-</code> +
- +
-=== パッケージに含まれるファイルの一覧表示 === +
-<code> +
-$ rpm -ql phpMyAdmin +
-/etc/httpd/conf.d/phpMyAdmin.conf +
-/etc/phpMyAdmin +
-/etc/phpMyAdmin/config.inc.php +
-/usr/share/doc/phpMyAdmin-2.11.11.1 +
-/usr/share/doc/phpMyAdmin-2.11.11.1/CREDITS +
-/usr/share/doc/phpMyAdmin-2.11.11.1/Documentation.txt +
-〜省略〜 +
-</code> +
- +
-=== パッケージの詳細情報を表示 === +
-<code> +
-$ rpm -qi python +
-Name        : python                       Relocations: (not relocatable) +
-Version     : 2.4.3                             Vendor: CentOS +
-Release     : 27.el5_5.3                    Build Date: 2010年11月12日 03時36分24秒 +
-Install Date: 2010年12月17日 17時52分09秒      Build Host: builder10.centos.org +
-Group       : Development/Languages         Source RPM: python-2.4.3-27.el5_5.3.src.rpm +
-Size        : 22130370                         License: PSF - see LICENSE +
-Signature   : DSA/SHA1, 2010年11月12日 09時22分06秒, Key ID a8a447dce8562897 +
-URL         : http://www.python.org/ +
-Summary     : 対話式、オブジェクト指向のインタープリタ言語 +
-Description : +
-Python is an interpreted, interactive, object-oriented programming +
-language often compared to Tcl, Perl, Scheme or Java. Python includes +
-modules, classes, exceptions, very high level dynamic data types and +
-dynamic typing. Python supports interfaces to many system calls and +
-libraries, as well as to various windowing systems (X11, Motif, Tk, +
-Mac and MFC). +
- +
-Programmers can write new built-in modules for Python in C or C++. +
-Python can be used as an extension language for applications that need +
-a programmable interface. This package contains most of the standard +
-Python modules, as well as modules for interfacing to the Tix widget +
-set for Tk and RPM. +
- +
-Note that documentation for Python is provided in the python-docs +
-package. +
-</code> +
- +
-=== 強制インストール === +
-<code> +
-$rpm -ivh --force --nodeps {ファイル名}:強制インストール(新規インストール & 依存関係無視) +
-</code> +
- +
-===== ログイン関連 ===== +
-==== 一時的にユーザを切り替える[su -] ==== +
-suコマンドはユーザを切り替えて新たなシェルを起動する。\\+
 \\ \\
-<html><span style="color: red"> +Linux 基本コマンドは **util-linux** パッケジに収めらており、どの Linux も標準でインストーされている。\\
-注意:<br/> +
- rootになる際に[su -][-]を付け忘れると、現在のユーザの環境が引き継がれてrootに切り替わる。<br/> +
- その為、スーパーユーザなのにcommand not foundと言われることになる。<br/> +
-</span></html>\\ +
-書式: +
-<code> +
-su [-flmp] [-c command] [-s shell] [-] [--help] [--version] [user [arg...]] +
-</code> +
-^オプショ^説明^ +
-|-c //command//|ユーザ切り替え後に//command//を実行して元のシェルに戻る。| +
-|-f|スタートアップファイル(.cshrc)を読み込まない。| +
-|-, -l|ログインシェルを使用しユーザを切り替える。指定したユーザの環境がローされる。| +
-|-m, -p|環境変数‘HOME’、‘USER’、‘LOGNAME’、‘SHELL’を変更しない。| +
-|-s //shell//|/etc/passwdに設定されたuserのシェルの代わりに//shell//を実行する。| +
-|--help|使用方法を表示する。| +
-|--version|バージョンを表示する。| +
-|//user// [//arg//...]|//user//を指定する。//arg//ログインシェルに渡す引数を指定する。| +
- +
-実行例: +
-<code> +
-$ 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 +
-mkdir: created 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コマンドに似ているが、とても高機能なページャである。\\ +
-\\ +
-書式: +
-<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      <- コマンドの出力結果を、↑↓キーで移動表示ができる。 +
-〜省略〜 +
-(END) q              <- 表示を終了するにはqキーを入力する。 +
- +
-$ less /usr          <- ls -al | less と同じ。 +
-合計 408 +
-drwxr-xr-x  16 root root   4096 2008-12-08 14:47 ./ +
-drwxr-xr-x  25 root root   4096 2009-01-22 21:10 ../ +
-drwxr-xr-x   2 root root   4096 2007-06-08 17:07 X11R6/ +
-drwxr-xr-x   2 root root  94208 2009-01-19 21:53 bin/ +
-〜省略〜 +
-/usr (END) q         <- 表示を終了するにはqキーを入力する。 +
-</code> +
- +
-==== ファイルのみ、ディレクトリのみに 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> +
-Date: Tue, 23 Jun 2009 01:01:36 +0900 +
-From: root@monster.fireball.local (Cron Daemon) +
-To: root@monster.fireball.local +
-Subject: Cron <root@monster> run-parts /etc/cron.hourly +
-Content-Type: text/plain; charset=UTF-8 +
-Auto-Submitted: auto-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> +
-Status: RO +
- +
-/etc/cron.hourly/0anacron: +
- +
-cat: /var/spool/anacron/cron.daily: No such file or directory +
- +
-& q    <- mailコマンドを終了するには q コマンドを入力 +
-</code>+
  
-===== 参考文献 ===== +===== カテゴリー別 (util-linux 以外も含む) ===== 
-[[http://www.atmarkit.co.jp/flinux/rensai/linuxtips/012easycd.html|特定のディレクトリ間を素早く移動するには]]\\+[[linux:commands:package_management|パッケージ管理関連]]\\ 
 +[[linux:commands:manage_user_group|ユーザー・グループ管理]]\\ 
 +[[linux:commands:login|ログイン管理関連]]\\ 
 +[[linux:commands:disk_manage|ディスク管理関連]]\\ 
 +[[linux:commands:file_directory|ファイル&ディレクトリ関連]]\\ 
 +[[linux:commands:job|ジョブ関連]]\\ 
 +[[linux:commands:process|プロセス関連]]\\ 
 +[[linux:commands:system_log|システムログ関連]]\\ 
 +[[linux:commands:network|ネットワーク関連]]\\ 
 +[[linux:commands:service|サービス関連]]\\ 
 +[[linux:commands:hardware|ハードウェア関連]]\\ 
 +[[linux:commands:mail|メール関連]]\\
  • linux/commands.1351743552.txt.gz
  • 最終更新: 2019/05/18 02:23
  • (外部編集)