More Linux Tips

More than one line comment bash

echo "Say Something"
your comment 1
comment 2
echo "Do something else"

Check tcp open ports

While doing this, you’re checking if the port 1521 is open at the ip address, very useful when you don’t have nc netcat, mmap or other stuff.

[[email protected]]# echo "" > /dev/tcp/

PFX Certificates

PFX files are PKCS#12 Personal Information Exchange Syntax Standard files. They can include arbitrary number of private keys with accompanying X.509 certificates (public keys) and a Certificate Authority Chain.

If you want to extract client certificates (not the CA certificates), you can use OpenSSL’s PKCS12 tool.

openssl pkcs12 -in xxxx.pfx -out mycertificates.crt -nokeys -clcerts

The command above will output the certificate(s) in PEM format. The “.crt” extension known to both Mac OS X and Windows operating systems and will be usable. You mention “.cer” extension your question which is the DER format equivalent. Same certificate but different encoding. Try the “.crt” file first and if it doesn’t help, it’s easy to convert from PEM to DER format.

openssl x509 -inform pem -in mycertificates.crt -outform der -out mycertificates.cer

Network routing

You can add static route using following command: ip route add {NETWORK} via {IP} dev {DEVICE} For example network available via

 # ip route add via dev eth1

Alternatively, you can use old good route command:

 # route add -net netmask gw dev eth1

Grep the nth line of a file?

Good old-fashioned awk is incredibly useful for these small jobs:

awk '{ if (NR==45) print $0 }' file

Or, you can pass in n as a parameter if you want to make a script:

# Usage getn N filename

awk '{ if(NR==n) print $0 }' n=$1 $2

$0 is the whole line. $1 would be the first column, $2 the 2nd etc.