Loading...
Linux Interview Questions

Compress The Folders And Files

1. What is the use of the tar command in Linux?
A) tar is used to create, extract, and manage archive files.
It bundles multiple files into a single file, often with compression.
2. How do you create a tar archive file?
A) tar -cvf archive.tar /path/to/files

  • c → create
  • v → verbose
  • f → filename

3. What is the difference between tar, gzip, and tar.gz files?

A)

  • .tar → archive only, no compression
  • .gz → compressed single file
  • .tar.gz → archive + compressed

4. How do you extract a tar file in Linux?
A)

tar -xvf archive.tar

5. What does tar -cvf backup.tar /dir mean?
A) Creates (c) a tar archive named backup.tar from /dir.

6. How do you view contents of a tar file without extracting?
A)

tar -tvf archive.tar

7. Difference between tar -xvf and tar -zxvf?
A)

  • -xvf → extract plain .tar
  • -zxvf → extract .tar.gz (uses gzip decompression)

8. How do you compress a directory into .tar.gz?
A)

tar -czvf archive.tar.gz /dir
  • z → gzip compression

9. How do you add files to an existing tar archive?
A)

tar -rvf archive.tar newfile.txt
  • r →d appen

10. How do you extract only a single file from a tar archive?
A)

tar -xvf archive.tar file.txt
Leave a Reply

Your email address will not be published. Required fields are marked *