Determine File Types from the Terminal in Linux/Unix

How to determine the file types from the terminal in Linux/Unix?

file command is used to determine the file types from the terminal in Linux/Unix. Most systems have by default file command available. It is a small tool which helps you quickly determine file type in Linux/Unix. It analyzes the file given as an argument and displays details about that file.

SYNOPSIS

file [-bchiklLNnprsvz0] [--apple] [--mime-encoding] [--mime-type] [-e testname] [-F separator] [-f namefile] [-m magicfiles]
file ...
file -C [-m magicfiles]
file [--help]

Example 1

[[email protected] ~]$ file name1
Outputs:
name1: ASCII text 

Example 2

[[email protected] ~]$ file 1.txt
Outputs: 1.txt: empty

Example 3

[[email protected] ~]$ file numbers.tar.gz
Outputs:
numbers.tar.gz: gzip compressed data, from Unix, last modified: Sat Apr 15 01:39:12 2017

That’s all for now. Have questions, post them in the comments.

Add Comment