How do I determine the type of a file?
Author: Deron Eriksson
Description: This Linux tutorial demonstrates how to determine a file's type.
Tutorial created using: CentOS release 4.6

The "file" command can be used to determine file types. The /usr/share/file/magic file contains "magic numbers" that the file command uses to identify files. We can execute the file command on the contents of the current directory via:

file *

Below, we can see the contents of a directory with a long listing. Following this, we see the contents of the same directory displayed using the file command. Notice that the file command displays the file types for each file.

long listing followed by the file command