Create a tar archive of backup_dir named backup.tar. (Verify using ls and tar -tf)

Step 1: Create a Tar Archive of backup_dir

bashCopyEdittar -cvf backup.tar backup_dir
  • c → Create a new archive

  • v → Verbose mode (shows files being archived)

  • f → Specifies the filename (backup.tar)


Step 2: Verify the Archive Using ls

bashCopyEditls -l
  • This lists all files in the current directory.

  • Expected output should include backup.tar.


Step 3: Verify the Contents of the Archive

bashCopyEdittar -tf backup.tar
  • t → List the contents of the archive

  • f → Specifies the archive filename


Step 4: Extract the Archive (Optional)

If you want to extract the archive, use:

bashCopyEdittar -xvf backup.tar
  • x → Extract files

  • v → Verbose mode

  • f → Specifies the archive filename


Now, you have all the necessary syntax for creating, verifying, and even extracting the tar archive.

0
Subscribe to my newsletter

Read articles from Ravi Vishwakarma directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ravi Vishwakarma
Ravi Vishwakarma