---
# System prepended metadata

title: Network Command
tags: [Unix-like]

---

---
tags: Unix-like
---
# Network Command

## netstat

可顯示目前的網路狀態，包括傳輸控制協定層的連線狀況、路由表、網路介面狀態和網路協定的統計資訊等。被看作過時、應被替代的工具。

## ss

Socket Statistics，比 netstat 更快速、更詳細。

> Some Linux distros such as Arch Linux and CentOS/RHEL 7 have already deprecated `net-tools`, and others are planning to do so in favor of `iproute2`.
> 
> | net-tool | iproute2 |
> |----------|----------|
> | ifconfig | ip addr, ip link |
> | route    | ip route |
> | arp      | ip neigh |
> | vconfig  | ip link  |
> | iptunnel | ip tunnel |
> | ipmaddr  | ip maddr |
> | netstat  | ss       |
> 
> [name=[Linux TCP/IP networking: net-tools vs. iproute2](http://xmodulo.com/linux-tcpip-networking-net-tools-iproute2.html)]

## lsof

List open files

```shell
$ lsof -i:8081  # 列出誰在使用 8081 的 Port
COMMAND     PID      USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
VBoxHeadl 99892 celineyeh   18u  IPv4 0xc2c25bfe676356cf      0t0  TCP *:sunproxyadmin (LISTEN)
```

## 參考資料

 - [netstat / Wiki](https://zh.wikipedia.org/wiki/Netstat)