What does it mean for a path to be passed?

table of contents
I'm Nakagawa from the infrastructure team
This article is about the mechanism of commands.
such as logging into a server and viewing logs, viewing file contents, and checking the server status
We re-examined the mechanism of commands that return various execution results,
When you look up why a command can be executed,because the path is set correctlyyou'll find that it's
But what exactly does "because the path is set correctly" mean?
What is a path?
- The path to the destination directory
- The location of the file that executes the command
The command is placed as a program in section "2." and is recognized and executed as a command.
In other words, ifthe program in the target directory is set as a commandit means that
Let's check it out
Let's take the ls command as an example
- Use the which command to find the program that executes the ls command
- Run the ls command to list the contents of the /bin/ directory
- Run /bin/ls to list the contents of the /bin/ directory

The execution results are the same!
However, it's time-consuming to find the program located in a directory and specify its full path.
Also, the `ls` command is easier to read because it's set to display files in different colors depending on their type.
You can check the directory currently set in the path using the echo command

Commands entered and executed on the command line are searched for and executed within a specific directory.
The path through which the system searches for the executable filethe command search pathis called
The command search path is defined within the directories listed in the PATH environment variable shown in the image above.
In this case, the following directories are relevant.
- /usr/local/sbin
- /usr/local/bin
- /sbin
- /bin
- /usr/sbin
- /usr/bin
- /opt/aws/bin
- /root/bin
When you enter a command from the command line, the system searches for the corresponding file in the command search path and
returns the result of its execution, whicha "path being set"in the system's PATH.
Conclusion
I often search for commands and options that suit my purpose, but
I didn't deeply understand the mechanism behind why those commands returned a certain result.
Learning commands is a form of learning, but understanding the underlying mechanisms
led to greater interest and understanding.
That concludes the explanation of how the password works.
Thank you for reading!
2
