I have seen that Adding some path to the path variable in Linux can be a difficult task for the deployer. For example, After installing Python to the Linux Server you are not able to run the Program and got errors like ImportError or NoModuleFound error. These problems are due to not adding the Path of the project and variables in the System Path Variable. Therefore I have come with this post. In this entire tutorial, you will learn how to add Path to Pathe Variable in Linux?
How to Know all the Variable Paths?
In Linux, you can know all the Paths in the Path variable. You can use the command echo $PATH for knowing all the Paths in PATH variable and env to know all the environment variables. Like this. Please note that I am using the Ubuntu Operating system for this entire tutorial.
Here you can see all the paths of the for the specific Tasks. But here the main name of the path you should note is PATH. This is the Path for the system variable.
How to add a Path to the PATH variable?
Let’s you want to add a folder path to the Path Variable lets a Projects folder. First, go to that folder and type pwd to find the path of it. After that copy, it and type the following command.
It will successfully add the path to the path variable. You can check it by typing echo $PATH. But it will not be added permanently to the Path variable. When you shut down the system and start again then you will not see the Path. You have to add it to the Path variable permanently. For this, you have to edit the .profile file and add the following line at the end.
After adding log out or restart the instance and type the echo $PATH command to verify that the path has been added or not.
Following all these above methods you will successfully add the Path to the path variable. I hope this article has clarified your question on How to Add Path to Path Variable in Linux? If you have any other query then you can contact us.