Tar Command in LinuxUsing the tar command in Linux
The tar command allows you to create and manage archives.
Archives are files that may contain many other files or directories, and can be compressed to reduce their size. The following command is an example that will create a compressed archive with two files inside of it.
tar -czvf archive.tar.gz file1 file2
This will create archive.tar.gz with the files – file1 and file2 in it. In this example, ‘archive’ is replaced with whatever you want to name it, and file1 and file2 would be actual file names that you want to be compressed.
Flags ‘c’ and ‘f’ are required to create the archive, while flags ‘z’ and ‘v’ alter it:
c – Creates the archive itself.
z – Use gzip compression to compress the archive and reduce its size.
v – Lists the files being archived.
f – Gives the archive a name