Linux tar Command

The Linux tar command is used to compress and extract files to and from an archive. In this article, we’ll show the basic usage of the tar command. It is very handy when it comes to making full back ups of your files and folders or restoring your transferred website from another host.

Creating an Archive using the Linux tar command

tar -czvf file1 file2 file3 archiveToCreate.tar.gz

This will create an archive called archiveToCreate.tar.gz with the files file1, file2 and file3 in it.

The flags represent:

  • c – create
  • z – using gzip compression
  • v – verbal, displaying information about the archive while archiving
  • f – using an archive file

Creating an Archive of an Entire Directory

tar -czvf /path/to/directory/* archiveToCreate.tar.gz

You can use WildCard to create an archive of all files within a directory

Extracting an Archive using the Linux tar command

tar -xzvf archiveToExtract.tar.gz

This will extract all files in the archive in the current directory, the only flag that is changed is the -c (for creating) with the x - extract the archive. 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Install WordPress via SSH

Since WordPress is the most widely used CMS it’s installation process has been made as simple and...

SSH Execute Command on a Remote server

Via SSH you can connect to a remote server’s shell. This will allow you to execute commands on...

How to connect to your shared hosting account via SFTP with FileZilla

SFTP is a convenient way to use SSH, while also using the interface of a simple FTP. In order to...

SSH netstat command

If you wish to debug or track statistics of your network in a Linux environment you can use SSH...

SSH head command

If you wish to view the head or the topmost of a large text file you can use SSH head command....