Identifying and Working with File Types

If you're new to Linux, you may see files with extensions you don't recognize. A file's extension is the last part of a file's name, after the final dot (in the file sneakers.txt, "txt" is that file's extension).

Here's a brief listing of extensions and their meanings:

Compressed/Archived Files

For information on creating zip and tar files, see the section called File Compression and Archiving — Gzip, Zip, and Tar

File Formats

For information on viewing and creating PDF files, see the section called Viewing PDFs

System Files

Programming and Scripting Files

But file extensions are not always used, or used consistently. So what happens when a file doesn't have an extension, or the file doesn't seem to be what the extension says it's supposed to be?

That's when the file command can be helpful.

In the section called Using Redirection in Chapter 10, you created a file called saturday, without an extension. Using the file command, you can tell what the file is by typing:

file saturday

and you'll see ASCII text, or something similar, telling you it's a text file. Any file that's designated a text file should be readable using cat, more, or less.

TipRead the Man Page
 

To learn more about file, read the man page by typing man file.

For more information on helpful commands for reading files, see Chapter 10.