Move all files matching certain pattern from subdirectories in another single target folder:
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 "{}" \;
Get complete info about partitions, type and if mounted:
lsblk -f
Also useful:
blkid -s UUID -o value /dev/sda
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
setxkbmap -model pc104 -layout us
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-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 -d -d pty,raw,echo=0 pty,raw,echo=0
socat PTY,link=/dev/YPort TCP:192.168.1.5:7970
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
/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.
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
^M = CR = d13 = '\r' ^J = LF = d10 = '\n'
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 . -type f -size +10000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'
dmidecode
cat /proc/cpuinfo
Listening or connected
$ netstat -tapnu
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
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
Someone suggested to give a look to http://www.ivarch.com/programs/pv.shtml
$ dd if=/dev/zero of=/dev/null& bs=1M status=progress
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
Simply copy the fonts in the ~/.fonts
folder (of the X11 user), create it if doesn't exist.
How to convert Matrioska Video (mkv) to standard mpeg containter (avi)
avconv -i file.mkv -b:video 4000k file.avi