Linux Labs

First steps / Stage 14 of 15

Help and the shell

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 8 · on a machine · 4 min

A new tool

What you will learn

  • Explain where Bash looks for a command and check it with type and PATH.
  • Find help on a command — --help, man or help — and the meaning of an option in it.
  • Predict what quotes and patterns do, and keep a PATH setting in ~/.bashrc.

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."

Exercise · look

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.

Sign in and start The machine is available after signing in
Check yourself 1 question

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.

  • ls lives in /usr/bin and runs from any directory. And in ~/tools the short lab-status also prints command not found — try cd ~/tools, then lab-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.

Ubuntu 24.04
Loading…