cli-tarHow do I use gzip and tar in Linux?
Gzip and tar are two command line tools used to compress and archive files in Linux.
To use gzip, you can run the following command:
gzip <filename>
This will compress the file and create a new file with a .gz extension.
To unzip the file, you can run the following command:
gunzip <filename.gz>
This will decompress the file and create a new file with the original filename.
To use tar, you can run the following command to create an archive:
tar -cvf <archive_name.tar> <filename1> <filename2> ...
This will create a tar archive containing the specified files.
To extract the files from the archive, you can run the following command:
tar -xvf <archive_name.tar>
This will extract the files from the archive and create new files with the original filenames.
Code explanation
gzip <filename>: Compress a file and create a new file with a .gz extensiongunzip <filename.gz>: Decompress a file and create a new file with the original filenametar -cvf <archive_name.tar> <filename1> <filename2> ...: Create a tar archive containing the specified filestar -xvf <archive_name.tar>: Extract the files from the archive and create new files with the original filenames
Helpful links
More of Cli Tar
- How do I use the command line to tar and zip a file?
- How do I use the command line to create a tar file?
- How do I compress a file using gzip and tar.xz?
- How do I use tar gzip with a password?
- How do I use the tar command line in Windows 10?
- How can I use the CLI to yield a tar file?
- How do I compare Unix tar and zip files?
- How do I create a Unix tar archive with a password?
- How can I fix an unexpected end of file error when compressing a file with tar and gzip?
See more codes...