You can see current search path with following command:
$ echo $PATH
Sample outputs:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/home/vivekgite/binUsually, all user commands are in /bin and /usr/bin or /usr/local/bin directories. All your programs are installed in these directories. When you type the clear command, you are running /usr/bin/clear. So if it is not in your path try to add directories to your search path as follows (setup Linux or UNIX search path with following bash export command):
$ export PATH=$PATH:/bin:/usr/local/bin
You can also find out of path of any command with which or whereis commands:
$ which ls
/bin/ls
$ which gcc
/usr/bin/gcc
$ which date/bin/date
$ which cal
/usr/bin/cal
$ whereis gcc
/usr/bin/gcc
You can run a program using its full pathname as follows:
$ /bin/ls $ /bin/date
Finally, sometime you may not have permission to run the command.
Example
Let's assume the program you want to execute is called "cal" and you get a "Command not found" message from Unix or Linux. First, type the following command to see if you get a path name:$ whereis cal
Sample outputs:
cal: /usr/bin/cal /usr/share/man/man1/cal.1.gzIf you do, you can invoke it using a full path name (e.g. /usr/bin/cal):
$ /usr/bin/cal
Sample outputs:
September 2012 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Or You can add the path to your PATH variable in your shell start-up file $HOME/.cshrc (csh/tcsh) or $HOME/.bashrc (bash) file, then "source" the file:
$ vi $HOME/.bashrc
Add the path as follows:
PATH=$PATH:/home/vivek/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games export PATH
Save and close the file. Run the following command:
$ source ~/.bashrc
$ echo $PATH
$ cal
Finally, you can use the following command to search for cal command get a hit about its location.
$ find / -name cal -print
http://www.cyberciti.biz/faq/linux-unix-command-not-found-error-and-how-to-get-rid-of-it/
0 komentar:
Posting Komentar