A colleague put a tool called lab-status in ~/tools — it prints a summary of the machine — and wrote: "Type lab-status and you will see the summary."
Run your colleague's tool
Run the three commands below in order: a run by name, a listing of ~/tools, and a run by full path.
First, predict
The file ~/tools/lab-status exists. What happens when you type lab-status?
Now start the exercise, run the command and compare your prediction with the output.
Why is lab-status not found while ~/tools/lab-status works?
-
A damaged file would not work by full path either. It is the same file — what differs is how the shell looks for it.
-
lslives in /usr/bin and runs from any directory. And in ~/tools the shortlab-statusalso printscommand not found— trycd ~/tools, thenlab-status. -
sudo changes the user a command runs as. The tool already works without sudo when you give its path:
~/tools/lab-status.
The shell looks a short name up in its list of directories, and ~/tools is not on it.