When I type a name of some executable in command line and it starts, how can I detect path where that executable is located?
You can find out which executable will be started by using the command
If you want to determine the path programmatically you're on the wrong stack exchange.
The problem of the simple solution
The more reliable solution
On Linux if you want to be completely sure about the path of the executable file of a running process then you can get it from its PID (Process ID; in the example below put the number instead of
How to get the number? PID of the last process run in shell in background is
You can get PIDs of other processes for example from a process list using
Scripts are a special case
Unfortunately the current working directory can change since the program start. Some interpreters like bash can keep the script file open on descriptor 255:
Everything can change
Any process can call