Say hello tar command

You need to use the tar command. The tar command first offered in the seventh edition of unix v7 in January 1979. Each tarball stores data along with additional information such as:

  • File names
  • Directory structure
  • File permission
  • SELinux permissions
  • Timestamps
  • File ownership
  • File access permissions and more

How to create tar.gz file in Linux using command line

The procedure to create a tar.gz file on Linux is as follows:

  1. Open the terminal application in Linux
  2. Run tar command to create an archived named file.tar.gz for given directory name by running: tar -czvf file.tar.gz directory
  3. Verify tar.gz file using the ls command and tar command

Let us see all commands and options in details.

Linux create tar.gz file with tar command

Say you want to create tar.gz file named projects.tar.gz for directory called $HOME/projects/:

$ ls -l $HOME/projects/

Sample outputs:

total 8
drwxr-xr-x 2 vivek vivek 4096 Oct 30 22:30 helloworld
drwxr-xr-x 4 vivek vivek 4096 Oct 30 13:16 myhellowebapp

#linux

How to create tar.gz file in Linux using command line
1.45 GEEK