martedì, dicembre 22, 2015

Grep Quick Reference

Basic grep usage



Get lines which does not begin with "#" or ";"?
# grep "^[^#;]" /path/to/my/file 
Search recursively through single file extension
# grep -r --include=<pattern> <string> <directory>
Print two line after and before the match.
# grep -A 2 -B 2 "pattern" /path/to/my/file"

Download Oracle JDK with single command


Today I want to show you how to download JDK with one single command. Yes, because if you want to get java from oracle web site you have to accept license before start the download.


If you want to don't want to use browser and you have to get it from command line you can use


# curl -LO ${URL} -H "Cookie: oraclelicense=accept-securebackup-cookie" 

where {URL} can be:


  • http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-x64.tar.gz for JDK 8
  • http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-linux-x64.tar.gz for JDK 7






mercoledì, dicembre 09, 2015

How to securely connect to IMAP using OpenSSL

I never knew how to connect to an IMAP server when SSL/TLS were forced. With unencrypted connections, you can just Telnet in, but this exposes your login credentials and data, so many servers will not allow that. The secure equivalent to Telnet, I found, is OpenSSL's s_client tool. The documentation clearly labels it as a debug tool.

You'd resort to either connection method for verification or troubleshooting purposes; I can't imagine anyone wanting to do employ Telnet or s_client regularly — rather than use some mail client.


As an example, here's how you could log into an Exchange account, select the Inbox folder, and log out:


# openssl s_client -connect server:port -crlf
? LOGIN username password
? SELECT Inbox
? LOGOUT