Use file command to determine file type

The file command is a useful tool in solaris that can help you to determine what file type a particular file is. The usage is simple, just “file “. Below we have two files, but we don’t know what type of file they are:

root@solaris:/pool/share# ls -lah
total 20K
drwxr-xr-x 2 root root   4 2011-10-03 04:08 .
drwxr-xr-x 3 root root   3 2011-07-28 04:27 ..
-rw-r--r-- 1 root root   9 2011-10-03 04:02 testfile1
-r-xr-xr-x 1 root root 13K 2011-10-03 04:02 testfile2

Now we find out using the file command

root@solaris:/pool/share# file testfile1
testfile1:      ascii text
root@solaris:/pool/share# file testfile2
testfile2:      ELF 32-bit LSB executable 80386 Version 1 [FPU], dynamically linked, not stripped, no debugging information available

We notice that the first testfile is ascii text and the other a 32 bit binary. In solaris it is useful to use this command, and can often be more convenient than using a cat of the file.

Be the first to comment

Leave a Reply