Web commands

  • Download a web page an all its requisites:
    wget -r -p -nc -nH --level=1 http://pypi.python.org/simple/python-ldap/
    
  • Create a PNG image of a rendered html page:
    kwebdesktop 1024 768 capture.png http://slashdot.org/
    
  • Search in all files malformed HTML entities (in this case non-breakable spaces that doesn’t end with a semicolon):
    grep -RIi --extended-regexp '&nbsp[^;]' ./
    
  • Here is a one-liner I use to ping some pages on internet to force our corporate proxy to refresh its internal cache:
    for EGG in BeautifulSoup PIL Plone; do wget --server-response -O /dev/null http://pypi.python.org/simple/$EGG/; done
    
  • Create a minimal self-signed unencrypted SSL certificate without issuer information and a validity period of 10 years:
    openssl req -x509 -nodes -subj '/' -days 3650 -newkey rsa:2048 -keyout self-signed.pem -out self-signed.pem
    
  • Create a pair of SSL self-signed certificate and (unencrypted) private key (source):
    openssl genrsa -out private.key 2048
    openssl req -new -subj '/' -key private.key -out certreq.csr
    openssl x509 -req -days 3650 -in certreq.csr -signkey private.key -out self-signed.pem
    rm certreq.csr
    
  • View certificate details:
    openssl x509 -noout -text -in self-signed.pem
    

OpenSSH commands

  • Here is the syntax that makes scp support spaces (source):
    scp foo.com:"/home/fubar/some\ folder/file.txt" ./
    
  • Copy a bunch of files to a remote server (or how to use find with scp):
    find /var/log/ -iname "*.log" -type f | xargs -i scp '{}' kevin@myserver:/media/backup/logs/
    
  • Redirect local 8081 port to proxy.company.com:8080 via a SSH tunnel passing through the authorized-server.company.com machine:
    ssh -T -N -C -L 8081:proxy.company.com:8080 kevin@authorized-server.company.com
    
  • Use rsync over different SSH port (source):
    rsync --progress -vrae 'ssh -p 8022' /home/user/docs/ bill@server:/home/user/docs/