September 01, 2017

Method of using relative path without current path in Linux


The "cmd1_TT" is the program that executes inputted one argument(argv[1]) and deletes environment variable PATH. "echo123" is soft-link of original echo.

The "echo123" works when current path is registered("export") or current path(./) is stated.




But see this.

The "fg_tt" is the text file in the /tmp But it works without current path. Because The "fg_tt" is not an executable file. Also the shell's autocomplete(Tab) is not related to PATH. Only executable files are affected by the PATH environment variable.

Check environment
O      S Ubuntu 16.04.1 LTS CPU Intel i5 2.80 GHz
SHELL GNU bash 4.3.46(1) GPU -
RAM 8 GB