You are here: Foswiki>Main Web>LinuxUsage?>LinuxUsefullCommands (14 Jul 2011, AvishaiIshShalom)EditAttach

Useful linux commands

Memory and process info

  • show process memory consumption, ordered by memory usage: ps -eO pcpu,pmem,vsz,rsz --sort -rsz,-vsz
  • show process info for pid: prtstat pid
  • send SIGKILL to all zombie processes: ps -eo pid,state|awk '$2=="Z" {print $1}' | xargs -L1 kill -9

Networking

  • show all processes with active ports: lsof -Pnl -i
  • dump and protocol decode ip communications: tcpdump -s 1500 -A -vvv
  • show listening ports with owning process - IPv4: netstat -Pnl --inet IPv6: netstat -Pnl --inet6
  • show routing cache: ip route show cache
  • flush routing cache: ip route flush cache
  • show nfs exports on remotehost: showmount -e remotehost
  • check port on remote host: netcat -zv remotehost port

SSH

  • be a socks proxy on localhost port 8080: ssh -D 8080 remotehost
  • connect without a pty, without running command and goto background ssh -NTf remotehost

SSH vpn tunnel

on machine A:
ssh -w 0:0 -NTf machineb
ip address add 192.168.99.2 peer 192.168.99.1 dev tun0
ip link set up dev tun0

on machine B:
ip address add 192.168.99.1 peer 192.168.99.2 dev tun0
ip link set up dev tun0

You may also want to masquerade traffic with iptables.

File management

  • Show path traversal leading to file namei filename
  • Same with mountpoints and mode namei -mx filename
-- AvishaiIshShalom - 17 Mar 2010
Topic revision: r5 - 14 Jul 2011 - 16:14:47 - AvishaiIshShalom
 

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback