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.

-----BEGIN CERTIFICATE-----
MIIGhTCCBW2gAwIBAgITFwAS0Zj4+uylATknJgAAABLRmDANBgkqhkiG9w0BAQsF
ADBMMRQwEgYKCZImiZPyLGQBGRYEY29ycDEYMBYGCgmSJomT8ixkARkWCHRocml2
ysR4VfQLr+A3zbM59CQjewP40y7oFgrpNuj8Hp1AXud3nsakEYFaGcc=
-----END CERTIFICATE-----

 

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
h++-://c_+.+h_i+e++.c-+/ce_+e+_-+

 

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.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |