COMPRESSING FILES IN LINUX
Files can be compressed in Linux using the "tar" command. The tar command stands for tape archive, and is used to create archives and extract files from archives. The tar command is one of the most important commands in Linux that provides compressing files into archives.
Syntax:
Options:
1. -c: Creates Archive
2. -x: Extracts the archive
3. -f: Creates Archive with given Filename
4. -t: Displays or Lists the content contained by the archived file
5. -u: Archives and adds to an existing Archive file
6. -v: Displays Verbose Information
7. -A: Concatenates the archived files
8. -z: Zips files and tells tar command to create tar file using gzip
9. -W: Filter an archive file
10. -r: Update of Add file or directory to an already existing .tar file
What is an Archive File?
An Archive file is a file that is composed of one or more files along with metadata. Archive files are used to collect multiple data files together into a single file for easier portability and storage, or simply to compress files to use less storage space.
Examples:
1. Creating an uncompressed tar Archive using option -cvf : This command creates a tar file called file.tar which is the Archive of all .c files in the current directory.
Output:
2. Extracting files from Archive using option -xvf : This command extracts files from Archives.
Output:
3. gzip compression on the tar Archive, using option -z : This command creates a tar file called file.tar.gz which is the Archive of .c files.
4. Extracting a gzip tar Archive *.tar.gz using option -xvzf : This command extracts files from tar archived file.tar.gz files.
5. Creating compressed tar archive file in Linux using option -j : This command compresses and creates archive file less than the size of the gzip. Both compress and decompress takes more time then gzip.
Output:
6. Untar multiple .tar, .tar.gz, .tar.tbz file in Linux : This command will extract or untar multiple files from the tar, tar.gz and tar.bz2 archive file. For example the above command will extract %u201CfileA%u201D %u201CfileB%u201D from the archive files.
7. Check size of existing tar, tar.gz, tar.tbz file in Linux : This command will display the size of archive file in Kilobytes(KB).
8. Viewing the Archive using option -tvf
Output:
Comments
Post a Comment