I started to begin a post about useful linux commands and command line tricks. It didn't take long for me to realize that would make a very very long post.
I'm going to start with some more common commands and some I've looked at recently. I expect this list to grow. For most of this I will list the command, my most common use(s) for it, and maybe some examples.
netstat
Useful for seeing what ports are open on your computer and what process is manning those ports. I might use this to make sure something like and ssh-server is running. Very useful on servers - dns,mail,web - for making sure your programs are configures to use the right ports.
netstat -natp
sudo netstat -natp|grep 'sshd'
ssh
If you don't know what this is for or how to use it, I don't see how anything else in this post will help you much.
traceroute
Traces the route a packet takes to get to a destination. I haven't found a really great regular/common use for it, but it is fun to run every once to a while to see where things are going, and what route they are taking.
traceroute www.google.com
mtr
It does the same as traceroute but it consistently pings each hop, and keeps track of packets - dropped, etc - can be useful for seeing where a connection may be getting hung up.
mtr www.google.com
xtightvncviewer
I use this all the time on my personal computers. I have one laptop that the battery doesn't work in, so it's always connected to the tv. It's nice to be able to connect to it from any other computer to change stuff. Or if I am trying to follow something my wife is doing on the computer and guide her through it I can connect in view only mode to always have a visual.
vncviewer remote.ip.addr[:port]
vncviewer -viewonly remote.ip.addr[:port]
whois
This can be useful, but like traceroute is mostly a curiosity thing. It will tell you who a particular ip address is registered to in the whois database.
whois ip.addr
nmap
This is a powerful great program that has many many uses. My most command is seeing things like what other computers are on the network and what services they are running. It scans the network and displays information.
nmap -v -sT -rF 192.168.0.0/24
The above command runs an nmap scan in verbose mode (
-v -sT), scans the ip addresses between
192.168.0.0-255 (192.168.0.0/24), Scans in fast mode the most common ports (
-F) and scans ports consecutively - not randomly (
-r).
I use this with grep to show only the info on open ports.
If all I want to see is the open ssh ports on my network I can use
-p22 instead of
-rF
sshuttle
This is one great program. I had never heard of it until recently, but it's pretty much the bomb. It can do more but the first thing I've used it fore was to set connect to another computer (via ssh) and route all network traffic through the tunnel. (pretty much sets up a VPN for you via ssh). You can use it to get around dns blocks. Or if someone wants to join your LAN game who is not on your LAN sshuttle will put you on their network.
sshuttle -r <server> --dns 0/0
I did run into a little bit of trouble on ubuntu 12.04 my first time trying it and I actually had to run these comands on the client and server (both ubuntu 12.04)
sudo dpkg-reconfigure resolvconf (select yes on any prompts)
sudo resolvconf --enable-updates
sudo reboot
sshfs
mount an ssh filesystem, I already have this one in another post but here it is for redundancy. You can mount a folder from one computer to an empty folder on your computer. syntax is similar to scp
sshfs <server>:/path/to/source /path/to/destination
Well that's it for now, I'm sure the list will grow.