tar Command
Purpose
Creates, extracts, or lists file archives.
Syntax
tar [ -c ] [ -f file ] [ -h ] [ -t ] [ -v ] [ -x ] [ -z ] [ file ]...
Description
The tar command creates, extracts, or lists file archives. In PowerVC virtual appliance, only basic archive creation, extraction, and listing are allowed for security. Advanced features, absolute paths, or device and file system modifications are not allowed.
Flags
| Items | Description |
|---|---|
| -c | Creates a new archive from specified files or directories. |
| -f file | Specify the archive file or directory name. This flag is required with the -c, -t, or -x flags. |
| -h or --help | Displays help about the tar command. |
| -t | Lists the files in an archive. |
| -v | Enables verbose output. This option displays the files that are processed during create or extract operation. |
| -x | Extracts files from an existing archive. |
| -z | Compresses or decompresses an archive by using the gzip algorithm. |
Examples
- To create backup.tar.gz compressed archive of the
/home/pvcroot/docs directory, enter the following
command:
tar -czvf backup.tar.gz /home/pvcroot/docs - To list the contents of the archive.tar archive, enter the following
command:
tar -tf archive.tar - To list the contents of the archive.tar.gz compressed archive without
extracting it, enter the following command:
tar -tzf archive.tar.gz - To extract the contents of the data.tar archive in verbose mode, enter the
following command:
tar -xvf data.tar - To extract the contents of the data.tar.gz compressed archive in verbose
mode, enter the following command:
tar -xzvf data.tar.gz - To extract the content of the path/to/file.txt file from the
archive.tar archive, enter the following
command:
tar -xf archive.tar path/to/file.txt - To create site-backup.tar.gz archive of the current directory, enter the
following command:
tar -czf site-backup.tar.gz .