The Tao is like a bellows:
it is empty yet infinitely capable.
The more you use it, the more it produces;
the more you talk of it, the less you understand.
Blogs
Quick System Backup via Netcat
Sometimes a backup is needed but the server storage is not enough, in this case you must backup your data on the fly via the net, without the facility of storing locally and then transfer the data.
There are many methods to backup your data on the fly, using rsync via ssh is one for example, but this post is about using netcat for a quick solution.
Listening side, where the backup data will be stored, or destination:
~# mkdir /whatever_the_name_of_your_backup_dir
~# cd !$
~# netcat -l -p 12345 | pv | tar xjf -Sending side, where the original data are, or source:
~# cd /
~# tar cjf - --ignore-failed-read bin boot cdrom dev/ etc/ home/ initrd* lib/ root/ sbin/ usr/ var/ vmlinuz* | pv | netcat -q 2 <YOUR_DESTINATION_IP> 12345Don't forget to create: /bin /media /mnt /opt /proc /selinux /srv /sys /tmp
and chmod 1777 /tmp
(This FHS is for a Debian Etch, please take care of different directories in your setup)
USB Stick GNU/Linux mini howto with Fix for "Boot error" Buggy BIOSes
I was reading some articles around the web about how building your persistent GNU/Linux system on usb stick, I found many howtos but I had problems with my BIOS.
It seems that certain versions of Award BIOS, one of the major BIOS vendor, are Buggy and misbehave with syslinux, to fix this you should give a USB-ZIP drive compatible geometry to the USB Stick. I found this useful info into the documentation inside the syslinux tarball (doc/usbkey.doc).
Clear the whole Postfix mail queue
~# for i in `mailq|grep '@' |awk {'print $1'}|grep -v '@'`; do postsuper -d $i ; doneThomas Sewell from coolsewell.com contributed with this helpful notes:
Split big files for editing
If you need to edit a big file, for example a mysql full dump for recover a single database, and your editor, for example emacs, say
something like "Maximum buffer size exceeded" you can split it in many smaller files.
~$ split -b 100m ORIGINAL_BIG_FILE OUTPUT_FILE_NAMEOutput files will be:
OUTPUT_FILE_NAMEaa
OUTPUT_FILE_NAMEab
OUTPUT_FILE_NAMEac
and on ... every one 100MB weight.
Then you can edit and just keep your DB for restore.
How do you rename files with a certain pattern in bash?
How do you rename files with a certain pattern in bash?
for i in *ABC*
do
new=$ ( echo $i | sed ’s/ABC/DEF/’ )
mv $i $new
doneThanks Live from Yokohama
Creating and using Qemu for a virtual OS Installation
Create qemu virtual image file:
qemu-img create virt1 1GOn my laptop for some reasons, no cdrom boot was allowed for the virtual installation,
so the loopback device comes useful to do the installation:
dd if=/dev/cdrom of=sarge-netinst.iso Now boot the new OS installation (I use Debian GNU/Linux for both real and virtual systems)
qemu virt1 -boot d -cdrom sarge-netinst.isoThen boot the new system (root or sudoed, as you need root privileges for routing)
qemu virt1 -boot c -n /etc/qemu-ifupA Grand Unified Theory of YouTube and MySpace (from Slashdot)
Ant writes "Paul Boutin's Slate article explains the factors contributing to the success YouTube and MySpace: they are easy to use (usability), and they don't 'tell you what to do.'" From the article: "Both YouTube and MySpace fit the textbook definition of Web 2.0, that hypothetical next-generation Internet where people contribute as easily as they consume.
Print all ANSI colors
(from http://wiki.splitbrain.org/shellsnippets)
for i in 30 31 32 33 34 35 36 37 39
do
for j in 40 41 42 43 44 45 46 47 49
do
# skip if same fore- and backgroundcolor
if [ $j -eq $[ i + 10 ] ]; then
continue
fi
echo -e $i $j "\033[${i};${j}mCOLOR\033[0m"
done
doneSimple bash calculator
Put the following little snippet in your .bashrc/.bash_profile and you'll have a handy little calculator:
? () { echo "$*" | bc -l; }Use like this:
bash$ ? 2*2
4
Thanks textsnippets.com
How to list duplicate lines in a text file, with counts next to each unique line
from:
How to list duplicate lines in a text file, with counts next to each unique line - [spugbrap's random notes geek blog] [del.icio.us (bash)]
At some point, last year (it's been in my 'toblog' file all this time), I needed to analyze the lines in a text file, removing duplicate lines, while counting how many times each duplicated line occurred within the file, and sorting from most common to least common.
Unlimited Loop
Generate an infinite loop in the shell
while true ; do date ; sleep 5 ; done
