How to write a Linux Script (Shebang)?


This page is about the creation of Script in Linux.


  • can be written in many languages
  • does not need an extension
  • must be given the execution permission

Syntax (Shebang)

#!/usr/bin/env perl

where the first line called the shebang define the interpreter to run.

  • the # is the command
  • the exclamation mark (“!”) is affectionately called “bang”
  • /bin/bash the path to the interpreter.
  • env start a new script without environment variable

The interpreter is not limited to bash. Scripts can be written in an other language such as:

  • Python,
  • Perl
  • Ruby, PHP, etc, etc.

The shebang is a kernel required syntax (not mandatory from the shell prespective)


According to the FHS, the script may be located:

  • in the /bin/ or /usr/bin directory for use by all users
  • in the user HOME/bin otherwise

Discover More
Bash Liste Des Attaques Ovh
Bash - Script

This page is Os Shell scripts (with a accent on the Bash shell) A Bash or Shell Script is a text file that: has a shebang has the executable permission. File extensions are meaningless in UNIX,...
Bash Liste Des Attaques Ovh
How to return two variables or more from a bash function?

This article shows you how you can return 2 or more variables from a bash function. Within your shell (remotely mostly within putty) Edit it with your favorite edition technique and add the bash...
Process States
OS - Executable

An operating system has two forms of executable file: direct execution: a native image indirect execution: a script file. The operating system executes the native image (an interpreter) and passes...
Card Puncher Data Processing
Python - Script

in Python are source file that can be run. On Linux, begin your scripts with your interpreter. See or You can find them by executing the whereis commando: sys.argv[0] is the script name...
Card Puncher Data Processing
Shell Data Processing - Sed (Stream editor)

sed stands for stream editor. It is a filter program used for filtering and transforming text It: takes as input a standard stream input modifies it based on an expression, and returns it as...

Share this page:
Follow us:
Task Runner