Linux tar
tar is a Linux command-line utility used for creating and manipulating tar archives. Tar (which stands for Tape Archive) is a file format used to store multiple files in a single file. It's commonly used for creating backups or for distributing multiple files as a single package. Here's how to use tar in Linux:
- Create a tar archive: To create a tar archive, use the "tar" command followed by the options you want to use and the name of the archive you want to create. For example, to create a tar archive called "archive.tar" containing all files in the current directory, use the following command:
tar -cvf archive.tar *
This will create a tar archive called "archive.tar" containing all files in the current directory.
- Extract files from a tar archive: To extract files from a tar archive, use the "tar" command followed by the options you want to use and the name of the archive you want to extract from. For example, to extract all files from the "archive.tar" archive created in the previous step, use the following command:
tar -xvf archive.tar
This will extract all files from the "archive.tar" archive to the current directory.
- Compress a tar archive: To compress a tar archive, you can use the gzip command in combination with the tar command. For example, to create a compressed tar archive called "archive.tar.gz" containing all files in the current directory, use the following command:
tar -czvf archive.tar.gz *
This will create a compressed tar archive called "archive.tar.gz" containing all files in the current directory.
- Extract files from a compressed tar archive: To extract files from a compressed tar archive, you can use the gunzip command in combination with the tar command. For example, to extract all files from the "archive.tar.gz" archive created in the previous step, use the following command:
tar -xzvf archive.tar.gz
This will extract all files from the "archive.tar.gz" archive to the current directory.
Tar is a powerful tool for creating and manipulating tar archives in Linux. It allows you to easily create, extract, and compress archives, making it an essential tool for tasks like backups and file distribution.
Comments
Post a Comment