Useful tar commands for developers

The word tar stands for tape achieve. Tar is mainly used tape drive backup used by the Linux/Unix system. It allows us to quickly access a collection of files.

It also allows highly compressed archive files commonly known as tarball, or tar, gzip, and bzip in Linux.

Create a gzip tar file

# Create a gzip file using tar command
$ tar -czf archive.tar.gz /htdocs /sql

Create a gzip tar file but exclude one directory

# Exclude one directory
$ tar -pczf archive.tar.gz --exclude "/home/user/htdocs/tmp/" /home/user/htdocs/