Tuesday, April 28, 2015

Oneliner for displaying apt packages which could be updated



function a { read input;dpkg -l ${input} | grep " ${input} " | awk '{$1=$2=$3=$4="";print $0}' | sed 's/^ *//';unset input;};{ apt-get --just-print upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "$1 (\e[1;34m$2\e[0m -> \e[1;32m$3\e[0m)\n"}';} | while read -r line; do echo -en "$line $(echo $line | awk '{print $1}' | a )\n"; done;





Example output (colored):

policykit-1 (0.105-4ubuntu2 -> 0.105-4ubuntu2.14.04.1) framework for managing administrative policies and privileges
python-urllib3 (1.7.1-1build1 -> 1.7.1-1ubuntu3) HTTP library with thread-safe connection pooling for Python
python-requests (2.2.1-1ubuntu0.1 -> 2.2.1-1ubuntu0.2) elegant and simple HTTP library for Python, built for human beings
software-properties-common (0.92.37.2 -> 0.92.37.3) manage the repositories that you install software from (common)
python3-software-properties (0.92.37.2 -> 0.92.37.3) manage the repositories that you install software from
cloud-guest-utils (0.27-0ubuntu9 -> 0.27-0ubuntu9.1) cloud guest utilities
cloud-init (0.7.5-0ubuntu1.3 -> 0.7.5-0ubuntu1.5) Init scripts for cloud instances
grub-legacy-ec2 (0.7.5-0ubuntu1.3 -> 0.7.5-0ubuntu1.5) Handles update-grub for ec2 instances
icinga2-doc (2.3.4-2~ppa1~trusty1 -> 2.3.4-3~ppa1~trusty1) host and network monitoring system - documentation

Monday, April 27, 2015

Useful nmap commands

Nmap scan of opened ports (including both udp and tcp ports):

sudo nmap --min-parallelism 100 -sT -sU -Pn localhost