When people see things as beautiful,
ugliness is created.
When people see things as good,
evil is created.
New Blog for Rigadicomando's contents
Dear reader, for convenience I'm moving the content of this blog
and the future posts in a subsection of my personal blog, so you
can continue following this thematic posts here:
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-ifupPrint 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"Leggi Argomenti" template per script
Template per script che legge argomenti da riga di comando:
#!/bin/bash
# FUNCTIONS
function help () {
cat <<EOF
Command: `basename $0`
Syntax: `basename $0` [ -h ]
Description: Descrizione script
Options: -h help (questo help)
-a Opzione "A"
-b Opzione "B"
EOF
}
# VARIABILI
# OPZIONI
while getopts ha:b: var
do
case $var in
h) help; exit
;;
a) echo "Opzione "-a" con argomento $OPTARG";
;;
b) echo "Opzione "-b" con argomento $OPTARG";
esac
done
shift ` expr $OPTIND - 1 `fuser + proc
Path completo dell'eseguibile che sta occupando una determinata
porta con un determinato protocollo
cat /proc/`fuser -n $2 $1 | gawk \'{}{printf\"%s\\n\",$2}{}\'`/cmdline && echo -e \"\\n\"Whoix
Questo sulla mia Debian non gira ... mi sono permesso di modificarlo un po':
cat /proc/`fuser -n tcp 80|gawk {'print $2'}`/cmdline && echoFabio
passless users
Volete vedere quali utenti nel vostro sistema NON hanno una password?
cat /etc/passwd |cut -f1,2 -d:| grep -v :x |cut -f1 -d:Whoix

