How to Check Path in Unix
Ever type in a simple command and get an error?
- $ woot
- bash: woot: command not found
Then the command is not in your PATH, or simply doesn't exist on your system.
EditSteps
-
1Use the right command. When you type in a command, the shell searches itself for built-in commands, then it searches the directories listed in your PATH variable.
- To check PATH, type "echo $PATH".
- $ echo $PATH
- /sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin
- $ echo $PATH
Ad - To check PATH, type "echo $PATH".
-
2Include the dollar sign, or the shell will just print "PATH" to your screen.) This shows the directories checked, separated by colons.
-
3To find the location of a command, use the "which" or "type" commands:
- $ which ifconfig
- /sbin/ifconfig
- $ type ifconfig
- ifconfig is /sbin/ifconfig
Ad
Questions and Answers
EditVideo
EditTips
- By default, the shell does not search your current directory in Unix-type OSes (BSD, Linux, etc.) unless it's already in your path. This can be fixed by adding a period (dot), which is the Unix short-cut for the current directory. This can be changed by going to your home directory. This should contain '.profile'. Use an editor, such as vi, to open, change, and save.
EditWarnings
- As always, be careful what you do while logged in as root.
Article Info
Categories: Operating Systems
Thanks to all authors for creating a page that has been read 22,335 times.
About this wikiHow