Most Common Linux Commands

2019-07-13  本文已影响0人  杨领well

netcat — a utility that is able to write and read data across TCP and UDP network connections.

(1) nc -v -w 2 -z target 22-23: try connecting to every port in [22, 23] at the target

ports scanning
(2) nc -v -n target 443: grab port banners at target:443
grab port banners
(3) nc -l -p 10001: listen for an incoming connection on port 10001.
(4) Transferring files using netcat:
// server
nc -l -p 1234 > filename.txt

// client
nc destination 1234 < filename.txt

wc — print new line, word and byte counts for each file

(1) wc file: print number of lines, number of words, number of bytes, filename for file

wc co_routine.cpp
(2) ls -l | wc -l: count the number of files in current directory
count file number

tcpdump — dump traffic on a network

pcap-filter — packet filter syntax

  • port port: either the source or destination port of the packet is port.
  • host host: either the source or destination of the packet is host.
  • src host host/src port port: the source of the packet is host/port.
  • dst host host/dst port port: the destination of the packet is host/port.

(1) tcpdump -nn -vv port 80: capture traffic on port 80

Flags are some combination of S(SYN), F(FIN), P(PUSH), R(RST), W(ECN CWR) or E (ECN-Echo), or a single ‘.’ (no flags).

capture port 80
(2) tcpdump -A port 8080:
tcpdump ASCII
(3) tcpdump -A dst port 1234: capture on destination port
capture on destination port

ss -- used to dump socket statistics

STATE-FILTER allows to construct arbitrary set of states to match. Its syntax is sequence of keywords state and exclude followed by identifier of state.
Available identifiers are:

  • all standard TCP states: established, syn-sent, syn-recv, fin-wait-1, fin-wait-2, time-wait, closed, close-wait, last-ack, listening and closing.
  • all - for all the states
  • connected - all the states except for listening and closed
  • synchronized - all the connected states except for syn-sent
  • bucket - states, which are maintained as minisockets, i.e. time-wait and syn-recv
  • big - opposite to bucket

(1) ss -tu: filter out tcp and udp connections

ubuntu@VM-100-62-ubuntu:~$ ss -tu
Netid     State       Recv-Q       Send-Q              Local Address:Port                Peer Address:Port       
tcp       ESTAB       0            0                   10.xxx.100.xx:ssh                61.xxx.169.xx:30199      
tcp       ESTAB       0            0                   10.xxx.100.xx:42710             10.xxx.231.xxx:5574       
上一篇下一篇

猜你喜欢

热点阅读