Skip to main content
2 of 3
added 26 characters in body
slm
  • 379.8k
  • 127
  • 793
  • 897

You can determine the nature of an executable in Unix using the file command and the type command.

type

You use type to determine an executable's location on disk like so:

$ type -a ls
ls is /usr/bin/ls
ls is /bin/ls

So I now know that ls is located here on my system in 2 locations:/usr/bin/ls & /bin/ls. Looking at those executables I can see they're identical:

$ ls -l /usr/bin/ls /bin/ls
-rwxr-xr-x. 1 root root 120232 Jan 20 05:11 /bin/ls
-rwxr-xr-x. 1 root root 120232 Jan 20 05:11 /usr/bin/ls

Using file

If I query them using the file command:

$ file /usr/bin/ls /bin/ls
/usr/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x303f40e1c9349c4ec83e1f99c511640d48e3670f, stripped
/bin/ls:     ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x303f40e1c9349c4ec83e1f99c511640d48e3670f, stripped

So these would be actual physical programs that have been compiled from C/C++. If they were shell scripts they'd typically present like this to file:

$ file somescript.bash 
somescript.bash: POSIX shell script, ASCII text executable

What's ELF?

ELF is a file format, it is the output of a compiler such as gcc, which is used to compile C/C++ programs such as ls.

In computing, the Executable and Linkable Format (ELF, formerly called Extensible Linking Format) is a common standard file format for executables, object code, shared libraries, and core dumps.

It typically will have one of the following extensions in the filename: none, .o, .so, .elf, .prx, .puff, .bin

slm
  • 379.8k
  • 127
  • 793
  • 897