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 Kunder som kunne bruge dette svar
Hjalp dette svar dig?

Relaterede artikler

SSH ip command

If you wish to obtain information about your server’s IP on a Linux machine using SSH you can use...

SSH rm command

If you wish to remove a file or folder from your Linux system you can use SSH rm command. In this...

SSH echo command

One of the most useful commands in a Linux environment is echo. With it, you can provide output...

SSH history command

If you wish to find what commands you have previously executed in a Linux environment you can use...

SSH cd command

SSH cd command is mainly used to navigate in your Linux environment. In this article, we’ll show...

Powered by WHMCompleteSolution