Archiving with tar

The tar command can be used to archive files, originally designed for storing data on Tape archives. It allows you to store multiple files and directories as a single file while retaining all the file attributes, such as owner, permissions, and so on. The file created by the tar command is often referred to as a tarball. In this recipe, we will learn how to create archives using tar.

Getting ready

The tar command comes by default with all Unix-like operating systems. It has a simple syntax and is a portable file format. It supports these arguments: A, c, d, r, t, u, x, f, and v. Each of these options can be used independently for different purposes corresponding to it.

How to do it...

We can use tar to create archives, and perform ...

Get Linux Shell Scripting Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.