Tuesday, May 14, 2024
46
rated 0 times [  46] [ 0]  / answers: 1 / hits: 316508  / 2 Years ago, mon, june 13, 2022, 3:36:19

I would like to understand what full path name really means. I have a file in my home directory called my_script. I assumed the full path name is ./my_script, meaning that it is in the root folder, but I am not sure. Can someone please enlighten me on that?


More From » command-line

 Answers
7

No, your assumption is wrong. The full path name for my_script file from your home directory is: /home/your_user_name/my_script. When you type ./my_script in terminal you actually try to execute the script (if is executable) and it will be executed only if your current working directory is /home/your_user_name/. To execute the script you can use also the full file path which is, as I said /home/your_user_name/my_script.



It is believed that a UNIX path name looks and feels like Internet addresses, thus result into compatibility. The full path name of the current working directory can be found in terminal by using the following command:



pwd


To find out the full path for your user home directory, you can use:



echo ~
echo $HOME
echo /home/$USER


The above three commands are equivalent.



To find out the full path name for a file you can use readlink command. For example, in your case:



cd ~
readlink -f my_script

[#29766] Tuesday, June 14, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
singerrupt

Total Points: 435
Total Questions: 111
Total Answers: 109

Location: Angola
Member since Tue, May 5, 2020
4 Years ago
;