Thursday, October 30, 2008

tar command examples

tar cjvf myfiles.tar.bz2 *.txt
tar czvf myfiles.tar.gz *.txt

tar cf filename.tar dirname
or
cd into directory tar cvf filename.tar *

tar cvf /dev/fd0 /usr/src /etc /home

home dir back up

cd /home

sudo tar czvf /tmp/homedir.tgz *
sudo tar czvf /tmp/homedir.tgz * --newer "2006-06-23"
...............................................................

tar -jxvf file.tar.bz2
tar -zxvf file.tar.gz -C /tmp

dd command examples

use dd to create file of any size
dd if=/dev/zero of=testfile_10MB bs=10485760 count=1

Backup Entire Harddisk to an Image
Backup content of the harddrive to a file. Creates an image of the drive
dd if=/dev/sda of=/tmp/sda.iso


back hard disk to remote host
dd bs=1M if=/dev/hda | gzip | ssh user@ip_addr 'dd of=hda.gz'

Spell Check a Text File using Aspell

aspell check test.txt

Linux command to get the MD5 of a File

Use this command to find the MD5 of a file.: md5sum file.txt

Wednesday, October 29, 2008

pdfimages: Extract and Save Images From A Portable Document Format ( PDF ) File

Posted By vivek On August 28, 2008 @ 8:36 pm In BASH Shell, CentOS, Debian / Ubuntu, Linux, Linux / UNIX File Formats, Package management, RedHat and Friends, Suse, UNIX, Ubuntu Linux | No Comments

Q. How do I extract images from a PDF file under Linux / UNIX shell account?

A. pdfimages works as Portable Document Format (PDF) image extractor under Linux / UNIX operating systems. It saves images from a PDF file as Portable Pixmap (PPM), Portable Bitmap (PBM), or JPEG files. Pdfimages reads the PDF file PDF-file, scans one or more pages, and writes one PPM, PBM, or JPEG file for each image, image-root-nnn.xxx, where nnn is the image number and xxx is the image type (.ppm, .pbm, .jpg).

pdfimages is installed using poppler-utils package under various Linux distributions:
# yum install poppler-utils
OR
# apt-get install poppler-utils
pdfimages syntax

pdfimages /path/to/file.pdf /path/to/output/dir
Extract the PDF file called bar.pdf and save every image as image-00{1,2,3..N}.ppm, enter:
$ pdfimages bar.pdf /tmp/image
$ ls /tmp/image*
Sample output:

image-000.ppm image-1025.ppm image-1140.ppm image-1256.ppm image-247.ppm image-374.ppm image-501.ppm image-628.ppm image-755.ppm image-882.ppm
image-001.ppm image-1026.ppm image-1141.ppm image-1257.ppm image-248.ppm image-375.ppm image-502.ppm image-629.ppm image-756.ppm image-883.ppm
image-002.ppm image-1027.ppm image-1142.ppm image-1258.ppm image-249.ppm image-376.ppm image-503.ppm image-630.ppm image-757.ppm image-884.ppm

Normally, all images are written as PBM (for monochrome images) or PPM (for non-monochrome images) files. With the -j option, images in DCT format are saved as JPEG files. All non-DCT images are saved in PBM/PPM format as usual:
$ pdfimages -j bar.pdf /tmp/image
The -f option Specifies the first page to scan. To scan first 5 pages, enter:
$ pdfimages -j -f 5 bar.pdf /tmp/image
The -l option specifies the last page to scan. To scan last 5 pages, enter:
$ pdfimages -j -l 5 bar.pdf /tmp/image



URL to article: http://www.cyberciti.biz/faq/easily-extract-images-from-pdf-file/

Dump the Text on a Virtual Console to a File

If you’re trying to fix a problem, you might want to capture the output of a command for reproduction on a website forum, along with the command you typed to get the results. If you’re working in a terminal window, you can cut and paste, but what if you’re working at a virtual console? If you simply want to capture the result of a command, just redirect the output:

ls > output.txt 2>&1

This will send both the output and error output (if any) of the ls command to output.txt. If you want to capture the command you typed and any other command-line detritus (including output), use the screendump command. The following will send everything currently on the current screen (command-line prompts included) to a text file called output.txt:

sudo screendump > output.txt

The command has to be issued as root because of permission issues, but the resulting file will be owned by you.

Tested on Ubuntu 8.04
source www.ubuntukungfu.org