Pranaam to all bhai ji _/\_
Today we are going to discuss about tar archive and compression method for creating compressed files in linux.
Tar command is use to generate an archive of folders/files , it doesnt compress the size.
where as , for compression we will use gzip or bzip.
in this tutorial we will learn, how to
--create tar archives (gzip and bzip compression integration).
--extract tar archive or a single file/directory.
--listing tar archive content.
ok now lets start :)
Creating tar archive using tar command :-
put your files in a folder and then run this command
tar -cf tar_archive_name.tar file_name/folder_in_which_we_placed files
here
tar is command
c and f are options for tar commands which is telling tar command that , create(c) a tar file(f)
whose name is tar_archive_name.tar and folder , whose tar archive we have to create is folder_in_which_we_placed files .
remember , use option f in the last else tar command may through error because f tells the name of the archive.
for example, i have folder indishell and i want to create a tar archive of this folder with name ica.tar
so command will be
tar -cf ica.tar indishell
this command will generate tar archive of folder indishell with name ica.tar in the directory where you working.
we need to specify either full path to indishell folder or need to switch in the directory where indishell folder exist.
Creating zipped tar archive :-
ok , now we will create zipped tar archive , means command will generate tar archive and then zipped file of that archive .first, we are going to use gzip compression with tar
let see how to do it :)
command is
tar -czf compressed_archive_name.tar.gz file_name/folder_name_in which_we_placed_files
here -czf tell to tar command that create(c for compress) a archive with gzip compression(z) and archive name(f for file) will be compressed_archive_name.tar.gz and file/folder whose archive has to generate is file_name/folder_name_in which_we_placed_files.
for example , i am going to generate zipped archive ica.tar.gz of epel-release file
command will be
tar -czf ica.tar.gz epel-release...
:)
Extracting files from tar archive :-
for extracting file/folders from packed archive tar , we use command
tar -xf tar_file.tar
here option x stands for extract and f tells the tar file name to tar command . tar_file.tar is the name of the tar file which we want to unpack.
lets have look on example , i have ica.tar archive on my machine and this archive contains epel-release.rpm file.
its simple tar file so command is
tar -xf ica.tar
Extracting file/folders from compressed tar archive :-
how to unpack compressed tar archive (tar.gz) , its also not too much hard or wired ;)
its similar to extracting simple tar archive, we need to add z in options and then tar command can extract compressed tar archive
command will be
tar -xzf tar_filename.tar.gz
here x stands for extract , z for gzip compression and f for file
Creating bzipped compressed archive(tar.bz2) :-
let create tar archive with bzip compression
we just need to add j in option of tar command
command is
tar -cjf archive_name.tar.bz2 file/folder_in_which_we_placed_files
here c stands for create , j for bzip compression, f for file name , archive_name.tar.bz2 is the name of the archive with which you want to create compressed archive , file/folder_in_which_we_placed_files is the name of the name of the source file/folder , whose archive you want to create
for example i want to create compressed archive of "in" folder with name indishell.tar.bz2
command is
tar -cjf indishell.tar.bz2 in
extracting bzip compressed archives
we are going to extract bzip compressed archives using tar command
our bzip compressed archive will have extension .tar.bz2
to extract content from this archive , we have command
tar -xjf archive.tar.bz2
Listing content of archive using tar command:-
if we want to list content of simple tar archive (file having .tar extension), command will be
tar -tzf archive_file.tar.gz
if archive is bzip compressed , we need to use command
Extracting single file/directory from tar archive:-
we can extract single file/directory from tar archive , just need to specify file/folder path (in archive ) after archive extraction command
for example , we have tar archive indishell.tar.bz2 and this archive contains 2 tar files in a folder having name "in"
i want to extract one tar file from indishell.tar.bz2 archive
command will be
for tar.bz2 archive
tar -xjf tar_name.tar.bz2 path_to_file/folder_inside_tar_archive
tar -xjf indishell.tar.bz2 in/ica.tar
for .tar archive command is
tar -xf arvhive_name.tar path_to_file/folder_inside_archive
for tar.gz archive , command is
tar -xzf archive_name.tar.gz path_to_file/folder_inside_archive
This was a short tutorial on tar archive and compressed archives
Thank you
Greetz to:-
zero cool, Team INDISHELL , Hardeep bhai and AR AR bhai ji
Today we are going to discuss about tar archive and compression method for creating compressed files in linux.
Tar command is use to generate an archive of folders/files , it doesnt compress the size.
where as , for compression we will use gzip or bzip.
in this tutorial we will learn, how to
--create tar archives (gzip and bzip compression integration).
--extract tar archive or a single file/directory.
--listing tar archive content.
ok now lets start :)
Creating tar archive using tar command :-
put your files in a folder and then run this command
tar -cf tar_archive_name.tar file_name/folder_in_which_we_placed files
here
tar is command
c and f are options for tar commands which is telling tar command that , create(c) a tar file(f)
whose name is tar_archive_name.tar and folder , whose tar archive we have to create is folder_in_which_we_placed files .
remember , use option f in the last else tar command may through error because f tells the name of the archive.
for example, i have folder indishell and i want to create a tar archive of this folder with name ica.tar
so command will be
tar -cf ica.tar indishell
this command will generate tar archive of folder indishell with name ica.tar in the directory where you working.
we need to specify either full path to indishell folder or need to switch in the directory where indishell folder exist.
Creating zipped tar archive :-
ok , now we will create zipped tar archive , means command will generate tar archive and then zipped file of that archive .first, we are going to use gzip compression with tar
let see how to do it :)
command is
tar -czf compressed_archive_name.tar.gz file_name/folder_name_in which_we_placed_files
here -czf tell to tar command that create(c for compress) a archive with gzip compression(z) and archive name(f for file) will be compressed_archive_name.tar.gz and file/folder whose archive has to generate is file_name/folder_name_in which_we_placed_files.
for example , i am going to generate zipped archive ica.tar.gz of epel-release file
command will be
tar -czf ica.tar.gz epel-release...
:)
Extracting files from tar archive :-
for extracting file/folders from packed archive tar , we use command
tar -xf tar_file.tar
here option x stands for extract and f tells the tar file name to tar command . tar_file.tar is the name of the tar file which we want to unpack.
lets have look on example , i have ica.tar archive on my machine and this archive contains epel-release.rpm file.
its simple tar file so command is
tar -xf ica.tar
Extracting file/folders from compressed tar archive :-
how to unpack compressed tar archive (tar.gz) , its also not too much hard or wired ;)
its similar to extracting simple tar archive, we need to add z in options and then tar command can extract compressed tar archive
command will be
tar -xzf tar_filename.tar.gz
here x stands for extract , z for gzip compression and f for file
Creating bzipped compressed archive(tar.bz2) :-
let create tar archive with bzip compression
we just need to add j in option of tar command
command is
tar -cjf archive_name.tar.bz2 file/folder_in_which_we_placed_files
here c stands for create , j for bzip compression, f for file name , archive_name.tar.bz2 is the name of the archive with which you want to create compressed archive , file/folder_in_which_we_placed_files is the name of the name of the source file/folder , whose archive you want to create
for example i want to create compressed archive of "in" folder with name indishell.tar.bz2
command is
tar -cjf indishell.tar.bz2 in
extracting bzip compressed archives
we are going to extract bzip compressed archives using tar command
our bzip compressed archive will have extension .tar.bz2
to extract content from this archive , we have command
tar -xjf archive.tar.bz2
Listing content of archive using tar command:-
if we want to list content of simple tar archive (file having .tar extension), command will be
tar -tf archive_name.tar
for listing content of gzip compressed archive, use command
tar -tzf archive_file.tar.gz
if archive is bzip compressed , we need to use command
tar -tjf archive_name.tar.bz2
Extracting single file/directory from tar archive:-
we can extract single file/directory from tar archive , just need to specify file/folder path (in archive ) after archive extraction command
for example , we have tar archive indishell.tar.bz2 and this archive contains 2 tar files in a folder having name "in"
i want to extract one tar file from indishell.tar.bz2 archive
command will be
for tar.bz2 archive
tar -xjf tar_name.tar.bz2 path_to_file/folder_inside_tar_archive
tar -xjf indishell.tar.bz2 in/ica.tar
for .tar archive command is
tar -xf arvhive_name.tar path_to_file/folder_inside_archive
for tar.gz archive , command is
tar -xzf archive_name.tar.gz path_to_file/folder_inside_archive
This was a short tutorial on tar archive and compressed archives
Thank you
Greetz to:-
zero cool, Team INDISHELL , Hardeep bhai and AR AR bhai ji
0 comments