Wednesday, February 29, 2012
Wednesday, February 15, 2012
Vim color scheme
I always forgot this:
In gvim, after changing the default color scheme, the next time gvim is started, the default setting is restored.Taken from: http://vim.wikia.com/wiki/Change_the_color_scheme
To retain the color scheme add colorscheme <scheme_name> to vimrc.
For example:
colorscheme murphy
Wednesday, February 8, 2012
AWK and the here-doc string
awk '{print $1}' <<!
jack be
nimble jack be
quick.
!
jas@hardy:~/awk$ ./here.sh
jack
nimble
quick.
AWK: convert lines in a file to columns
#!/bin/bash
awk '
/Name:/, /Zip:/ { printf "%s ", $0 }
/Zip:/ { print "" }
' <<EOT
Name: John Doe
Age: 32
Zip: 60324
Name: Jane Doe
Age: 34
Zip: 54930
Name: Skippy
Age:134
Zip:23456
EOT
Wednesday, February 1, 2012
Wireshark tools
capinfos eth2_20120131_224001.pcap
editcap -i 120 eth2_20120131_224001.pcap eth2.pcap
editcap -A "2012-01-31 17:44:00" -B "2012-01-31 17:48:00" eth2_20120131_224001.pcap eth2_20120131.pcap
editcap -i 120 eth2_20120131_224001.pcap eth2.pcap
editcap -A "2012-01-31 17:44:00" -B "2012-01-31 17:48:00" eth2_20120131_224001.pcap eth2_20120131.pcap
Tuesday, January 24, 2012
How to interpret the status of dpkg (–list)?
The first column of the dpkg -list corresponds to the status of a package. How to interpret this status.
Status of every package is represented by three characters xxx
First character: The possible value for the first character. The first character signifies the desired state, like we (or some user) is marking the package for installation
u: Unknown (an unknown state)
i: Install (marked for installation)
r: Remove (marked for removal)
p: Purge (marked for purging)
h: Hold
Second Character: The second character signifies the current state, whether it is installed or not. The possible values are
n: Not- The package is not installed
i: Inst – The package is successfully installed
c: Cfg-files – Configuration files are present
u: Unpacked- The package is stilled unpacked
f: Failed-cfg- Failed to remove configuration files
h: Half-inst- The package is only partially installed
W: trig-aWait
t: Trig-pend
Third Character: This corresponds to the error state. The possible value include
R: Reinst-required The package must be installed.
Taken from: http://joysofprogramming.com/status-dpkg-list/
Cleaning the boot partition in Ubuntu
Today I found a pop up message on one of my Ubuntu machines that said the boot partition was low on space. I did a search on the web for a cleaning solution for the boot partition and found this page:
http://ubuntugenius.wordpress.com/2011/01/08/ubuntu-cleanup-how-to-remove-all-unused-linux-kernel-headers-images-and-modules/
Basically it is proposed a script for removing all unused Linux kernel headers, images and modules:
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
I found some flaws in this script so I came with this one trying to improve it:
dpkg -l 'linux-*' | \
# We only need the second column of the installed linux-* packages list
awk '/^ii/ { print $2 } ' | \
# Take out the packages with the number of the running kernel
grep -v $(uname -r | sed 's/\([0-9.-]\+\)-[^0-9]\+/\1/') | \
# The -v force me into this extra line
grep '[0-9]' | \
xargs sudo apt-get -y purge
Later I'll try to improve it a little bit more.
http://ubuntugenius.wordpress.com/2011/01/08/ubuntu-cleanup-how-to-remove-all-unused-linux-kernel-headers-images-and-modules/
Basically it is proposed a script for removing all unused Linux kernel headers, images and modules:
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
I found some flaws in this script so I came with this one trying to improve it:
dpkg -l 'linux-*' | \
# We only need the second column of the installed linux-* packages list
awk '/^ii/ { print $2 } ' | \
# Take out the packages with the number of the running kernel
grep -v $(uname -r | sed 's/\([0-9.-]\+\)-[^0-9]\+/\1/') | \
# The -v force me into this extra line
grep '[0-9]' | \
xargs sudo apt-get -y purge
Later I'll try to improve it a little bit more.
Subscribe to:
Posts (Atom)