J
Jarret W. Buse
Guest
Applications 25 – Uncommon Options of tar Part 1
In the previous article, Applications 23 - Compression with gzip, the basis was that small files can help speed up a system. File compression is making files smaller than they are so they can read/written faster and transferred over the network/Internet quicker.
There is also the ability to write more compressed files on portable media such as USB, CD/DVD, etc. The tar compression method is another typical method used on Linux systems.
The basic syntax for using tar is:
tar <operation> [option] [folder/file]
The non-common options for tar are not often used, but you should have an idea of what else can be done with tar.
The default block size is 20*512 (20). The value can be changed from 20 to another value as needed. To set a block size of 10, the command would be “tar -cb 10 -f blocksize.tar *”.
To backup your files into an archive, use the “--backup” option. The files specified and subfolders will be included in the archive. The “BACKUP-TYPE” can be one of the following:
When using “simple”, the filenames will be what you specify. When using “numbered”, the names will have a number added to them. For example, if the file name is set to “Backup.tar”, the first file will be named “Backup.tar”. The second backup with the same filename will be named “Backup.tar.~1~” and so on. So, to backup the current folder and subfolders and files as a numbered backup, use the command “tar -cf Backup.tar --backup=numbered *”.
When specifying any output filename for the archive, use the “-f” option followed by a space and then the filename which is used as an output filename. For example, to create a file called “main.tar” containing a local file called “test.txt”, use the command “tar -cf main.tar test.txt”.
If the output archive format needs to be changed, you can use the “--format” option. The various “FORMAT” options are:
This is the first part of uncommon tar options. Please continue reading over the next article to complete the uncommon tar options.
In the previous article, Applications 23 - Compression with gzip, the basis was that small files can help speed up a system. File compression is making files smaller than they are so they can read/written faster and transferred over the network/Internet quicker.
There is also the ability to write more compressed files on portable media such as USB, CD/DVD, etc. The tar compression method is another typical method used on Linux systems.
The basic syntax for using tar is:
tar <operation> [option] [folder/file]
The non-common options for tar are not often used, but you should have an idea of what else can be done with tar.
- --atime-preserve
- -b (--blocking-factor N)
The default block size is 20*512 (20). The value can be changed from 20 to another value as needed. To set a block size of 10, the command would be “tar -cb 10 -f blocksize.tar *”.
- --backup BACKUP-TYPE
To backup your files into an archive, use the “--backup” option. The files specified and subfolders will be included in the archive. The “BACKUP-TYPE” can be one of the following:
- numbered – number the backups
- existing – create numbered backups of files that already have them, simple backups of the others
- simple – always make simple backups
When using “simple”, the filenames will be what you specify. When using “numbered”, the names will have a number added to them. For example, if the file name is set to “Backup.tar”, the first file will be named “Backup.tar”. The second backup with the same filename will be named “Backup.tar.~1~” and so on. So, to backup the current folder and subfolders and files as a numbered backup, use the command “tar -cf Backup.tar --backup=numbered *”.
- -C (--directory DIR)
- -l, (--check-links)
- --checkpoint
- -f (--file [HOSTNAME:]FILE)
When specifying any output filename for the archive, use the “-f” option followed by a space and then the filename which is used as an output filename. For example, to create a file called “main.tar” containing a local file called “test.txt”, use the command “tar -cf main.tar test.txt”.
- -F (--info-script FILE, --new-volume-script FILE)
- --force-local
- --format FORMAT
If the output archive format needs to be changed, you can use the “--format” option. The various “FORMAT” options are:
- v7 - Creates an archive that is compatible with Unix V7 tar
- oldgnu - Creates an archive that is compatible with GNU tar version 1.12 or earlier
- gnu - Creates archive in GNU tar 1.13 format. Basically it is the same as `oldgnu' with the only difference in the way it handles long numeric fields
- Ustar - Creates a POSIX.1-1988 compatible archive
- Posix - Creates a POSIX.1-2001 archive
This is the first part of uncommon tar options. Please continue reading over the next article to complete the uncommon tar options.