Linux Know-How provides a collection of introductory texts on often needed Linux skills. |
Home Newbie Guide Basic Operations Basics How to run a program | ||
See also: Executing commands, Background Execution | ||
Search the VIAS Library | Index | ||
How to run a programTyping the name of the executable on the command line doesn't help? There are three possibilities. The first possibility: I did not type the name of the executable correctly. Check the case--Linux is case sensitive! For example, typing "Pico" or "PICO" will not start the pico editor. The second possibility: maybe the program is not on my PATH? Under Linux (or any UNIX), an executable must be on your PATH to run it, and the current directory is not on my PATH. Type the full path to the executable in front of the executable name, or do: cd the_program_directory ./program_name I must put the dot and slash in front of the program name or the program will not execute. (This is a security feature not to put one's current directory on the path. It makes "trojan horses" more difficult. A "trojan horse" is a malicious program that pretends to be something different than it really is.) The dot means "the current directory", and the slash "/" is a separator between the directory name and the filename (exactly as "\" in DOS). I may check my path using: echo $PATH To learn how to change your PATH, or add your current directory to it, see the next answer. If my executable is lost somewhere in the directory tree, I may want to find it using (for example): find / -name "netscape" to find a file named "netscape", starting the search from the root directory "/". You may be able to achieve the same result faster using: locate netscape
Please note that the PATH is normally different for root than for the regular users (root's PATH includes /sbin and /usr/sbin whereas users' don't). Therefore users cannot execute commands located in the "sbin" directories unless they specify the full path to the command. Also, if you become a superuser by executing the su command, you inherit the user's PATH, and to execute the command located in sbin, you need to specify the full path. Conversely, if I need to learn where an executable which is on my PATH is located on your system (i.e., the executable runs by typing its name anywhere in the system, but I would like to know where it is located), I may use something like this: which netscape which will show the full PATH to the executable program called "netscape" (if one exists). The third possibility: maybe the file is not executable. If it should be, change the permissions to make it executable. E.g. (as root or the user who owns the file): chmod a+x my_file will make the file "my_file" executable for all users. Check if it worked using: ls -l my_file Read here(lnag_basics.html#file_permissions) if you don't understand the output of this command or the whole "third possibility". Please note that under Linux (or UNIX), the file extension (for example .exe or .com or .bat) does not make the file executable. The file needs an "executable file access mode" which is not unlike a "file attribute" under DOS.
|
||
Home Newbie Guide Basic Operations Basics How to run a program |