Compress and Extract Files in Linux

Extract:

.tar.bz2
To extract a tar (Tape ARchiver) file, type the following in the shell prompt:

1
tar xvjf yourFileName.tar.bz2

Which will untar it to the current directory. Depending on the file structure that being compressed, it might create sub-directories.
Parameters:
x – extract
v – verbose output (lists all files as they are extracted)
j – deal with bzipped file
f – read from a file, rather than a tape device

.tar.gz or .tgz

1
2
tar xvzf file.tar.gz
tar xvzf file.tgz

Parameters:
-x, –extract, –get extract files from an archive
-v, –verbose verbosely list files processed
-z, –gzip, –gunzip, –ungzip filter the archive through gzip
-f, –file=ARCHIVE use archive file or device ARCHIVE

.bz2 file

1
tar jxf YOUR_FILE_NAME.bz2

.zip file

1
unzip YOUR_FILE_NAME.zip
This entry was posted in Bash, Linux and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


1 + = four