Archive for September, 2010


If you like quick access to Documents,Spreadsheet

Or any other file you use often,ad them in your

Template folder in home dir.

Now when you mouse right click the are instant available

Advertisements

Run “python -m SimpleHTTPServer” in any directory, and the files are now available to anybody on http://your-ip:8000

ie:
cd /home/rich/shared
python -m SimpleHTTPServer

Two commands and you can share anything anywhere with anyone 😉

UUID stands for Universally Unique IDentifier and it is used in Linux to identify disk in the /etc/fstab file.

This way, the order of the disk in the motherboard can be changed, not affecting the mount point they will have.

As can be seen, it is a good idea to have fstab using UUID instead of the /dev/xdx way to identify the disks.

Let’s learn how to add disks, to your fstab file using UUID.

List the UUIDs

There are two ways of doing this:

  1. ls -l /dev/disk/by-uuid/
  2. Being the output

    lrwxrwxrwx 1 root root 10 Sep  2 10:54 11b7eb1f-79d5-4bfe-8aa5-9235e6cccbfe -> ../../sda1
    lrwxrwxrwx 1 root root 10 Sep  2 10:54 340cf4e2-4ee7-490c-a169-5045ebff4fac -> ../../sdb4
    lrwxrwxrwx 1 root root 10 Sep  2 10:54 37ea6741-c1b0-4297-9f23-b36417b3c109 -> ../../sdb1
    lrwxrwxrwx 1 root root 10 Sep  2 10:54 5b0a6c7b-d936-4470-a645-2b68db32d2c1 -> ../../sdb3
    lrwxrwxrwx 1 root root 10 Sep  2 10:54 6db36bd8-0778-4b35-a0bd-66487002cbe0 -> ../../sdb2
    lrwxrwxrwx 1 root root 10 Sep  2 10:54 afdc3ca9-c06e-452a-8e42-2b35ad9dac65 -> ../../sda2
    
  3. blkid
  4. Being the output

    /dev/sda1: UUID="11b7eb1f-79d5-4bfe-8aa5-9235e6cccbfe" SEC_TYPE="ext2" TYPE="ext3"
    /dev/sda2: LABEL="/home" UUID="afdc3ca9-c06e-452a-8e42-2b35ad9dac65" SEC_TYPE="ext2" TYPE="ext3"
    /dev/sdb1: UUID="37ea6741-c1b0-4297-9f23-b36417b3c109" TYPE="swap"
    /dev/sdb2: UUID="393ac665-f5c2-488d-b601-b59ba1d5675b" SEC_TYPE="ext2" TYPE="ext3"
    /dev/sdb3: UUID="5b0a6c7b-d936-4470-a645-2b68db32d2c1" TYPE="ext2"
    /dev/sdb4: UUID="340cf4e2-4ee7-490c-a169-5045ebff4fac" SEC_TYPE="ext2" TYPE="ext3"
    

Now that you have the UUID edit the /etc/fstab file and make it look like this:

UUID=340cf4e2-4ee7-490c-a169-5045ebff4fac / ext3 defaults 0 1
UUID=37ea6741-c1b0-4297-9f23-b36417b3c109 swap swap defaults 0 0
UUID=5b0a6c7b-d936-4470-a645-2b68db32d2c1 /boot ext2 defaults 0 1
UUID=6db36bd8-0778-4b35-a0bd-66487002cbe0 /home ext3 defaults 0 1

Instead of:

/dev/sdb4 / ext3 defaults 0 1
/dev/sdb1 swap swap defaults 0 0
/dev/sdb3 /boot ext2 defaults 0 1
/dev/sdb2 /home ext3 defaults 0 1

If you ever need to create directory trees like this

Directory Tree

You can do this:

cd /tmp

mkdir 1

cd 1

mkdir 2

cd 2

mkdir C

or, you can just do this:

mkdir -p /tmp/1/2/3

From the man page of mkdir

-p, --parents
no error if existing, make parent directories as needed

You can also use this option to create more complicated trees. Like this one.

directory tree

Do that with this:

mkdir -p /tmp/a{1,2,B{1,2}}

According to Wikipedia:

“In computing, tar (derived from tape archive and commonly referred to as “tarball”) is both a file format (in the form of a type of archive bitstream) and the name of a program used to handle such files. The format was created in the early days of Unix and standardized by POSIX.1-1988 and later POSIX.1-2001.

Initially developed to be written directly to sequential I/O devices for tape backup purposes, it is now commonly used to collect many files into one larger file for distribution or archiving, while preserving file system information such as user and group permissions, dates, and directory structures.

We will now learn some useful command to manage and create tar files.

We will cover how to:

  1. Create a tar file with no compression
  2. Untar an uncompressed tar file
  3. Create a gzipped tar file
  4. Untar a gzipped tar file
  5. Create a bzipped tar file
  6. Untar a bzipeed tar file
  7. Listing the contents of a tar file
  8. Extracting the files to a specific directory

1. Create a tar with no compression

tar cvf tar-file.tar directory/

2. Untar an uncompressed tar file

tar xvf tar-file.tar

3. Create a gzipped tar file

tar cvzf tar-file.tar.gz /directory

4. Untar a gzipped tar file

tar xvzf tar-file.tar.gz

5. Create a bzipped tar file

tar cvjf tar-file.tar.bz /directory

6. Untar a bzipeed tar file

tar xvjf tar-file.tar.bz

7. Listing the contents of a tar file

tar tvf tar-file.tar

For uncompressed tar file

tar tvfz tar-file.tar

For gzipped tar files

tar tvfj tar-file.tar

For jzipped tar files

8. Extracting the files to a specific directory

tar xvf -C tmp/som/other/directory tar-file.tar.gz

For uncompressed tar files

tar xvzf -C tmp/som/other/directory tar-file.tar.gz

For gzipped tar files

tar xvjf -C tmp/som/other/directory tar-file.tar.gz

For jzipped tar files

The options used

-c
create a new archive
-v
verbosely list files processed
-f
use archive file or device ARCHIVE
-x
eXtract the file
-z
–gzip, –gunzip –ungzip
-j
–bzip2
-C
change to directory DIR