Check These Out
At some point you want to know what packets are flowing on your network. Use tcpdump for this. The man page is obtuse, to say the least, so here are some simple commands to get you started.
-n means show IP numbers and don't try to translate them to names.
-l means write a line as soon as it is ready.
-i eth0 means trace the packets flowing through the first ethernet interface.
src or dst w.x.y.z traces only packets going to or from IP address w.x.y.z.
port 80 traces only packets for HTTP.
proto udp traces only packets for UDP protocol.
Once you are happy with each option combine them with 'and' 'or' 'not' to get the effects you want.
Ever compress a file for the web by replacing all newline characters with nothing so it makes one nice big blob?
It is a great idea, however what about when you want to edit that file? ...Serious pain in the butt.
I ran into this today in that my only copy of a CSS file was "compressed" with no newlines.
I whipped this up and it converted back into nice human readable CSS :-)
It could be nicer, but it does the job.
Use GNU Parallel: short, easy to read, and will run one job per core.
Often, the very next command after the cd command is 'ls', so why not combine them?. Tested on a Red Hat derivative and Mac OS X Leopard
Update: changed ${1:-$HOME} to "${@:-$HOME}" to accomodate directories with spaces in the names
displays the output of ls -l without the rest of the crud. pretty simple but useful.
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token.
This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use:
`awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'`
You must adapt the command line to include:
* $MFA_IDis ARN of the virtual MFA or serial number of the physical one
* TTL for the credentials
Used this command recently to remove the trailing ?> from all the files in a php project, which has having some unnecessary whitespace issues. Obviously, change *.php to whatever you'd like.
Using this command you can track a moment when usb device was attached.
The value for the sort command's -k argument is the column in the CSV file to sort on. In this example, it sorts on the second column. You must use some form of the sort command in order for uniq to work properly.