Adding Your File to a PATH Location
First, look up the existing PATH locations using this command:
echo $PATH | sed "s/:/\\n/g"
This will list all the PATH locations in your terminal:
Notice that not all of the folders listed here are accessible to you without sudo, since they do not belong inside your Home directory. The most preferred location is
/home/user/.local/bin
If this folder doesn’t exist, you can create it and add it to the list by following the instructions under the next subheading. Place the file inside that location and make sure that the executable flag is set. The file then becomes a command.
Using Shebang in Linux
Imagine you’re working on a Linux computer and have a recipe with instructions written in different languages. But your computer only understands English! That’s where the shebang comes in. It’s like a tiny label at the beginning of the recipe that tells your computer which “translator” to use for each language. This magic symbol, #!
, followed by the interpreter’s path, is the key to understanding and running all sorts of scripts on your system.