# # Wesleyan University # COMP 360, Section 1, Fall 2016 # V. Manfredi # # List of networking-related unix commands # # List current processes and their process ids (pids) ps auxwww # a = all user processes, u = display username # x = include processes not attached to terminal # w = output formatting ps auxwww | grep PROGRAM_NAME # Kill a process. Obtain process id (pid) using ps command in terminal kill -15 pid # Software termination kill -9 pid # Nuclear option # What is the IP address for a host? Lookup done using DNS host www.google.com # What is the host name of your machine? Can also use to set the # machine host name. Permanently set by changing /etc/hostname and # rebooting hostname # Look up host and ip information. Note that nslookup is another way # to do this but nslookup is now deprecated; use dig or host instead dig www.google.com host www.google.com whois www.google.com # What is the DNS server that I'm using? less /etc/resolv.conf # What interfaces does my machine have? What are my IP and MAC # addresses? Also configure/enable/disable an interface and change # MTU of interface packets ifconfig ifconfig eth0 # show only interface eth0 information ifconfig eth0 - promisc # make interface eth0 promiscuous (capture # all packets) ip addr # Works in linux only, not Mac OS # Give me information about my network interface card ethtool eth0 # Works in linux only, not Mac OS # What's in the network data structures my machine is maintaining? # What connections does my machine have? What ports are open? netstat | less netstat -r # display routing table info ss # Works in linux only, not Mac OS ss -ta # TCP connections ss -ua # UDP connections ss -xa # Unix connections # Show my routing table route route add -net 10.10.10.0/24 gw 192.168.0.1 # Add a route route del -net 10.10.10.0/24 gw 192.168.0.1 # Delete a route route add default gw 192.168.0.1 # Add default gateway # Check reachability of a host. ping 8.8.8.8 ping ww.google.com ping -c 10 www.google.com # How many hops is it to a destination host? What path is taken to # reach the host? traceroute www.google.com tracepath www.google.com # Ping + traceroute mtr www.google.com # Works in linux only, not Mac OS # Request a file or webpage wget www.google.com # Works in linux only, not Mac OS curl www.google.com # Do almost anything networking related using netcat nc -l 51234 # Be a server: listen for connections on port 51234 nc localhost 51234 # Be a client. Connect to port 51234 on # localhost. Type a string and press enter and # you should see it show up at the server. Type a # string at server and press enter and you should # see it show up at client netstat | grep 51234 # Look at the connections you created nc -u -l 51234 # UDP server nc -u localhost 51234 # UDP client netstat | grep 51234 # Check connection is now UDP nc -u host.example.com 80 # Open a TCP connection on port 80. once # connected, enter GET / HTTP/1.1 # followed by two enters# # Network mapping and port scanning nmap www.google.com # Encrypted file transfer scp PATH_OF_FILE_TO_COPY PATH_WHERE_TO_PUT_FILE # Unencrypted remote connections to a server. For a list of places # that work with telnet: http://www.telnet.org/htm/places.htm telnet gaia.cs.umass.edu 80 # Connection is unencrypted!!!!! Once connected, enter: HEAD / HTTP/1.0 or GET / HTTP/1.1 Then press enter twice. And you should get a response from the server # Encrypted remote connections to a server. Get yourself a shell # account from the following so you can test a real site: # http://sdf.org/ ssh -v USERNAME@sdf.org # The commands previously listed all have additional flags that I am # not showing. You can type man COMMAND_NAME # in a terminal to find out more about them. If a program isn't # installed, try installing it on linux with the following command # (you'll need root privileges) sudo apt-get install COMMAND_NAME