find . -iname '*.jpg' -exec mv {} ../target/ \;
Remove all files matching certain pattern in here and in all subdirectories:
find . -iname "*.poo" -exec rm -r "{}" \;
Remove all empty subdirectories in here:
find . -depth -type d -empty -exec rmdir "{}" \;
===== disk UUID's =====
Get complete info about partitions, type and if mounted:
lsblk -f
Also useful:
blkid -s UUID -o value /dev/sda
===== PDF tools =====
Lower file-size (quality) of a pdf document
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
''-dPDFSETTINGS=/screen'' for even lower size/quality
pdfjoin , no rotate
pdfjoin --rotateoversize false
two a5 in one a4
pdfnup a5.pdf a5.pdf --nup '2x1'
Note: ''pdfnup'' is part of ''texlive-extra-utils'' package
overlay a "draft" or other watermark...
pdftk in.pdf multistamp stamp.pdf output out.pdf
a4 to a3 or other scaling
gs -o output.pdf -sDEVICE=pdfwrite -sPAPERSIZE=a4 -dFIXEDMEDIA -dPDFFitPage -dCompatibilityLevel=1.4 input.pdf
join and rotate
pdfjam --outfile out.pdf --landscape --angle 90 input1.pdf input2.pdf
===== Reset keyboard =====
''setxkbmap -model pc104 -layout us''
===== Debian/ubuntu package modify and (re)build =====
https://wiki.debian.org/BuildingTutorial
===== uDev =====
[[https://blog.bofh.it/debian/id_267]]
===== Asterisk click-to-call =====
[[http://bitree.ru/click2call4chrome_en.html]]
===== 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''
See also [[http://nairobi-embedded.org/transfering_buildroot_fs_data_into_qemu_disk_images.html]]
----
===== Socat / YPort =====
''socat -d -d pty,raw,echo=0 pty,raw,echo=0''
''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
* Keysigning https://wiki.debian.org/Keysigning and GPG https://help.ubuntu.com/community/GnuPrivacyGuardHowto
===== 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 -p//sshport// -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
== Or: (definitely best solution) ==
''$ dd if=/dev/zero of=/dev/null& bs=1M status=progress''
===== 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''