Linux Commands - Archiving and Compression
Commonly used flags:
- -c: Create a new archive
- -f: Create a output file.
- -x: Extract from tar archive.
- -t: List the contents of tar without extracting.
- -r: Append file to an existing archive
- Example:
- Commonly used flags:
- -l: List compressed size, uncompressed size, ratio, uncompressed name
- —v: enable verbose
- Example:
gzip: Compression utility that uses DEFLATE compression algorithm.Basic Syntax: gzip [OPTIONS] FILE
gzip myarchive.tar
#view result using ls
myarchive.tar.gz
#unzip
gunzip myarchive.tar.gz
#view result using ls
myarchive.tar
tar: It is used to create, manipulate and extract tar archives.Basic Syntax: tar [OPTIONS] FILE...
#create tar archive of file or directory
tar -cf myarchive.tar test/
#append files in existing archive
tar -rf myarchive.tar cust_data.sql
#list the contents of tar without extracting
tar -tf myarchive.tar
#result
backupScript/
cust_data.sql
#extract specific file from archive
tar -xf myarchive.tar cust_data.sql
#view extracted file
test@test:~$ ls
cust_data.sql myarchive.tar