File (command)

From LQWiki
Jump to navigation Jump to search

file is a command used to provide an overview of one or more files and identify the contents.

Example

Here is an example from a console session:

tweedleburg:~ # file spider4.tar
spider4.tar: POSIX tar archive (GNU)
tweedleburg:~ # file amadeus.mpg
amadeus.mpg: MPEG sequence, v2, program multiplex
tweedleburg:~ # file tmp
tmp: directory
tweedleburg:~ # file /usr/lib/libQtCore.so.4
/usr/lib/libQtCore.so.4: symbolic link to `libQtCore.so.4.5.1'

Also, while it is customary to name shell scripts with a '.sh' extension, it's more economical not to and distro scripts are rarely named that way. 'file' provides a quick overview of what's a script and what's a binary when 'ls' merely displays a bunch of executables.