Instructions for using zforce command on Linux

The gzip command is a popular tool used to compress / decompress files in Linux. TipsMake.com presents the basics of this tool in the article: Some basic Terminal commands in Linux Mint 11.

The gzip command is a popular tool used to compress / decompress files in Linux.TipsMake.com presents the basics of this tool in the article: Some basic Terminal commands in Linux Mint 11. This utility creates .gz files. But sometimes (such as during file transfers) this .gz file extension may be removed. But not too worried! There is a tool that forces the .gz extension back to these compressed files.

The tool mentioned is zforce and in this tutorial, we will discuss how to use this command line utility. But before starting, please note that all the examples here are tested on Ubuntu 18.04 LTS.

Linux zforce command

As mentioned at the beginning, the zforce command allows the user to force the extension '.gz' back on all gzip files. The following is its syntax:

 zforce [ name . ] 

And here's how this tool's homepage explains it: "Zforce forces the .gz extension back on all gzip files so that gzip doesn't compress them twice."

This can be useful for files whose names are truncated when transferring files. On systems, the file name is limited to 14 characters, so the original name is truncated to make room for the .gz suffix .

For example, 12345678901234 was renamed 12345678901.gz. But a short file name, such as foo.tgz will be preserved.

For example, we have a .gz file named 'files'. As can be seen, the .gz extension is missing in the file name. So what to do is simply use the following command:

 zforce files 

And this is the ouput that this command creates:

 files -- replaced with files.gz 

As you can see, the command indicates that 'files' have been replaced with 'files.gz'. And when you check the .gz file in the current directory, you will see a file named files.gz.

Now, if there is a folder filled with .gz files whose names have been truncated, there is no need to enter each file name. Do the same as the example below:

Picture 1 of Instructions for using zforce command on Linux

You can see that all 3 files in the example have the .gz extension. Rest assured that if any file already contains the .gz extension in the name, then this operation will remain the same.

If you use a lot of gzip and encounter the .gz extension being truncated from the file name, you now know how to handle it.

Good luck!

See more:

  1. 14 interesting Linux commands in Terminal
  2. Basic Linux commands everyone needs to know
  3. 7 commands to manipulate the most basic files and folders everyone must know
Update 26 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile