More About Commands
In A Few Commands In Bash Shell , we have learnt about running a few commands. But where does Bash shell find commands? To answer this question, we are going to learn a few concepts about Bash shell.
bin Directory
Most of the time, a directory which contains commands is named bin, because commands are binary files. There are several bin directories across the system. Examples of bin directories are: /usr/bin, /usr/local/bin, /home/username/bin, /sbin.
Here, we replace username with the name of a user and a user can store its personal commands here. /sbin stores commands for the root user. A normal user might need the root user authority to run it.
PATH Variable
There is a variable named PATH defined in a hidden file .bashrc in the home directory of a user. The names of directories are separated with :(colon) and assigned to this variable. We can see the value of PATH variable using command: echo $PATH.
When we run a command, the first directory is being searched for the command and if it's not found then the second directory is being search. This process follows until command is found or there is no directory left in the list. If we include .(dot) in the start then our current directory is being searched first.
Manual Pages
We can find information about a command using man command e.g. man ls. We can find what a command do, options, examples and so on. Please press Q key to exit from man command.
We can also use man man to know about man itself. There are several sections related to the different parts of a Linux system.
Last but not least important, we use a terminal to interact with a Linux system. A terminal does not contains any file or directory or a process. All are the parts of an underlying Linux system. We will talk about a process in the future.
Happy reading and thank you. Meet you soon.
Comments
Post a Comment