2
2

More than 5 years have passed since last update.

備忘:Linuxでよく使うコマンド

Last updated at Posted at 2016-08-20
毎回同じことをいろいろなサイトで検索している気がするので備忘録としてよく使うコマンドを記載。

実行環境はまちまちだが、Amazon LinuxもしくはRasbian。



LISTEN状態のポートを調べる

$ netstat -nlt

---OUTPUT---

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp6       0      0 :::80                   :::*                    LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN 

-n ホスト名などを解決せずに数字で表示する
-l 接続待ち状態のソケットのみを表示する
-t TCPソケットを表示する

起動中のプロセスを調べる

$ ps aux

---OUTPUT---

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  4.4  0.8   5356  3804 ?        Ss   13:55   0:06 /sbin/init
root         2  0.0  0.0      0     0 ?        S    13:55   0:00 [kthreadd]
root         3  0.2  0.0      0     0 ?        S    13:55   0:00 [ksoftirqd/0]
root         4  0.0  0.0      0     0 ?        S    13:55   0:00 [kworker/0:0]
root         5  0.0  0.0      0     0 ?        S<   13:55   0:00 [kworker/0:0H]
root         6  0.1  0.0      0     0 ?        S    13:55   0:00 [kworker/u2:0]
root         7  0.0  0.0      0     0 ?        S    13:55   0:00 [kdevtmpfs]
root         8  0.0  0.0      0     0 ?        S<   13:55   0:00 [netns]

--以下省略--

a すべてのプロセスを表示します。
u ユーザーフォーマットで表示します。
x 制御端末のないプロセスも表示します。

コメントアウト以外の行を表示する

$ grep -v -e '^\s*#' -e '^\s*$' ファイル名

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2