Determining the type of file
Follow @ggarronAs some of you may know Linux does not use the extension (suffix) of the file to determine the type of it, what it does is to look at the file content.
So you can name your files as you want and Linux will still be able to recognize it.
If you ever need to know the type of a given file, with no suffix, or with the incorrect suffix, use the Linux command file
You should have this command already installed on your Linux, but if not, installing it is really simple.
Debian / Ubuntu
sudo aptitude install file
once installed, you can start guessing the file types.
Example:
$ ls *.txt -l -rw-r--r-- 1 ggarron ggarron 25511 2007-10-25 17:37 dhclient.txt -rw-r--r-- 1 ggarron ggarron 77757 2007-11-09 10:48 gammu.txt -rw-r--r-- 1 ggarron ggarron 1298 2007-11-20 16:46 latex.txt -rw-r--r-- 1 ggarron ggarron 73823 2007-08-31 11:29 man-iptables.txt -rw-r--r-- 1 ggarron ggarron 142738 2008-01-02 17:28 nmap.txt -rw-r--r-- 1 ggarron ggarron 9834 2007-12-13 18:12 picture.txt -rw-r--r-- 1 ggarron ggarron 1717 2007-07-03 12:55 readme.txt -rw-r--r-- 1 ggarron ggarron 2468 2007-12-27 16:56 robots.txt -rw-r--r-- 1 ggarron ggarron 105 2007-08-05 01:34 upgrade_readme.txt
Now apply the file command
$ file *.txt dhclient.txt: Non-ISO extended-ASCII English text gammu.txt: UTF-8 Unicode Pascal program text latex.txt: LaTeX 2e document text man-iptables.txt: Non-ISO extended-ASCII English text nmap.txt: UTF-8 Unicode English text picture.txt: PNG image data, 550 x 53, 8-bit/color RGB, non-interlaced readme.txt: ASCII English text, with very long lines, with CRLF line terminators robots.txt: ASCII English text upgrade_readme.txt: ASCII English text, with no line terminators
As you can see picture.txt is a PNG file and not a TXT file, you can also see that there are different types of TXT files, it recognize between Pacal program and LaTeX document, when both are plain text.