FreeKB - Linux Commands file command
Linux Commands - file command

The file command can be used to display a file type. Let's create an empty file.

touch foo.txt


The file command will show that foo.txt is an empty file.

~]# file foo.txt
foo.txt: empty


Let's append some text to foo.txt.

echo "Hello World" > foo.txt


Now the file command should return the following.

~]# file foo.txt
foo.txt: ASCII text


Let's say you have a certificate file, foo.cer, that contains something like this.



Something like this should be returned.

foo.cer: PEM certificate


Let's say you have a binary file foo.file. Attempting to view the content of foo.file will probably return mumbo jumbo, something like this.

~]# cat foo.file


The file command should identify foo.file as a data file.

~]# file foo.file
foo.file: data


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 2d88f in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |