Linux Commands / IT Support Guides
Identify an unknown Linux file with file
Use file to check what a Linux file appears to contain before choosing how to open it.
Environment and inputs: Linux · Bash-compatible shell; package and service names vary by distribution
Understand the problem
Start with the actual file you received. Keep the original file so you can compare it with a fresh export if needed.
Run the command
Replace /tmp/support-sample with the path to the file you want to inspect. Put the path in quotes if it contains spaces. The -- marks the end of options.
file -- /tmp/support-sample
Read the output
An output such as support-sample: ASCII text means file detected plain text. If it reports gzip compressed data, use a tool that can read gzip. An output of data means it did not identify a more specific type.
Choose the next step
Compare the reported type with the format you expected. If the command cannot open the file, check the path and your read permissions.
Before making changes
The reported type helps you choose a viewer. Treat an unexpected attachment as untrusted and avoid executing it.