RHEL 6 Linux Bset Gude

RHEL 6 Linux  Bset Gude
Ajay Saxena

Tuesday 6 May, 2014

Tar’s ten very useful command in linux

The full form of tar is tape archive. Tar is the primary archiving utility in Linux / Unix. Using the tar command we can compress high number of files and folders to form a archive file. Archived tar file is commonly called us tar ball. Tar archived file will ends in three formats filename.tar, filename.tar.bz and filename.tar.bz2. The tar file ends with .bz is said to be gzipped tar archive and the tar file ends with .bz2 is said to be bzipped tar archive. Earlier we have seen data compression using zip command.
Here is top 10 useful Tar command in linux.
1.Command to create tar archive file
tar -cvf  nagios-3.2.0.tar folder_name
-c  option is used to create a tar ball
-v  option is used to verbosely show the .tar file progress.
-f  specifies the filename type
2.Command to extract tar archive file
If you extract a tar ball it will be extracted in the same directory.
tar -xvf nagios-3.2.0.tar
-x  option is used to extract a tar ball.
-v  option is used to verbosely show the .tar file progress.
-f  specifies the filename type.
3.Command to extract tar archive file in different directory.
If you want to extract a tar ball in to different directory use “-C” option.
tar -xvf nagios-3.2.0.tar -C /root/Desktop/
-C Option is used to extract the tar ball in different location.
4.Command to view files inside tar archive with out extracting it.
tar -tvf nagios-3.2.0.tar
-t option is used to view content present inside the archive file.
5.Command to extract only single file from a tar archive.
tar -xvf nagios-3.2.0.tar compile.sh
Another Method
tar –extract –file=nagios-3.2.0.tar compile.sh
6.Command to extract multiple files from a tar archive.
syntax:
tar -xvf archive_filename.tar file1 file2
Example:
tar -xvf nagios-3.2.0.tar compile.sh config.guess
Another Method
tar –extract –file=nagios-3.2.0.tar compile.sh config.guess
Examples of gzipped tar archive
7.Command to create tar.gz archive file
tar -cvzf  tts.tar.gz folder_name
-z  Option is used to create gzip archive file
-c  option is used to create a tar ball
-v  option is used to verbosely show the .tar file progress.
-f  specifies the filename type
8.Command to extract tar.gz archive file
If you extract a tar ball it will be extracted in the same directory.
tar -xvf nagios-3.2.0.tar.gz
-x  option is used to extract a tar ball
-v  option is used to verbosely show the .tar file progress.
-f  specifies the filename type
9.Command to extract tar.gz archive file in different directory
If you want to extract a tar ball in to different directory use “-C” option.
tar -xvf nagios-3.2.0.tar.gz -C /root/Desktop/
-C Option is used to extract the tar ball in different location.
10.Command to view files inside tar.gz archive with out extracting it.
tar -tvf nagios-3.2.0.tar.gz
-t option is used to view content present inside the archive file.
11.Command to extract only single file from a tar.gz archive.
tar -xvf nagios-3.2.0.tar.gz compile.sh
Another Method
tar –extract –file=nagios-3.2.0.tar.gz compile.sh
12.Command to extract multiple files from a tar.gz archive.
syntax:
tar -xvf archive_filename.tar.gz file1 file2
Example:
tar -xvf nagios-3.2.0.tar.gz compile.sh config.guess
Another Method
tar –extract –file=nagios-3.2.0.tar.gz compile.sh config.guess
Examples of bzipped tar archive
13.Command to create tar.bz2 archive file
tar -cvjf  tts.tar.gz folder_name
-j  Option is used to create gzip archive file
-c  option is used to create a tar ball
-v  option is used to verbosely show the .tar file progress.
-f  specifies the filename type
14.Command to extract tar.bz2 archive file
If you extract a tar ball it will be extracted in the same directory.
tar -xvf nagios-3.2.0.tar.bz2
-x  option is used to extract a tar ball
-v  option is used to verbosely show the .tar file progress.
-f  specifies the filename type
15.Command to extract tar.bz2 archive file in different directory
If you want to extract a tar ball in to different directory use “-C” option.
tar -xvf nagios-3.2.0.tar.bz2 -C /root/Desktop/
-C Option is used to extract the tar ball in different location.
16.Command to view files inside tar.bz2 archive with out extracting it.
tar -tvf nagios-3.2.0.tar.bz2
-t option is used to view content present inside the archive file.
17.Command to extract only single file from a tar.bz2 archive.
tar -xvf nagios-3.2.0.tar.bz2 compile.sh
Another Method
tar –extract –file=nagios-3.2.0.tar.bz2 compile.sh
18.Command to extract multiple files from a tar.bz2 archive.
syntax:
tar -xvf archive_filename.tar.bz2 file1 file2
Example:
tar -xvf nagios-3.2.0.tar.bz2 compile.sh config.guess
Another Method
tar –extract –file=nagios-3.2.0.tar.bz2 compile.sh config.guess
19.Command to add files and folders to an existing or already created tar ball
tar -rvf testing.tar test/
-r Option is used to append files and folders to the end of an archive
20.Command to view tar version
tar –version
 ............................................................................

No comments:

Post a Comment

Thanks for come here..