This is a no-frills Linux command line guide/cheat sheet that will help you archive or compress just about any file that you’re bound to come across. If you’d like to have more options, read the man pages! Also, the opposite to this guide about extracting/uncompressing/unarchiving files in Linux can be found here.
read more…
Forget pulling up Photoshop, GIMP, or any other GUI program for a simple CLI job. With utilities like ‘mogrify‘ for Linux and ‘sips‘ for Mac OSX, it’s incredibly quick and easy to batch resize images through the command line. For example, if I wanted to resize all images within a particular folder to a width of 800px without losing aspect ratio, I would use the following commands:
Under Linux:
mogrify -resize 800 *.jpg
Under Mac OSX:
sips --resampleWidth 800 *.jpg
There are many more options for these programs, so play around and be sure to read the man pages.
Another usage example that I heard about today was to use the commands above in a script that will automatically create a thumbnail, small, medium, and large image sizes from a supplied image and then copy them off to the appropriate folder. This is useful in building a website that has a lot of different image sizes required for the same image.
Additional Resources:
http://www.smokinglinux.com/tutorials/howto-batch-image-resize-on-linux
http://www.ibm.com/developerworks/linux/library/l-graf/
Table of Contents
This guide will assist in loading a pre-built VirtualBox image. The example used is a pre-built Ubuntu 9.10 “Karmic Koala” guest image. Any VirtualBox image can be used however.
read more…
I hadn’t realized this before, but you can shrink a dynamic VirtualBox disk image. This is incredibly helpful if you’ve uninstalled programs or freed up a bunch of space and you want the .vdi image size to reflect that. Otherwise, the dynamic disk image will stay the same size it was before. The process is simple, but can be a bit involved so I’ll just touch on the basics and then refer you to a few guides that were really helpful when I did this for my Ubuntu 9.10 VirtualBox image. These guides can be applied to other guest images as well.
1.) Install “zerofree” on your virtualbox guest machine.
2.) Boot to safe mode (recovery mode) where you can access your root partition (/dev/sda1).
3.) Mount the root partition as read-only (mount -o ro /dev/sda1 /mnt/tmp)
4.) Run “zerofree /dev/sda1″
5.) Shutdown the virtual machine and run “VBoxManage modifyhd –compact /path/to/virtualboximage.vdi”
In-Depth Guides:
http://maketecheasier.com/shrink-your-virtualbox-vm/2009/04/06 — Keep in mind that zerofree does in fact support ext4 (I think this article is a tiny bit dated, but it’s a great one).
http://www.virtualbox.org/manual/UserManual.html — The all important VirtualBox Users Guide.
http://forums.virtualbox.org/viewtopic.php?p=29272#29272 — Another good reference for VirtualBox
You can count up or down easily in the terminal using the command seq. Combine this with a for loop and you have a really quick and easy way to count from x to y for the variable i. For example, if I wanted to download all images that have been numbered step1.png, step2.png, step3.png, …, step20.png I could use the following command to download them:
for i in $(seq 1 20); do wget http://website.com/images/step$i.png; done
Mac OS Users:
Unfortunately, ’seq’ isn’t included on Mac OS, so you’ll need to use the ‘jot’ program or cleverly use the ‘jot’ program in a script to mimic the ’seq’ command and syntax like so (thanks to Fredrick Rodland for this one):
#!/bin/sh
# Fredrik Rodland
# dev_____AT____rodland.no
# http://rodland.no
# 20081004
MIN=$1
MAX=$2
PAD=$3
LENGTH=${#MAX}
if [ $PAD ]; then
W="-w %0$LENGTH""d"
fi
let NMB_STEP=$MAX-$MIN+1
jot $W $NMB_STEP $MIN
If you’re a Mac user, I would recommend that you copy and save this to a file, save it as seq, make it executable with ‘chmod +x seq’, and finally copy it to your /usr/local/bin directory with ‘cp seq /usr/local/bin’.