Thursday, 30 November 2023   |

How to Use the Gzip Command in Linux


The `gzip` command is a popular tool used in Linux for file compression. It allows you to compress and decompress files using the gzip compression algorithm. Here's how you can use the `gzip` command:

1. **Compression**: To compress a file, use the following syntax:
   ```
   gzip [options] [filename]
   ```
   For example, to compress a file named "example.txt," you would run:
   ```
   gzip example.txt
   ```
   This command will create a compressed file named "example.txt.gz" and delete the original file.

   **Options**:
   - `-c`: Write the compressed output to standard output without deleting the original file.
   - `-k`: Keep the original file after compression (does not delete the original file).

2. **Decompression**: To decompress a file, use the following syntax:
   ```
   gzip -d [filename.gz]
   ```
   For example, to decompress a file named "example.txt.gz," you would run:
   ```
   gzip -d example.txt.gz
   ```
   This command will decompress the file and restore it to its original state. The compressed file "example.txt.gz" will be deleted.

   **Options**:
   - `-c`: Write the decompressed output to standard output without deleting the original file.
   - `-k`: Keep the compressed file after decompression (does not delete the original file).

Note: The `gzip` command can also compress or decompress multiple files by providing multiple filenames as arguments.

Additional options and flags are available for advanced usage. You can refer to the `gzip` command's manual page for more information by running `man gzip` in the terminal.


Date: 20 June 2023    Comments: 0


Comments - 0

There are no comments yet

Leave A Comment