Questa è una vecchia versione del documento!
Indice
Linux Tips & Tricks
Reset keyboard
setxkbmap -model pc104 -layout us
Debian/ubuntu package modify and (re)build
uDev
Asterisk click-to-call
Virtual Machines
VDI <--> RAW
Convert VDI (or other) to raw disk:
$ VBoxManage clonehd astlinu256.vdi ast.raw –format RAW
Resize raw disk
$ qemu-img resize ast.raw 100M
Note that partition table is not altered (to be done manually)
QEMU
qemu-img create filename.img 100M
qemu-system-i386 -cdrom cdrom.iso -hda disk1.img -hdb disk2.img -m 128 -boot d
Socat / YPort
socat PTY,link=/dev/YPort TCP:192.168.1.5:7970
External Links
- bash tricks http://cfenollosa.com/misc/tricks.txt
- vi reference http://www.unix-manuals.com/refs/vi-ref/vi-ref.htm
- Guida alla gestione dei pacchetti in Debian https://www.debian.org/doc/manuals/debian-reference/ch02.it.html
obtain mac address with sed
With ifconfig
ifconfig eth0 | head -n 1 | sed 's/.*HWaddr //g' | xargs
With ip
ip addr show dev eth0 | tail -n1 | sed 's/.*ether //' | sed 's/brd.*//' | xargs
udev
/etc/udev/rules.d/xx-my-rules.rules SUBSYSTEM=="tty", ATTRS{idVendor}=="ABCD", ATTRS{idProduct}=="1234", ATTRS{serial}=="12345678", SYMLINK+="mydevice"
To obtain serial number:
udevadm info -a -n /dev/ttyUSB1 | grep serial
Credits: http://hintshop.ludvig.co.nz/show/persistent-names-usb-serial-devices
Note : udevadm
returns ALL usb hierarchy devices, thus the serial returned is not necessarily the one of the hw device!
Actually many (chinese) converters do not have serial number programmed.
gEDA
PCB
To set a minimum clearance for all selected objects
:MinClearGap(Selected,=10,mil)
To convert from vector image (postscript) to pcb format:
$pstoedit -xscale 0.1 -yscale 0.1 -f "pcb: -stdnames -tshiftx -0.0947 -tshifty -0.886 -grid 0.1 -mm -snapdist 0.4" file.ps file.pcb
Appunti vari
^M = CR = d13 = '\r' ^J = LF = d10 = '\n'
Mount images (iso, img, ...)
ISO:
# mount -o loop disk1.iso /mnt/disk
IMG:
fdisk -l /path/to/image
to obtain block size and start of the partition, then
# mount -o loop,offset=NNNN disk1.iso /mnt/disk
for example block size = 512, start block is 2048, so: # mount -o loop,offset=1048576 disk1.iso /mnt/disk
Find large files
find . -type f -size +10000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'
hardware info
dmidecode
cat /proc/cpuinfo
show tcp/udp sockets
Listening or connected
$ netstat -tapnu
ssh connection with port tunnelling
To have a port forwarded through the ssh connection
ssh user@destinationhost -psshport -L[localip:]localport:destip:destport
sshport : the port where the ssh daemon listens
localip : localip where to bind (optional, localhost is default)
localport : local port to bind
destip : destination ip where i want to connect, seen by the destinationhost's point of view, could be localhost if same machine as destinationhost, or its local ip, or another ip in the network
destport : the destionation port where i want to connect
howto show 'dd' progress
Sending a USR1 signal to a running `dd' process makes it print I/O statistics to standard error and then resume copying.
$ dd if=/dev/zero of=/dev/null& pid=$!
$ kill -USR1 $pid; sleep 1; kill $pid
You can add “watch” to this one:
1) find $pid for you dd process:
$ps aux|grep dd
2) show progress, by running:
$watch kill -USR1 $pid
Or:
Someone suggested to give a look to http://www.ivarch.com/programs/pv.shtml
rsync quick ref
classical backup rule
rsync –delete –perms –numeric-ids -aruv –bwlimit=100 –protect-args [SOURCE] [DEST]
–exclude ' '
to exclude some file
–password-file=FILE
the password should be wrote in a plain text file 'FILE'
-u, –update
skip files that are newer on the receiver
-C, –cvs-exclude
auto-ignore files in the same way CVS does
add TTF fonts
Simply copy the fonts in the ~/.fonts
folder (of the X11 user), create it if doesn't exist.
Video conversions
How to convert Matrioska Video (mkv) to standard mpeg containter (avi)
avconv -i file.mkv -b:video 4000k file.avi