A answer with a different perspective, may help in better understanding of *nix environment.
All the commands/utilities you know of in *nux are present in some or the other directory which you can find using the
$ which ls
$ which sort
So, how these get located which you try to execute the command?
The answer is the
PATH variable. If you do a
echo $PATH, you'll see a colon
: separated list of directories.
Sample output for $PATH
so, if you place your own executable at one of those locations, you'll be able to run it just as other system commands. Or, you can add your own defined directory to this list, by appending it to the
PATH variable, and exporting it, so that it is available for the complete shell, like
You may want to add this particular line to
.bashrc file, so that you don't need to execute the above command everytime you start the shell.
Just for fun
Ty changing the
PATH variable, make it empty, you'll end up with useless shell, until you reset the
PATH properly again.
$ export PATH=""
bash: ls: No such file or directory
$ which pwd
bash: which: No such file or directory