Tar Files
Tar files are used to create archive files. Multiple files and directories can be archived into a single file by using the tar command. Keep in mind that tar does not perform compression.
Options
The most commonly used options in tar are –
-c | create archive |
-x | extract archive |
-v | verbosely list processed files |
-f | the output would be a file |
-t | displays content of an archive |
-p | Preserve permission |
-z | used for gzip |
-j | used for bzip2 |
Syntax
tar –cvf archive.tar file1 file2 file3 file4
Example – suppose you have to create a tar file (example.tar) with 3 files f1, f2, f3. Then the command would be –
# tar -cvf example.tar f1 f2 f3
Given below are some examples
1 # tar xvf example.tar
Extracts the archive example.tar in pwd to obtain original files
2 # tar tvf example.tar
Shows the contents of the archive example.tar
3 # tar pcvf example2.tar f1 f2 f3
Creates an archive example2.tar and preserves permission of the original files f1, f2, f3
gzip
As mentioned earlier, tar performs no compression. To compress the archive, gzip can be used. gzip has some additional options –
-1 | fastest compression regardless of the compression ratio |
-9 | best possible compression ratio regardless of the time needed |
# gzip example.tar | compresses the archive example.tar and creates a file example.tar.gz |
# gunzip example.tar.gz | extracts the compressed archive example.tar.gz |
# gzip -1 example2.tar | performs fastest compression |
# gzip -9 example2.tar | performs best compression |
Alternative method | |
# tar zcvf example.tar.gz f1 f2 f3 | creates a compressed archive example.tar.gz with the files f1, f2 and f3 |
# tar zxvf example.tar.gz | extracts the compressed archive example.tar.gz |
bzip2
bzip2 is a more powerful compression tool than gzip. bzip2 is the upgrade of the original bzip. bzip2 also supports fastest and best compression.
# bzip example.tar | compresses the archive example.tar and creates a file example.tar.bz2 |
# bunzip2 example.tar.bz2 | extracts the compressed archive example.tar.bz2 |
# bzip2 -1 example2.tar | performs fastest compression |
# bzip2 -9 example2.tar | performs best compression |
Alternative method | |
# tar jcvf example.tar.bz2 f1 f2 f3 | creates a compressed archive example.tar.bz2 with the files f1, f2 and f3 |
# tar jxvf example.tar.bz2 | extracts the compressed archive example.tar.bz2 |
RPM
RPM or Relational Package Manager is used to install packages/software into the system. RPM can be setup using the following command
# rpm –ivh rpm_name
-i = install
-v = show output verbosely
-h = show progress with #
RPM sometimes creates dependency problems. For example, if A.rpm requires B.rpm to be previously installed, then A.rpm cannot be installed unless B.rpm is installed first.
To install A.rpm ignoring dependency, the following command may be used, but it is very likely that the package will not work properly.
# rpm –ivh A.rpm –no-deps
To check whether an RPM is installed, the following commands can be used
# rpm –q RPM1 | Checks whether package RPM1 is installed. |
# rpm –qa | Shows all installed RPM |
# rpm –ql RPM2 | Shows locations of all files created during the installation process of RPM2 |
0 comments:
Post a Comment