Archiving and Compressing Files

In this chapter, you will learn how to put a group of files together into a single archive. You will also learn how to compress an archive file using various compression methods.

Creating an archive

Let's create a backup for all the bash scripts in the /home/elliot directory. As the root user, create a directory named backup in /root:

root@ubuntu-linux:~# mkdir /root/backup

To create an archive, we use the tape archive command tar. The general syntax to create an archive is as follows:

tar -cf archive_name files

The -c option is the shorthand notation of --create, which creates the archive. The -f option is the shorthand notation of --file, which specifies the archive name.

Now let's create an archive named ...

Get Learn Linux Quickly now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.