linux tar gz folder code example

Example 1: gzip folder with tar

# gzip my-folder-name
#
# flags:
# 	z = filter the archive through gzip
# 	c = create a new archive
# 	v = verbosely list files processed
# 	f = use archive file or device ARCHIVE
#
# Example:
tar -zcvf my-filename.tar.gz my-folder-name

Example 2: unzip a tar.gz file in linux

tar -xvzf community_images.tar.gz

Example 3: tar directory

tar -czvf archive.tar.gz stuff

Example 4: how to put directory in archive bash

tar cf ostechnix.tar ostechnix/
# Here, c flag refers create new archive and f refers the file name.