[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

What does it mean that the path (PATH) is valid?

My name is Nakagawa from the infrastructure team.

This article is about how commands work.

I took another look at the mechanism of commands that return various execution results, such as logging into a server and viewing logs, viewing file contents, and checking server status

When I look into the reason why the command can be executed, it says
that the path is present So, what does "because the pass is available" mean?

What is a path?

  1. Path/route to the target directory.
  2. The location of the file that executes the command.

The command is placed as a program at "2." and is recognized and executed as a command.
In other words, the path is passing = the program in the target directory is set as a command .

I'll check it out

Let's check using the ls command as an example.

  1. Find a program that executes the ls command with the which command
  2. Run the ls command to list the contents of the /bin/ directory
  3. Run /bin/ls to list the contents of the /bin/ directory

null
The execution results are the same!

However, it is time-consuming to search for a program located in a directory and then specify it using the full path.
Also, in the case of the ls command, it is easy to see because it is set to display files in different colors for each file type.

You can check the directory to which the path is currently set using the echo command.

null

Commands that you enter on the command line are searched for and executed in specific directories.
The path used to search for the executable file is called the command search path

The command search path is set in the directory in the environment variable PATH in the image above.
In this case, the following directory would be 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 path is passed because it searches for the corresponding file from the command search path and returns the execution result .

At the end

I often search for commands and options that suit my purpose, but
I didn't have a deep understanding of how the execution results were returned.
Memorizing the commands is a learning experience, but once I learned how it works,
I became more interested and understood.

That's all about how the path works.
Thank you for reading!

If you found this article helpful , please give it a like!
2
Loading...
2 votes, average: 1.00 / 12
3,682
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

The person who wrote this article

About the author

Sakina Nakagawa

I joined the company in 2016 as a new graduate. Lately, I've been having fun learning the basics of servers.