Unix Intermediate commands

  • lsof, kill, ifconfig
  • chmod wget
  • who whois
  • Print user detail
# users name
who

# time of last system boot
who -b
  • wget used to download software, music, video from internet)
wget <address>
wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
  • Display whois information for domain
# whois <domain>
whois google.com
  • host performs DNS lookups, converting domain names to IP addresses and vice-versa
# host <domain>
host google.com
  • Display numerical IP address - route
route -n
  • Listing all ports (both TCP and UDP) - netstat
# Netstat (network statistics)
netstat -a

See active PORTs

  • lsof ---> list open files
  • In Linux/Unix everything is considers as a files (pipes, sockets, directories, devices etc)
sudo lsof -i | grep LISTEN

lsof -i TCP:6379
lsof -i :6379

# Gives only PID
lsof -t -i:6379

Check my IP

# Windows -- IP with details
Ifconfig

# Ubuntu -- PI with detail
ifconfig

# Display all local ip addresses
hostname -I
  • Mac
    • system pref > network >Ethernet/wireless

Free ports or kill app

# Kill process with process ID of pid - `kill`
kill pid
sudo kill -9 <PID>

# Kill all at once
sudo kill -9 $(sudo lsof -t -i:8000)

# Kill process using `fuser`
sudo fuser -k 8000/TCP

# Kill all processes named processname - `killall`
killall processname

Interact with threads, processes and hard disk

  • Display running processes - ps, top, htop
# Display your currently running processes
ps

# list of top processes
top

# Interactive process viewer (top alternative)
htop

ping (Packet INternet Groper)

# Send ICMP echo request to host
ping <host

# limit the number of packets sent to 2
ping -c 2 google.com

# check IPv6 only
ping6 google.com 
ping -6 google.com

# check IPv4 only
ping4 google.com
ping -4 google.com

dig

  • Domain Information Groper
  • Is a powerful command-line tool for querying DNS name servers.
dig google.com

Reference