Lesson 10 Commands¶
||Create an alias for a command (or commands).|
||Remove an alias created with
||Show all variables and functions.|
||Show all environment variables.|
||Assign an environment variable.|
||Execute a script as if it were typed into the shell.|
||Run a program, replacing the shell.|
$PATH Environment Variable¶
Where do commands come from? Commands are files that are located in Linux’s system directories. A special environment variable
$PATH controls where the shell looks for commands when you enter one. Use the
echo command to show you the path:
$ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
The path is a list of directories separated by a colon (
:). The above path has the following parts:
||Extra administrator commands.|
||Commands installed by snap packages.|
$PATHis searched in order!
What happens when you delete your path? Try it.
Most commands are now unavailable! With no
$PATH only shell built-in commands work. You can still use
echo and you can still set a variable. If you find that you have a broken
$PATH you can fix it by ensuring at least the following directories are present:
Run a command to restore your path.
Trapped on the Island¶
On the first midterm the
apropos command was hijacked. The reason was a bogus
$PATH entry. For the final you may have to face a broken path again. Can you restore your path and escape the island?
Try for yourself by logging in to: