Ubuntu tar Command: Create & Extract Archives

To perform file packaging and unzipping operations in Ubuntu using the tar command, you can follow the example below:

  1. Packaging files:
tar -cvf archive.tar file1.txt file2.txt

This will create a file named archive.tar, which includes two files: file1.txt and file2.txt.

  1. Extract files:
tar -xvf archive.tar

This will decompress the archive.tar file and extract its contents to the current directory.

  1. View the contents of the compressed file:
tar -tvf archive.tar

This will list the files contained in the archive.tar file.

  1. Compress folder:
tar -cvf archive.tar folder1

This will create a file called archive.tar, which includes the folder folder1 and all of its contents.

Here are some basic examples of how to use the tar command, which can be adjusted and expanded based on specific needs and situations.

bannerAds