Wednesday, 26 June 2013

How to compress and extract zip, tar , tar.gz and tar.bz2 in Linux/RHEL/Centos


ZIP : Compress and extract zip file in Linux

Compress file and folder with zip

# zip -r archive-name.zip directory_name

extract file and folder with zip
#unzip archive-name.zip

TAR: Compress and extract TAR file in Linux

Compress file and folder with tar
# tar -cvf archive-name.tar directory_name

extract file and folder with tar
# tar -xvf archive-name.tar

Define location where you want to extract

# tar -xvf archive-name.tar -C /home/extract-here/

TAR.GZ: Compress and extract TAR.GZ file in Linux

Compress file and folder with tar.gz
# tar -zcvf archive-name.tar.gz directory_name

extract file and folder with tar
# tar -zxvf archive-name.tar.gz

Define location where you want to extract

# tar -zxvf archive-name.tar.gz -C /tmp/extract_here/

TAR.BZ2: Compress and extract TAR.BZ2 file in Linux

Compress file and folder with tar.bz2
# tar -jcvf archive-name.tar.bz2 directory_name

extract file and folder with tar
# tar -jxvf archive-name.tar.bz2

Define location where you want to extract

# tar -jxvf archive-name.tar.bz2 -C /tmp/extract_here/

No comments:

Post a Comment

Install XRDP in Centos 7

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum update yum groupinstall "GNOME Desktop" ...