What is the purpose of the tar command in UNIX?

What is the purpose of the tar command in UNIX?

a) To create and manage archive files
b) To delete files
c) To view file permissions
d) To display file contents

Answer:

a) To create and manage archive files

Explanation:

The tar command in UNIX is used to create, extract, and manage archive files. It is commonly used to bundle multiple files and directories into a single archive file for easier storage or transfer. The most common format for tar archives is .tar or .tar.gz for compressed files.

For example, running tar -cvf archive.tar file1 file2 creates an archive file named archive.tar containing file1 and file2. Similarly, tar -xvf archive.tar extracts the files from the archive. The -z option can be added to compress or decompress files using gzip.

Understanding the tar command is crucial for backup, file transfer, and storage operations. It simplifies file management by allowing users to package multiple files into a single file for more efficient handling in UNIX systems.

Reference:

Top 50 Unix MCQ Questions & Answers

Scroll to Top