Command Line Executables and Scripts
We have several kinds of executable commands; those that are built into the BASH shell, executables that are binary program files, and scripts that are interpreted by another program, like BASH or Perl or Python.
While Windows determines what a file is by its extension, Linux examines the first few bytes of the file itself. The file extension is less important than in Windows. Here is a tool to determine what a particular file actually is:
me@ubu:~$ file path/to/filename.ext
This will tell you what kind of file it is. And note that in Linux, a file does not even have to have an extension. For example:
me@ubu:~$ which date
This command, which, tells us the location of an executable file, if it is
in one of a number of special directories. This tells us the
date is a
file in the directory
me@ubu:~$ file /bin/date
This tells us that
/bin/date is an ELF executable file.
me@ubu:~$ file index.html
Tells us that
index.html is an HTML document in the current directory.
Here are a few common file types found on Linux computers:
.doc— a MS Word or other document file.
.html— an HTML document file. May also use
.pl— a Perl script. May have no extension at all.
.py— a Python script. Usually has this extension.
.sh— a BASH (usually) shell script. May have no extension at all.
.txt— a text document file.
Of particular interest are those that are bash (or Bourne shell) scripts. If you place a series of bash command lines in a file, and make that file executable, you have made a shell script. See Shell Scripts.