Where are commands stored in Linux File System?

Now the first thing you type is the command name.Now that lets the shell know what program you actually want to run.And once the shell knows what program you want to run, it knows the name of the program you want to run.The shell will then search for that program on something called your Shell’s path, which is just a list of folders that contain these programs. And you can actually see your shells path by typing echo, then a dollar sign, then path.

$ echo $PATH

Okay, so echo space then and then path and you press enter and you see this terrifying output come out. But it’s actually it’s actually very easy to understand once you notice that these are just different folder paths, each separated by a colon by two dots here.So for example, there’s a folder here that’s called Slash (\) use a \local \bin. Then you’ve got another folder here.

\usr\local\bin, then another folder here and another folder here and another folder here and so on and so on.Okay, so what the shell will do is it’ll start at the very left of the path and it will look inside that folder for a command called echo or called cal or called date or whatever you called it. Okay.So it will look in the leftmost folder and it will if it doesn’t find it there, it will move to the next one. So it would start at the very left and it would move to maybe to this folder.

OK, then if it didn’t find it there, it would move to this folder and if it didn’t find it, there would move to this folder and so on and so on and so on until it got right to the end. So to \snap\bin. And if it didn’t find a folder with that name in any of those folders, OK, then the this shell would give you a command, an error like command not found. for an example.. I have type ‘blah’ as a command and the shell will through an error ‘command not found’. The shell will search through all the directories/folders as added in the $PATH variable and could not find any command related to ‘blah’ and is throwing error ‘command not found’

$ blah

This is where the commands of the ubuntu linux system stores and if it could not find the command and is throwing error. There is much more interesting stuff to come out, you can create your own commands, compile them and run on your ubuntu system. This is the power of ubuntu system

Leave a Reply