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

Linux top command

If you wish to monitor the performance of your VPS or Dedicated server and track processes, RAM...

Linux ping command

If you wish to test your connection to a server from your Linux system you can use the Linux ping...

Linux file command

The file command is used to check a file’s type and contents in Linux environment. It is most...

Linux export command

When you’re managing your shell’s variables and you wish to save them to your environment you can...

Linux su command

The su command is most commonly used to switch to another user. You will then be able to run...