Comandos Útiles
Convert a flv video file to avi using mencoder
mencoder your_video.flv -oac mp3lame -ovc xvid -lameopts preset=standard:fast
-xvidencopts pass=1 -o your_video.avi
Mail with attachment
tar cvzf - data1 data2 | uuencode data.tar.gz | mail -s 'data' you@host.fr
Show the UUID of a filesystem or partition
sudo vol_id -u /dev/sda1
Send pop-up notifications on Gnome
notify-send ["
Change Gnome wallpaper
gconftool-2 -t string -s /desktop/gnome/background/picture_filename
Send a .loc file to a garmin gps over usb
gpsbabel -D 0 -i geo -f "/path/to/.loc" -o garmin -F usb:
Grep colorized
grep -i --color=auto
Convert a SVG file to grayscale
It requires inkscape 0.46 and lxml packages
inkscape -f file.svg --verb=org.inkscape.color.grayscale --verb=FileSave
--verb=FileClose
Watch Network Activity in Real-time
lsof -i
Burn CD/DVD from an iso, eject disc when finished.
cdrecord dev=0,0,0 -v -eject yourimage.iso
Backup your CD/DVD making a iso file
dd if=/dev/cdrom of=image.iso
Launch a VirtualBox virtual machine
VBoxManage startvm "name"
Delete an hard disk entry in Virtualbox registry
sed -i '/Centos/d' VirtualBox.xml
Find and delete oldest file of specific types in directory tree
find / \( -name "*.log" -o -name "*.mylogs" \) -exec ls -lrt {} \; | sort -k6,8 | head -n1 | cut -d" " -f8- | tr -d '\n' | xargs -0 rm
Remove all backup files in my home directory
find ~user/ -name "*~" -exec rm {} \;
Recursivly search current directory for files larger than 100MB
find -size +100M
Print basename of files
find . -name '*.deb' -printf "%f\n"
View the system memory in clear text
hexdump -e '90/1 "%_p" "\n"' /dev/mem | less
Convert a file from ISO-8859-1 (or whatever) to UTF-8 (or whatever)
tcs -f 8859-1 -t utf /some/file
Find UTF-8 text files misinterpreted as ISO 8859-1 due to Byte Order Mark (BOM) of the Unicode Standard.
find . -type f | grep -rl $'\xEF\xBB\xBF'
Montar una Carpeta remota de Windows usando Samba
mount -t smbfs -o username=usuario,group=dominio //servidor/carpeta /media/APPL/
List all PostgreSQL databases. Useful when doing backups
psql -U postgres -lAt | awk -F\| '$1 !~ /^template/ && $1 !~ /^postgres/ && NF > 1 {print $1}'
Postgresql SQL to show count of ALL tables (relations) including relation-size
SELECT relname, reltuples, pg_relation_size(relname) FROM pg_class r JOIN pg_namespace n ON (relnamespace = n.oid) WHERE relkind = 'r' AND n.nspname = 'public' ORDER BY relname;
Convert all files in a dir of a certain type to flv
for f in *.m4a; do ffmpeg -i "$f" "${f%.m4a}.flv"; done
For all flv files in a dir, grab the first frame and make a jpg.
for f in *.flv; do ffmpeg -y -i "$f" -f image2 -ss 10 -vframes 1 -an "${f%.flv}.jpg"; done
Backup with SSH in a archive
PRIVATEKEY - Of course the full path to the private key
HOST - The host where to get the backup
SOURCE - The directory you wish to backup
DESTINATION - The destination for the backup on your local machine
ssh -i $PRIVATEKEY $HOST -C 'cd $SOURCE; tar -cz --numeric-owner .' | tee $DESTINATION/backup.tgz | tar -tz
Otra forma:
ssh user@host 'cd dir; tar zcf - .' > file.tgz
Email HTML content
mailx bar@foo.com -s "HTML Hello" -a "Content-Type: text/html" < body.htm
Send a binary file as an attachment to an email
uuencode archive.tar.gz archive.tar.gz | mail -s "Emailing: archive.tar.gz" user@example.com
Delete Empty Directories
find . -type d -exec rmdir {} \;
Add -depth to prevent find complaining (it will ensure empty trees are deleted, too) and --ignore-fail-on-non-empty to stop rmdir (gnu version) complaining:
find . -depth -type d -exec rmdir --ignore-fail-on-non-empty {} \;
Of course for efficiency, you can use xargs:
find . -depth -type d -print0 | xargs -0 rmdir --ignore-fail-on-non-empty
Search and replace in multiple files and save them with the same names - quickly and effectively!
for files in $(ls -A directory_name); do sed -i 's/search/replaced/g' $files; done;
O también :
find . -name "*.php" -exec sed -i 's/old/new/g' {} \;
Using scanner device from command line
scanimage -d mustek_usb --resolution 100 --mode Color > image.pnm
Extract track 9 from a CD
mplayer -fs cdda://9 -ao pcm:file=track9.wav
Record a screencast and convert it to an mpeg
ffmpeg -f x11grab -r 25 -s 800x600 -i :0.0 /tmp/outputFile.mpg
Find broken symlinks and delete them
Using the -L flag follows symlinks, so the -type l test only returns true if the link can't be followed, or is a symlink to another broken symlink.
find -L /path/to/check -type l -delete
If you don't want to delete them, but just want to list them, do
find -L /path -type l
If you want to delete them with confirmation first, do
find -L /path -type l -exec rm -i {} +
Alias para obtener la clave OpenPGP keys para PPAs de Launchpad en Ubuntu
alias launchpadkey="sudo apt-key adv --keyserver keyserver.ubuntu.com --recv -keys "
Uso : launchpadkey 4E5E17B5
Para montar una imagen iso
mount image-file.iso /mnt/cdrom -o loop
Crear una imagen iso de un CD o un DVD
mkisofs -r -o imagen.iso /cdrom/
Reemplazar los espacios en blanco por guiones de subrayado en el nombre de varios archivos
rename 'y/ /_/' *
Cambiar permisos solo a archivos
find . -type f -print0 | xargs -0 chmod -x
Simple list of apache2 virtualhosts
/usr/sbin/apache2ctl -S
Restart apache only if config works
alias restart='apache2ctl configtest && apache2ctl restart'
Save man pages to pdf
man -t man | ps2pdf - > man.pdf
Print man pages to PDF
man -t [command] | lp -d PDF -t [command].pdf
Update twitter from shell
curl -u user:pass -d status="Tweeting from the shell" http://twitter.com/statuses/update.xml
Convert an avi video to mp4
ffmpeg -i tuvideo.avi -s 480x320 -aspect 16:9 -b 768k -ab 64k -ar 22050 -r 30000/1001 tuNuevoVideo.mp4
Chequear si el sistema es de 32bits o 64bits
getconf LONG_BIT