Why we use file compassion are explained below,

· Results in smaller file size.

· Text files can be compressed up to 75%.

· Binary files usually don’t compress much.

· tar” archives are often compressed.

[root@localhost root]# gzip

ð It can compress any text file or binary file for saving disk space. For text file, it will zip more then 60% or 70 % but for binary file it will perform more then 30% or 40%. After doing the zip of the file is added a extension of "gz" and color of the file's name will changed.

[root@localhost root]# gzip -v

ð It will showing how many percentage are zipped.

[root@localhost root]# zcat .gz

ð To read a zip file.

[root@localhost root]# gunzip

ð To unzip a zip file.

[root@localhost root]# gunzip -c | wc -l

[root@localhost root]# bzip2

ð It also works as "gzip" command.

[root@localhost root]# bzcat

ð To read a zip file which file are zipped by "bzip2" command.

[root@localhost root]# bunzip2

ð For unzipping a zip file, which file are zipped by "bzip2" command.

[root@localhost root]# comprise

[root@localhost root]# uncomprise

ð These two commands are used for older version of UNIX.


Archiving places many files into one target file. Easier to back up, store, transfer. “tar” is standard Linux archiving command. Usually extension of an archive file is “.tar”.

Creating an Archive:


tar crf archive_name.tar file1 file2 file3 . . . . . . filen




Creates a new archive.


Produces verbose messages.


archive_name is use of new file.


Extracts an archive.


Displays list of all files in the archive.


A long listing of each file in the archive.


For gzip compression.


For bzip2 compression.


[root@localhost root]# tar cvf work.tar .bash_profile myfile profile1

[root@localhost root]# tar cvf myhome.tar ~

[root@localhost root]# tar cvf /dev/fd0 ~

Inspecting Archives:

To inspect archives we can use the following commands,

[root@localhost root]# tar tf archive_name.tar

ð It displays a list of all files in the archive.

[root@localhost root]# tar tvf archive_name.tar

ð The v causes a long listing of each file in the archive.

Extracting an Archive:

[root@localhost root]# tar xvf archive_name.tar

ð The archive will be extracted in the current directory by first maintaining their hierarchy relative to the current directory.

Compressing Archives:

Often “tar” archives are compressed/uncompressed archives. Compression switches use during creation and extraction.


[root@localhost root]# tar czf smallHome.tgz ~

[root@localhost root]# mv smallHome.tgz /tmp

[root@localhost root]# cd /tmp

[root@localhost tmp]# gzip -d smallHome.tgz

“tar” to unformatted Floppies:

Floppies can be used like tape drives. The requirements are given below,

· Low level format required.

· File system not needed.

· Use tar to write to the floppy.

· /dev/fd0 is the destination.

· Floppy can’t be mounted.


[root@localhost root]# tar czvf /dev/fd0 mydir

ð Whole floppy disk will act now as tape drive and it carries the data of mydir as archive.

[root@localhost root]# tar xzvf /dev/fd0

ð The archive will be extracted in the current directory

RAID - Redundant Array of Independent Disk

Four types of RAID are supported by Red Hat Linux.





All the statements to setup RAID-1 are given below and this statement is same for all others RAID installation.

1. By the "fdisk" command, we will first create two drives of same size. Now two drives will formatted with LINUX RAID SOFTWARE type.

[root@localhost root]# fdisk /dev/hda

ð Now we will find all the options to create new drive and format the drives. And after we will reboot the computer.

2. Go to the directory called "raidtool",

[root@localhost root]# cd /usr/share/doc/raidtool-1.00.3

[root@localhost raidtool-1.00.3]# ls





Because we are working with RAID 1, so we will open the file raid1.conf.sample and edit this file.

[root@localhost raidtool-1.00.3]# vi raid1.conf.sample

ð It will Show all the information for installation of RAID1. Copy it to the "etc" directory and save as it with a new file name "raidtab".

[root@localhost raidtool-1.00.3]# cp raid1.conf.sample /etc/raidtab

[root@localhost raidtool-1.00.3]# cd

[root@localhost root]# vi /etc/raidtab

raiddev /dev/md0

raid-level 1 # This is the raid number. Such that RAID1

nr-raid-disks 2 # How many disk will be used.

nr-spare-disks 0

chunk-size 4

device /dev/hda5

raid-disk 0

device /dev/hda6

raid-disk 1

3. Now we will create md0 device,

[root@localhost root]# mkraid /dev/md0

[root@localhost root]# mkraid -R /dev/md0

To create md0, it will take all the information from "/etc/raidtab" file. To check that md0 is created or not, open the file from "proc" directory.

[root@localhost root]# vi /proc/mdstat

ð It will show all the information of "md0".

4. Now, we will format "md0" by the command as

[root@localhost root]# mkfs -t ext3 /dev/md0

5. Now, We need to create a new directory for making mount point of "md0".

[root@localhost root]# mkdir /raid

Open the "fstab" file and add a new line as below for mounting md0.

[root@localhost root]# vi /etc/fstab

/dev/md0 /raid raid defaults 0 0

This line will active after booting time of computer. You can mount directly by the command as,

[root@localhost root]# mount /dev/md0 /raid

[root@localhost root]# umount /raid

Note: To check the performance of RAID, you can also mount two devices,

[root@localhost root]# mount /dev/hda5 /opt

[root@localhost root]# mount /dev/hda6 /tmp

[root@localhost root]# cd /opt

[root@localhost opt]# ls

file1 file2 dir1 dir2 lost+found

[root@localhost opt]# cd /tmp

[root@localhost tmp]# ls

file1 file2 dir1 dir2 lost+found