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 O’Reilly online learning.

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