Skip to main content
1 of 3
slm
  • 379.8k
  • 127
  • 793
  • 897

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

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

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
slm
  • 379.8k
  • 127
  • 793
  • 897