Tar

 tar: The command itself.

[options]: Optional flags or settings that modify the behavior of the tar command.

[archive-file]: The name of the archive file you are creating or working with.

[file or directory to be archived]: The file or directory you want to include in the archive.

Options

Description

-c

Creates an archive by bundling files and directories together.

-x

Extracts files and directories from an existing archive.

-f

Specifies the filename of the archive to be created or extracted.

-t

Displays or lists the files and directories contained within an archive.

-u

Archives and adds new files or directories to an existing archive.

-v

Displays verbose information, providing detailed output during the archiving or extraction process.

-A

Concatenates multiple archive files into a single archive.

-z

Uses gzip compression when creating a tar file, resulting in a compressed archive with the ‘.tar.gz’ extension.

-j

Uses bzip2 compression when creating a tar file, resulting in a compressed archive with the ‘.tar.bz2’ extension.

-W

Verifies the integrity of an archive file, ensuring its contents are not corrupted.

-r

Updates or adds files or directories to an already existing archive without recreating the entire archive.

1. Creating an uncompressed tar Archive using option - cvf

This command creates a tar file called file.tar which is the Archive of all .c files in the current directory. 

tar cvf file.tar *.c

  • ‘-c’: Creates a new archive.

  • ‘-v’: Displays verbose output, showing the progress of the archiving process.

  • ‘-f’: Specifies the filename of the archive



This command creates a tar file called file.tar which is the Archive of all .c files in the current directory. 

tar cvf file.tar *.c

  • ‘-c’: Creates a new archive.

  • ‘-v’: Displays verbose output, showing the progress of the archiving process.

  • ‘-f’: Specifies the filename of the archive


This command creates a tar file called file.tar.gz which is the Archive of .c files.  

tar cvzf file.tar.gz *.c