Tuesday, October 03, 2006

File Command Guess Linux File Type

By convention, Windows system using 3 alphanumeric characters to serve as file extension. File extension telling Windows OS how to deal with the file, what program to manipulate the file, and to Windows users easily recognize a common file type.

There is no such strong concept of file extension in Linux as well as UNIX world. Linux folks, however, do practice to use file extension for some file formats such as compression or archive file format. Windows users might easily get cheated by file extension trap in Linux.

For example, it is perfectly fine to rename a PKZIP compatible zip file called backup.zip to backup.tgz or whatever filename. Later, if the user simply executing tar -zxvf backup.tgz might either get errors or see nothing and thought the file is corrupted.

Purposely rename a PKZIP compatible zip file as it is a gzip compressed tarball archive file. Use the file command to test the file if it is a valid Linux file format.

Wait! Before deleting the file which thought to be corrupted, use the file command to inspect the file type first.

Type file backup.tgz at the command prompt, it shows that backup.tgz is actually a PKZIP compatible zip file. So, user should executing unzip backup.tgz to extract the zip file or rename backup.tgz to backup.zip before executing the unzip command.

Related information:

  • Search more related info with Google Search engine built-in

This article has 1 comments.

Thebodytalk said...

Well...I am a fan of "Reader's Digest" for more that 5 years. When I see your blog's title on the blogger's update page, I can't help clicking on it. Anyway, good information for computer users, though.