Last active
September 25, 2020 14:37
-
-
Save ponsuke0531/f2236dd8d7a0552065226fa0b2218de2 to your computer and use it in GitHub Desktop.
Linuxコマンドでやりたいことをやるためのリンク集 ref: https://qiita.com/ponsuke0531/items/73895dcdbb5ddd7d3331
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# インストールしたものを見たい | |
$ sudo dpkg -l | |
# インストールしたい | |
$ sudo apt-get -y install {インストールしたいもの} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(Cntrol + R) | |
$ (reverse-i-search)`cd': cd {ディレクトリ} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat -n {ファイル} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
再帰的に見たい。 | |
$ ls -R | |
ディレクトリだけパスだけ一覧で見たい。 | |
$ find {見たい場所} -type d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RHEL6以前 | |
# 自動起動サービスの一覧 | |
$ ls -la /etc/init.d/ | |
# RHEL7以降 | |
# サービスの一覧(状態付き) | |
$ systemctl list-unit-files --type=service | |
# サービスの一覧(依存関係と状態付き) | |
$ systemctl list-dependencies | |
# 自動起動の確認 | |
$ systemctl is-enabled {サービス}yum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ls -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 任意の文字列が含まれる行数を数えたい | |
$ grep -a {任意の文字列} {ファイルパス} | wc -l | |
## 例) hoge.iniで「key(大文字小文字区別なし)」かつ「;(コメント)で始まらない」行数を数えたい | |
$ grep -ai key hoge.ini | grep ^[^\;] | wc -l | |
# 任意の文字列が含まれる行数を数えたい | |
$ grep -c {任意の文字列} {ファイルパス} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
再帰的に見たい。 | |
$ ls -R | |
ディレクトリだけパスだけ一覧で見たい。 | |
$ find {見たい場所} -type d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ss -version | |
ss utility, iproute2-ss170501 | |
# 名前解決しない(n)で接続全部(a)のTCP(t)とUDP(u)をみる | |
$ ss -natu | |
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port | |
udp UNCONN 0 0 *:68 *:* | |
tcp LISTEN 0 128 *:111 *:* | |
$ netstat --version | |
net-tools 1.60 | |
netstat 1.42 (2001-04-15) | |
# 名前解決しない(n)で接続全部(a)のTCP(t)とUDP(u)をみる | |
$ netstat -natu | |
Active Internet connections (servers and established) | |
Proto Recv-Q Send-Q Local Address Foreign Address State | |
tcp 1 0 127.0.0.1:12345 127.0.0.1:1234 CLOSE_WAIT | |
udp 0 0 127.0.0.1:54321 0.0.0.0:* | |
# Windowsの場合 : 名前解決しない(n)で接続全部(a)をプロセスIDと合わせて(o)みる | |
$ netstat -nao | |
アクティブな接続 | |
プロトコル ローカル アドレス 外部アドレス 状態 PID | |
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4104 | |
UDP [::1]:52633 *:* 6704 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
再帰的に見たい。 | |
$ ls -R | |
ディレクトリだけパスだけ一覧で見たい。 | |
$ find {見たい場所} -type d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ locale | |
LANG=ja_JP.utf8 | |
LC_CTYPE="ja_JP.utf8" | |
LC_NUMERIC="ja_JP.utf8" | |
LC_TIME="ja_JP.utf8" | |
LC_COLLATE="ja_JP.utf8" | |
LC_MONETARY="ja_JP.utf8" | |
LC_MESSAGES="ja_JP.utf8" | |
LC_ALL=ja_JP.utf8 | |
# ロケールに設定できるのを見たい。大量にあるから日本のだけ。 | |
$ locale -a | grep -i ja | |
ja_JP | |
ja_JP.utf8 | |
ja_JP@cjknarrow | |
ja_JP.utf8@cjknarrow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
再帰的に見たい。 | |
$ ls -R | |
ディレクトリだけパスだけ一覧で見たい。 | |
$ find {見たい場所} -type d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ip addr show <------ MacOSで使うにはインストールが必要です | |
$ ip route | |
$ curl ifconfig.co <-------- インターネットへの接続が必要です | |
$ ifconfig <--- CentOSで使うにはインストールが必要です |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
再帰的に見たい。 | |
$ ls -R | |
ディレクトリだけパスだけ一覧で見たい。 | |
$ find {見たい場所} -type d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 設定した環境変数を見たい。 | |
$ printenv {環境変数名} | |
# PATHを見たい。 | |
$ printenv PATH | |
/usr/local/bin:/Users/mana/.phpenv/shims:/Users/mana/.phpenv/bin:...:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin | |
# PATHを改行で見やすく区切ってみたい | |
$ printenv PATH | sed -e 's/:/:\n/g' | |
/c/app/Java/jdk1.8.0_231/: | |
... | |
/mingw64/bin: | |
/usr/local/bin: | |
/usr/bin: | |
/bin: | |
# 曖昧な名前で見たい。 | |
$ printenv | grep -i oracle | |
# 環境変数を設定したい(bash) | |
$ echo 'export {環境変数名}="{環境変数値}"' >> ~/.bash_profile | |
$ source .bash_profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
再帰的に見たい。 | |
$ ls -R | |
ディレクトリだけパスだけ一覧で見たい。 | |
$ find {見たい場所} -type d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ diff {ファイル名1} {ファイル名2} | |
$ diff –r {ディレクトリパス1} (ディレクトリパス2} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ls -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ログファイルを削除 | |
$ rm {ログファイルがあるディレクトリパス}\*.log | |
# 空っぽのディレクトリ削除 | |
$ rm -d {ディレクトリ} | |
# 中身もろともガッツリ削除 | |
$ rm -rf {ディレクトリ} | |
# ディレクトリは残してファイル削除 | |
$ find {ディレクトリ} -type f | xargs rm | |
# 名前の一部を指定してディレクトリ配下までファイル削除:なかったら何もしない | |
$ find {ディレクトリ} -type f -name {名前の一部} | xargs --no-run-if-empty rm | |
# パスに半角スペースが含まれるファイルをfindして任意の文字でgrepして一括削除する | |
$ find {ディレクトリ} -type f | grep -i {ファイル名の一部} | sed -e 's/ /\\ /g' | xargs rm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
再帰的に見たい。 | |
$ ls -R | |
ディレクトリだけパスだけ一覧で見たい。 | |
$ find {見たい場所} -type d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 設定した環境変数を見たい。 | |
$ printenv {環境変数名} | |
# PATHを見たい。 | |
$ printenv PATH | |
/usr/local/bin:/Users/mana/.phpenv/shims:/Users/mana/.phpenv/bin:...:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin | |
# PATHを改行で見やすく区切ってみたい | |
$ printenv PATH | sed -e 's/:/:\n/g' | |
/c/app/Java/jdk1.8.0_231/: | |
... | |
/mingw64/bin: | |
/usr/local/bin: | |
/usr/bin: | |
/bin: | |
# 曖昧な名前で見たい。 | |
$ printenv | grep -i oracle | |
# 環境変数を設定したい(bash) | |
$ echo 'export {環境変数名}="{環境変数値}"' >> ~/.bash_profile | |
$ source .bash_profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ls -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ログファイルを削除 | |
$ rm {ログファイルがあるディレクトリパス}\*.log | |
# 空っぽのディレクトリ削除 | |
$ rm -d {ディレクトリ} | |
# 中身もろともガッツリ削除 | |
$ rm -rf {ディレクトリ} | |
# ディレクトリは残してファイル削除 | |
$ find {ディレクトリ} -type f | xargs rm | |
# 名前の一部を指定してディレクトリ配下までファイル削除:なかったら何もしない | |
$ find {ディレクトリ} -type f -name {名前の一部} | xargs --no-run-if-empty rm | |
# パスに半角スペースが含まれるファイルをfindして任意の文字でgrepして一括削除する | |
$ find {ディレクトリ} -type f | grep -i {ファイル名の一部} | sed -e 's/ /\\ /g' | xargs rm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
再帰的に見たい。 | |
$ ls -R | |
ディレクトリだけパスだけ一覧で見たい。 | |
$ find {見たい場所} -type d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 設定した環境変数を見たい。 | |
$ printenv {環境変数名} | |
# PATHを見たい。 | |
$ printenv PATH | |
/usr/local/bin:/Users/mana/.phpenv/shims:/Users/mana/.phpenv/bin:...:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin | |
# PATHを改行で見やすく区切ってみたい | |
$ printenv PATH | sed -e 's/:/:\n/g' | |
/c/app/Java/jdk1.8.0_231/: | |
... | |
/mingw64/bin: | |
/usr/local/bin: | |
/usr/bin: | |
/bin: | |
# 曖昧な名前で見たい。 | |
$ printenv | grep -i oracle | |
# 環境変数を設定したい(bash) | |
$ echo 'export {環境変数名}="{環境変数値}"' >> ~/.bash_profile | |
$ source .bash_profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ls -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 設定した環境変数を見たい。 | |
$ printenv {環境変数名} | |
# PATHを見たい。 | |
$ printenv PATH | |
/usr/local/bin:/Users/mana/.phpenv/shims:/Users/mana/.phpenv/bin:...:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin | |
# PATHを改行で見やすく区切ってみたい | |
$ printenv PATH | sed -e 's/:/:\n/g' | |
/c/app/Java/jdk1.8.0_231/: | |
... | |
/mingw64/bin: | |
/usr/local/bin: | |
/usr/bin: | |
/bin: | |
# 曖昧な名前で見たい。 | |
$ printenv | grep -i oracle | |
# 環境変数を設定したい(bash) | |
$ echo 'export {環境変数名}="{環境変数値}"' >> ~/.bash_profile | |
$ source .bash_profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
undo : u | |
paste : p(カーソル行の下にpaste) P(カーソル業行にpaste) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 任意の文字列が含まれる行数を数えたい | |
$ grep -a {任意の文字列} {ファイルパス} | wc -l | |
## 例) hoge.iniで「key(大文字小文字区別なし)」かつ「;(コメント)で始まらない」行数を数えたい | |
$ grep -ai key hoge.ini | grep ^[^\;] | wc -l | |
# 任意の文字列が含まれる行数を数えたい | |
$ grep -c {任意の文字列} {ファイルパス} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 状態を確認したい | |
$ sudo service iptables status | |
$ sudo systemctl status iptables | |
$ sudo /etc/rc.d/init.d/iptables status | |
# 設定を保存したい | |
$ sudo iptables-save > {ファイル名} | |
# 設定を読み込みたい | |
$ sudo iptables-restore < {ファイル名} | |
# 動かしたい | |
$ sudo service iptables start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
undo : u | |
paste : p(カーソル行の下にpaste) P(カーソル業行にpaste) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
再帰的に見たい。 | |
$ ls -R | |
ディレクトリだけパスだけ一覧で見たい。 | |
$ find {見たい場所} -type d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ssh-keygen [オプション] -t 鍵タイプ [-N 新しいパスフレーズ] [-C コメント] [-f 鍵ファイル] | |
$ ssh-keygen -p [-P 古いパスフレーズ] [-N 新しいパスフレーズ] [-f 鍵ファイル] | |
$ ssh-keygen -i [-f 鍵ファイル] | |
$ ssh-keygen -l [-f 鍵ファイル] | |
# RAS鍵を作る場合 | |
$ ssh-keygen -t rsa | |
Enter file in which to save the key (/root/.ssh/id_rsa): | |
Created directory '/root/.ssh'. | |
Enter passphrase (empty for no passphrase): | |
Enter same passphrase again: | |
Your identification has been saved in /root/.ssh/id_rsa. | |
Your public key has been saved in /root/.ssh/id_rsa.pub. | |
The key fingerprint is: | |
62:47:8f:cd:fa:16:f4:15:74:c6:9a:3c:59:49:fe:f4 root@localhost.localdomain | |
The key's randomart image is: | |
+--[ RSA 2048]----+ | |
| .oo+| | |
| o+o| | |
| . . B.| | |
| . =. B.o| | |
| o S.+. . .E| | |
| . o .. . | | |
| . . | | |
| .. | | |
| .. | | |
+-----------------+ | |
# 鍵の強度(鍵長)を確認する場合 | |
$ ssh-keygen -l -f ~/.ssh/id_rsa.pub | |
2048 62:47:8f:cd:fa:16:f4:15:74:c6:9a:3c:59:49:fe:f4 root@localhost.localdomain (RSA) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
undo : u | |
paste : p(カーソル行の下にpaste) P(カーソル業行にpaste) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ls -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ssh-keygen [オプション] -t 鍵タイプ [-N 新しいパスフレーズ] [-C コメント] [-f 鍵ファイル] | |
$ ssh-keygen -p [-P 古いパスフレーズ] [-N 新しいパスフレーズ] [-f 鍵ファイル] | |
$ ssh-keygen -i [-f 鍵ファイル] | |
$ ssh-keygen -l [-f 鍵ファイル] | |
# RAS鍵を作る場合 | |
$ ssh-keygen -t rsa | |
Enter file in which to save the key (/root/.ssh/id_rsa): | |
Created directory '/root/.ssh'. | |
Enter passphrase (empty for no passphrase): | |
Enter same passphrase again: | |
Your identification has been saved in /root/.ssh/id_rsa. | |
Your public key has been saved in /root/.ssh/id_rsa.pub. | |
The key fingerprint is: | |
62:47:8f:cd:fa:16:f4:15:74:c6:9a:3c:59:49:fe:f4 root@localhost.localdomain | |
The key's randomart image is: | |
+--[ RSA 2048]----+ | |
| .oo+| | |
| o+o| | |
| . . B.| | |
| . =. B.o| | |
| o S.+. . .E| | |
| . o .. . | | |
| . . | | |
| .. | | |
| .. | | |
+-----------------+ | |
# 鍵の強度(鍵長)を確認する場合 | |
$ ssh-keygen -l -f ~/.ssh/id_rsa.pub | |
2048 62:47:8f:cd:fa:16:f4:15:74:c6:9a:3c:59:49:fe:f4 root@localhost.localdomain (RSA) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
undo : u | |
paste : p(カーソル行の下にpaste) P(カーソル業行にpaste) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ssh-keygen [オプション] -t 鍵タイプ [-N 新しいパスフレーズ] [-C コメント] [-f 鍵ファイル] | |
$ ssh-keygen -p [-P 古いパスフレーズ] [-N 新しいパスフレーズ] [-f 鍵ファイル] | |
$ ssh-keygen -i [-f 鍵ファイル] | |
$ ssh-keygen -l [-f 鍵ファイル] | |
# RAS鍵を作る場合 | |
$ ssh-keygen -t rsa | |
Enter file in which to save the key (/root/.ssh/id_rsa): | |
Created directory '/root/.ssh'. | |
Enter passphrase (empty for no passphrase): | |
Enter same passphrase again: | |
Your identification has been saved in /root/.ssh/id_rsa. | |
Your public key has been saved in /root/.ssh/id_rsa.pub. | |
The key fingerprint is: | |
62:47:8f:cd:fa:16:f4:15:74:c6:9a:3c:59:49:fe:f4 root@localhost.localdomain | |
The key's randomart image is: | |
+--[ RSA 2048]----+ | |
| .oo+| | |
| o+o| | |
| . . B.| | |
| . =. B.o| | |
| o S.+. . .E| | |
| . o .. . | | |
| . . | | |
| .. | | |
| .. | | |
+-----------------+ | |
# 鍵の強度(鍵長)を確認する場合 | |
$ ssh-keygen -l -f ~/.ssh/id_rsa.pub | |
2048 62:47:8f:cd:fa:16:f4:15:74:c6:9a:3c:59:49:fe:f4 root@localhost.localdomain (RSA) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
undo : u | |
paste : p(カーソル行の下にpaste) P(カーソル業行にpaste) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ssh-keygen [オプション] -t 鍵タイプ [-N 新しいパスフレーズ] [-C コメント] [-f 鍵ファイル] | |
$ ssh-keygen -p [-P 古いパスフレーズ] [-N 新しいパスフレーズ] [-f 鍵ファイル] | |
$ ssh-keygen -i [-f 鍵ファイル] | |
$ ssh-keygen -l [-f 鍵ファイル] | |
# RAS鍵を作る場合 | |
$ ssh-keygen -t rsa | |
Enter file in which to save the key (/root/.ssh/id_rsa): | |
Created directory '/root/.ssh'. | |
Enter passphrase (empty for no passphrase): | |
Enter same passphrase again: | |
Your identification has been saved in /root/.ssh/id_rsa. | |
Your public key has been saved in /root/.ssh/id_rsa.pub. | |
The key fingerprint is: | |
62:47:8f:cd:fa:16:f4:15:74:c6:9a:3c:59:49:fe:f4 root@localhost.localdomain | |
The key's randomart image is: | |
+--[ RSA 2048]----+ | |
| .oo+| | |
| o+o| | |
| . . B.| | |
| . =. B.o| | |
| o S.+. . .E| | |
| . o .. . | | |
| . . | | |
| .. | | |
| .. | | |
+-----------------+ | |
# 鍵の強度(鍵長)を確認する場合 | |
$ ssh-keygen -l -f ~/.ssh/id_rsa.pub | |
2048 62:47:8f:cd:fa:16:f4:15:74:c6:9a:3c:59:49:fe:f4 root@localhost.localdomain (RSA) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
undo : u | |
paste : p(カーソル行の下にpaste) P(カーソル業行にpaste) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ssh-keygen [オプション] -t 鍵タイプ [-N 新しいパスフレーズ] [-C コメント] [-f 鍵ファイル] | |
$ ssh-keygen -p [-P 古いパスフレーズ] [-N 新しいパスフレーズ] [-f 鍵ファイル] | |
$ ssh-keygen -i [-f 鍵ファイル] | |
$ ssh-keygen -l [-f 鍵ファイル] | |
# RAS鍵を作る場合 | |
$ ssh-keygen -t rsa | |
Enter file in which to save the key (/root/.ssh/id_rsa): | |
Created directory '/root/.ssh'. | |
Enter passphrase (empty for no passphrase): | |
Enter same passphrase again: | |
Your identification has been saved in /root/.ssh/id_rsa. | |
Your public key has been saved in /root/.ssh/id_rsa.pub. | |
The key fingerprint is: | |
62:47:8f:cd:fa:16:f4:15:74:c6:9a:3c:59:49:fe:f4 root@localhost.localdomain | |
The key's randomart image is: | |
+--[ RSA 2048]----+ | |
| .oo+| | |
| o+o| | |
| . . B.| | |
| . =. B.o| | |
| o S.+. . .E| | |
| . o .. . | | |
| . . | | |
| .. | | |
| .. | | |
+-----------------+ | |
# 鍵の強度(鍵長)を確認する場合 | |
$ ssh-keygen -l -f ~/.ssh/id_rsa.pub | |
2048 62:47:8f:cd:fa:16:f4:15:74:c6:9a:3c:59:49:fe:f4 root@localhost.localdomain (RSA) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
undo : u | |
paste : p(カーソル行の下にpaste) P(カーソル業行にpaste) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ssh-keygen [オプション] -t 鍵タイプ [-N 新しいパスフレーズ] [-C コメント] [-f 鍵ファイル] | |
$ ssh-keygen -p [-P 古いパスフレーズ] [-N 新しいパスフレーズ] [-f 鍵ファイル] | |
$ ssh-keygen -i [-f 鍵ファイル] | |
$ ssh-keygen -l [-f 鍵ファイル] | |
# RAS鍵を作る場合 | |
$ ssh-keygen -t rsa | |
Enter file in which to save the key (/root/.ssh/id_rsa): | |
Created directory '/root/.ssh'. | |
Enter passphrase (empty for no passphrase): | |
Enter same passphrase again: | |
Your identification has been saved in /root/.ssh/id_rsa. | |
Your public key has been saved in /root/.ssh/id_rsa.pub. | |
The key fingerprint is: | |
62:47:8f:cd:fa:16:f4:15:74:c6:9a:3c:59:49:fe:f4 root@localhost.localdomain | |
The key's randomart image is: | |
+--[ RSA 2048]----+ | |
| .oo+| | |
| o+o| | |
| . . B.| | |
| . =. B.o| | |
| o S.+. . .E| | |
| . o .. . | | |
| . . | | |
| .. | | |
| .. | | |
+-----------------+ | |
# 鍵の強度(鍵長)を確認する場合 | |
$ ssh-keygen -l -f ~/.ssh/id_rsa.pub | |
2048 62:47:8f:cd:fa:16:f4:15:74:c6:9a:3c:59:49:fe:f4 root@localhost.localdomain (RSA) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
undo : u | |
paste : p(カーソル行の下にpaste) P(カーソル業行にpaste) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
undo : u | |
paste : p(カーソル行の下にpaste) P(カーソル業行にpaste) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ログファイルを削除 | |
$ rm {ログファイルがあるディレクトリパス}\*.log | |
# 空っぽのディレクトリ削除 | |
$ rm -d {ディレクトリ} | |
# 中身もろともガッツリ削除 | |
$ rm -rf {ディレクトリ} | |
# ディレクトリは残してファイル削除 | |
$ find {ディレクトリ} -type f | xargs rm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# パッケージを検索したい | |
$ yum search {インストールしたいもの} | |
# コマンドやファイル名でパッケージを検索したい | |
$ yum provides {ファイル名} | |
$ yum provides */{コマンド} | |
# インストールしたい | |
$ yum install {インストールしたいもの} | |
# インストールしたものを見たい | |
$ yum list installed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tailを使う場合 | |
$ tail --version | |
tail (GNU coreutils) 5.97 | |
$ tail -f {ログファイル} | |
# lessを使う場合(スクロールしても画面から見切れた上の部分はもう見れない) | |
$ less --version | |
less 436 | |
$ less +F {ログファイル} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ponsukeのパスワードを変えたい | |
$ sudo passwd ponsuke | |
[sudo] password for ponsuke: | |
Changing password for user ponsuke. | |
New password: | |
Retype new password: | |
passwd: all authentication tokens updated successfully. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 構文 | |
$ chmod {アクセス権限} {ファイル名かディレクトリ名} | |
# 他人に書き込み権限をあげる | |
$ sudo chmod o+w {ファイル名かディレクトリ名} | |
# 再帰的に権限を変更したい | |
$ chmod -R {アクセス権限} {ファイル名かディレクトリ名} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ chown --version | |
chown (GNU coreutils) 8.22 | |
# 再帰的に持ち主を変更する | |
$ chown -R {ユーザ} {ディレクトリ} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
再帰的に見たい。 | |
$ ls -R | |
ディレクトリだけパスだけ一覧で見たい。 | |
$ find {見たい場所} -type d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ユーザ名をソートして一覧を見たい | |
$ cat /etc/passwd | sort | |
ユーザー名:パスワード(xで表示される):ユーザーID:グループID:何も表示されない箇所は作成時に任意でつけるコメント:ホームディレクトリ:シェルの場所 | |
# グループの一覧を見たい | |
$ cat /etc/group | |
# CPUの情報を見たい | |
$ cat /proc/cpuinfo | |
# アーキテクチャ(64bitか32bitか的な)を見たい | |
$ arch | |
x86_64 | |
$ uname -m | |
x86_64 | |
$ uname -a | |
Linux localhost.localhost 2.6.32-276.el6.x86_64 #1 SMP Tue May 29 17:38:19 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
再帰的に見たい。 | |
$ ls -R | |
ディレクトリだけパスだけ一覧で見たい。 | |
$ find {見たい場所} -type d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tailを使う場合 | |
$ tail --version | |
tail (GNU coreutils) 5.97 | |
$ tail -f {ログファイル} | |
# lessを使う場合(スクロールしても画面から見切れた上の部分はもう見れない) | |
$ less --version | |
less 436 | |
$ less +F {ログファイル} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ps aux | grep glassfish | |
# ps 実行中のプロセスを表示する | |
# psのオプション------------------------ | |
# a 自分以外のユーザーのプロセスも表示する | |
# u ユーザー名と開始時刻を表示する | |
# x 制御端末のないプロセスの情報も表示する |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ハイフン(-)で始まる文字 | |
## 失敗例 | |
$ grep -rn "-- " {ディレクトリパス} | |
grep: unknown option -- | |
Usage: grep [OPTION]... PATTERN [FILE]... | |
Try 'grep --help' for more information. | |
## 成功例 | |
$ grep -rn "\-- " {ディレクトリパス} | |
#「 AS 」で始まる「大文字英数字」を探す | |
grep -r -P '(?<=\sAS\s)[A-Z0-9_]+' {ディレクトリパス} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# パッケージを検索したい | |
$ yum search {インストールしたいもの} | |
# コマンドやファイル名でパッケージを検索したい | |
$ yum provides {ファイル名} | |
$ yum provides */{コマンド} | |
# インストールしたい | |
$ yum install {インストールしたいもの} | |
# インストールしたものを見たい | |
$ yum list installed | |
# yumでインストールしたときのインストール場所を見たい | |
$ rpm -ql {パッケージ名} | |
# アンインストールしたい | |
$ yum -y remove {アンインストールしたのも} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rpm -ql {パッケージ名} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cp [options] {コピー元} {コピー先} | |
// 再帰的にできるだけ属性とディレクトリの構成を保持して、同名ファイルがあっても警告なしで上書きをする | |
$ cp -arf {コピー元ディレクトリ} {コピー先ディレクトリ} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mv {リネーム前} {リネーム後} | |
// 文字を置換してリネーム(unixにはないらしい) | |
$ rename {置換前文字} {置換後文字} {ファイル名} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat {ファイル名} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ディレクトリを再帰的に作りたい | |
mkdir -p ./pon/suke/chovin | |
# シンボリックリンクを作りたい | |
$ ln -s {リンク元のディレクトリパス} {リンク先のパス} | |
# AからZまでの羅列を作りたい | |
$ echo {A..Z} | |
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z | |
$ echo {G..Q}58 | |
G58 H58 I58 J58 K58 L58 M58 N58 O58 P58 Q58 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sort [オプション] {ソート前ファイル} > {ソートごファイル} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 圧縮したい | |
$ tar -cvf {アーカイブファイル名} {圧縮するもの} | |
# 解凍したい | |
$ tar -xvf {アーカイブファイル名} | |
# 解凍したい(展開先を指定) | |
$ tar -xvf {アーカイブファイル名} -C {展開先ディレクトリ} | |
# ZIPファイルを解凍したい | |
$ unzip {アーカイブファイル名}.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ od -c {ファイルパス} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ファイル名で検索したい | |
$ find {ディレクトリパス} -type f -name '{検索したい文字列}' | |
# ファイル名で検索したい(大文字小文字無視) | |
$ find {ディレクトリパス} -type f -iname '{検索したい文字列}' | |
ディレクトリ名で検索したい | |
$ find {ディレクトリパス} -type d -name '{検索したい文字列}' | |
ファイル名かディレクトリ名で検索したい | |
$ find {ディレクトリパス} -name '{検索したい文字列}' | |
# ファイルの拡張子を指定して再帰的に検索したい | |
$ find ./ -name *.xhtml | |
$ grep '{検索したい文字列}' {ディレクトリパス} -r --include=*.php | |
ファイルの中身にある文字列で検索したい(ファイル表示版) | |
$ find {ディレクトリパス} -type f | xargs grep '{検索したい文字列}' | |
$ grep -rl '{検索したい文字列}' {ディレクトリパス} | |
ファイルの中身にある文字列で検索したい(行表示版) | |
$ grep -rn '{検索したい文字列}' {ディレクトリパス} | |
# ファイルの中身にある文字列で検索したい(大文字小文字無視版) | |
$ grep -irl '{検索したい文字列}' {ディレクトリパス} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 特定ファイルのをみたい | |
$ nkf -g {ファイルパス} | |
# ディレクトリのを全部みたい | |
$ find {ディレクトリパス} -type f | xargs nkf -g | |
# 特定ファイルのをみたい:BOM付きかどうかまで見たい | |
$ file {ファイルパス} | |
{ファイルパス}: Bourne-Again shell script text executable, UTF-8 Unicode (with BOM) text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ nkf -g {ファイルパス} | |
$ find {ディレクトリパス} -type f | xargs nkf -g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 対象のPIDを確認(Linux) | |
$ top -d1a | |
# 対象のPIDを確認(Windows) | |
$ netstat -nao | |
アクティブな接続 | |
プロトコル ローカル アドレス 外部アドレス 状態 PID | |
TCP .....省略 | |
# 殺す | |
$ sudo kill -9 {PID} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ echo 'export {環境変数名}="{環境変数値}"' >> ~/.bash_profile | |
$ source .bash_profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mv {移動元} {移動先} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mv {移動元} {移動先} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ touch {ファイル名} | |
$ echo -n > {ファイル名} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat {結合したいファイル} {結合したいファイル} > {結合したファイル} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ざっくり構文 | |
$ sed [オプション] [対象ファイル] | |
# 文字列を削除したい(-i:対象のファイルを上書き更新) | |
$ sed -i 's/文字列//g' target.txt | |
# 文字の置換をしたい | |
$ sed -i 's/{置換前文字列}/{置換後文字列}/g' {ファイルパス} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ printenv {環境変数名} | |
$ printenv PATH | |
/usr/local/bin:/Users/mana/.phpenv/shims:/Users/mana/.phpenv/bin:/usr/local/bin:/Users/mana/.phpenv/shims:/Users/mana/.phpenv/bin:/usr/local/opt/postgresql@9.6/bin:/usr/local/Cellar/ant/1.10.0/libexec/bin:/usr/local/bin:/usr/local/sbin:/Users/mana/.nodebrew/current/bin:/Users/mana/bin/Sencha/Cmd/6.0.2.14/..:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
フォーマット | |
$ printenv {環境変数名} | |
PATHを見たい。 | |
$ printenv PATH | |
/usr/local/bin:/Users/mana/.phpenv/shims:/Users/mana/.phpenv/bin:/usr/local/bin:/Users/mana/.phpenv/shims:/Users/mana/.phpenv/bin:/usr/local/opt/postgresql@9.6/bin:/usr/local/Cellar/ant/1.10.0/libexec/bin:/usr/local/bin:/usr/local/sbin:/Users/mana/.nodebrew/current/bin:/Users/mana/bin/Sencha/Cmd/6.0.2.14/..:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin | |
曖昧な名前で見たい。 | |
$ printenv | grep -i oracle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment