The tape archive (tar) command was originally designed to back up filesystems to tape devices. Although many people now use the tar command to back up to non-tape devices, you should be aware of how to use tape devices as well. For the following examples, we assume that you do not have a tape drive in your system. The examples provided for the tar command place the tar ball (the result of the tar command) in a regular file; however, if you have a tape drive, you can just replace the filename with your tape device file.
To create a backup (or tar ball) with the tar utility, use the -c (create) option in conjunction with the -f (filename) option:
#tar -cf <filename_to_be_created> <filename_to_be backed_up>
The leading / characters are removed from the filenames, so instead of absolute pathnames being backed up, the pathnames are relative. This makes it easier to specify where the files are restored. Having the leading / would result in files always being stored in the exact same location. To see the contents of a tar ball, use the -t (table of contents) option in conjunction with the -f option, as shown below.
#tar -tf <filename>
You often want to see detailed information when listing the contents of the tar ball. Include the -v (verbose) option to see additional information, as shown in this command.
#tar -tvf <filename>
To extract all the contents of the tar ball into the current directory, use the -x (extract) option in conjunction with the -f option, as shown in the following command
#tar -xf <filename>
If you only wants to extract only a specific type of files, you can specify it at the end of the command. In the following example, I have specified that I only needs to extract all the “.doc” files from the tar ball.
#tar xvf <filename> –-wildcards ‘*.doc’
Latest posts by Ruwantha Nissanka (see all)
- 4 ways to hide your identity using linux - January 18, 2021
- How To Install Kali Linux in Virtualbox - December 31, 2020
- Kali Linux : The OS That Hackers Use - December 31, 2020
- How to monitor user activity in Linux with Acct - December 30, 2020
- Debsecan : You will not miss another security update - December 28, 2020