Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




12.1 Identifying files

When a source file has been compiled to an object file or executable the options used to compile it are no longer obvious. The file command looks at the contents of an object file or executable and determines some of its characteristics, such as whether it was compiled with dynamic or static linking.

For example, here is the result of the file command for a typical executable:

$ file a.out 
a.out: ELF 32-bit LSB executable, Intel 80386, 
  version 1 (SYSV), dynamically linked (uses shared
  libs), not stripped

The output shows that the executable file is dynamically linked, and compiled for the Intel 386 and compatible processors. A full explanation of the output is shown below:

The internal format of the executable file (ELF stands for "Executable and Linking Format", other formats such as COFF "Common Object File Format" are used on some older operating systems (e.g. MS-DOS)).
The word size (for some platforms this would be 64-bit).
Compiled for a platform with least significant byte first word-ordering, such as Intel and AMD x86 processors (the alternative MSB most significant byte first is used by other processors, such as the Motorola 680x0)(36). Some processors such as Itanium and MIPS support both LSB and MSB orderings.
Intel 80386
The processor the executable file was compiled for.
version 1 (SYSV)
This is the version of the internal format of the file.
dynamically linked
The executable uses shared libraries (statically linked indicates programs linked statically, for example using the -static option)
not stripped
The executable contains a symbol table (this can be removed with the strip command).

The file command can also be used on object files, where it gives similar output. The POSIX standard(37) for Unix systems defines the behavior of the file command.

  Published under the terms of the GNU General Public License Design by Interspire