Skip to content

Instantly share code, notes, and snippets.

@vitojeng
Last active August 28, 2018 09:15
Show Gist options
  • Save vitojeng/a28f840921db3b3626fb50406d01e198 to your computer and use it in GitHub Desktop.
Save vitojeng/a28f840921db3b3626fb50406d01e198 to your computer and use it in GitHub Desktop.
Useful linux commands

Account

# 建立帳號, 並建立 home dir
$ sudo useradd -m [account]

# 更改密碼, 會詢問
$ sudo passwd [account] 

查詢某個 process 佔用那些 port

方法一:

$ netstat -tupln | grep 10671
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:51621           0.0.0.0:*               LISTEN      10671/java
tcp        0      0 0.0.0.0:9999            0.0.0.0:*               LISTEN      10671/java

方法二:

$ sudo lsof -i | grep 10671
java      10671 vagrant   13u  IPv4  47918      0t0  TCP *:9999 (LISTEN)
java      10671 vagrant   14u  IPv4  47919      0t0  TCP *:51621 (LISTEN)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment