What is the difference between adding to PATH on the CLI vs in bashrc [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
This question already has an answer here:
How to correctly add a path to PATH?
11 answers
In an online video lecture the teacher has explained how to add to PATH
both on the command line and via .bashrc
, and has indicated that the proper way of doing this is through .bashrc
but has not adequately explained why.
My question is what is the difference between executing the following from the command line:
$ export PATH=/home/username/bin:$PATH
Or simply adding the line: export PATH=/home/username/bin:$PATH
to my ~/.bashrc
.
linux bash path
marked as duplicate by Jesse_b, Archemar, Jeff Schaller, Vlastimil, meuh Feb 26 at 8:14
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
0
down vote
favorite
This question already has an answer here:
How to correctly add a path to PATH?
11 answers
In an online video lecture the teacher has explained how to add to PATH
both on the command line and via .bashrc
, and has indicated that the proper way of doing this is through .bashrc
but has not adequately explained why.
My question is what is the difference between executing the following from the command line:
$ export PATH=/home/username/bin:$PATH
Or simply adding the line: export PATH=/home/username/bin:$PATH
to my ~/.bashrc
.
linux bash path
marked as duplicate by Jesse_b, Archemar, Jeff Schaller, Vlastimil, meuh Feb 26 at 8:14
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
@Jesse_b Thanks for the edit.It makes more sense of what I wanted to ask.
â user7841468
Feb 25 at 17:54
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
How to correctly add a path to PATH?
11 answers
In an online video lecture the teacher has explained how to add to PATH
both on the command line and via .bashrc
, and has indicated that the proper way of doing this is through .bashrc
but has not adequately explained why.
My question is what is the difference between executing the following from the command line:
$ export PATH=/home/username/bin:$PATH
Or simply adding the line: export PATH=/home/username/bin:$PATH
to my ~/.bashrc
.
linux bash path
This question already has an answer here:
How to correctly add a path to PATH?
11 answers
In an online video lecture the teacher has explained how to add to PATH
both on the command line and via .bashrc
, and has indicated that the proper way of doing this is through .bashrc
but has not adequately explained why.
My question is what is the difference between executing the following from the command line:
$ export PATH=/home/username/bin:$PATH
Or simply adding the line: export PATH=/home/username/bin:$PATH
to my ~/.bashrc
.
This question already has an answer here:
How to correctly add a path to PATH?
11 answers
linux bash path
edited Feb 25 at 17:51
Jesse_b
10.4k22658
10.4k22658
asked Feb 25 at 17:29
user7841468
335
335
marked as duplicate by Jesse_b, Archemar, Jeff Schaller, Vlastimil, meuh Feb 26 at 8:14
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Jesse_b, Archemar, Jeff Schaller, Vlastimil, meuh Feb 26 at 8:14
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
@Jesse_b Thanks for the edit.It makes more sense of what I wanted to ask.
â user7841468
Feb 25 at 17:54
add a comment |Â
@Jesse_b Thanks for the edit.It makes more sense of what I wanted to ask.
â user7841468
Feb 25 at 17:54
@Jesse_b Thanks for the edit.It makes more sense of what I wanted to ask.
â user7841468
Feb 25 at 17:54
@Jesse_b Thanks for the edit.It makes more sense of what I wanted to ask.
â user7841468
Feb 25 at 17:54
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
PATH is an environment variable (one of many) that stores the path that Bash searches when you type in a command on the command line. If you add a folder to the PATH, then any commands in that folder will be available for you to type at the command line (although, be careful, if the same commands exist elsewhere, earlier in the path).
However, if you change PATH on the command line, that won't persist outside of that session, after you log out. The .bashrc
script is run every time Bash starts, so if you put a command in there to edit the PATH (or any other environment variable), that change will persist every time you log in to Bash.
Does that help?
So the path to a directory I set is for that session only. But if I put the same in .bashrc it is permanent.Did I get it right ?
â user7841468
Feb 25 at 17:42
@user7841468 essentially, yes. In general, environment variables are internal to Bash and not persistent. If you change one from the command line, that will only last for that session. However, all of the commands in .bashrc are run every time you log in to Bash, which effectively makes them persistent.
â Time4Tea
Feb 25 at 17:51
That seems correct thanks for the clarification.You were a great help sir.
â user7841468
Feb 25 at 17:53
add a comment |Â
up vote
0
down vote
To modify the PATH
in such a way that future shells see the modified value, the change should be made in the shell startup files (~/.bashrc
in the case of bash
for example).
However, that change will not be visible in the current shell, so executing the equivalent command on the command line introduces the new value for PATH
for the currently running shell session as well.
If you only changed the shell startup file, you would have to close the current shell session and start a new one to see the effect of the change.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
PATH is an environment variable (one of many) that stores the path that Bash searches when you type in a command on the command line. If you add a folder to the PATH, then any commands in that folder will be available for you to type at the command line (although, be careful, if the same commands exist elsewhere, earlier in the path).
However, if you change PATH on the command line, that won't persist outside of that session, after you log out. The .bashrc
script is run every time Bash starts, so if you put a command in there to edit the PATH (or any other environment variable), that change will persist every time you log in to Bash.
Does that help?
So the path to a directory I set is for that session only. But if I put the same in .bashrc it is permanent.Did I get it right ?
â user7841468
Feb 25 at 17:42
@user7841468 essentially, yes. In general, environment variables are internal to Bash and not persistent. If you change one from the command line, that will only last for that session. However, all of the commands in .bashrc are run every time you log in to Bash, which effectively makes them persistent.
â Time4Tea
Feb 25 at 17:51
That seems correct thanks for the clarification.You were a great help sir.
â user7841468
Feb 25 at 17:53
add a comment |Â
up vote
2
down vote
accepted
PATH is an environment variable (one of many) that stores the path that Bash searches when you type in a command on the command line. If you add a folder to the PATH, then any commands in that folder will be available for you to type at the command line (although, be careful, if the same commands exist elsewhere, earlier in the path).
However, if you change PATH on the command line, that won't persist outside of that session, after you log out. The .bashrc
script is run every time Bash starts, so if you put a command in there to edit the PATH (or any other environment variable), that change will persist every time you log in to Bash.
Does that help?
So the path to a directory I set is for that session only. But if I put the same in .bashrc it is permanent.Did I get it right ?
â user7841468
Feb 25 at 17:42
@user7841468 essentially, yes. In general, environment variables are internal to Bash and not persistent. If you change one from the command line, that will only last for that session. However, all of the commands in .bashrc are run every time you log in to Bash, which effectively makes them persistent.
â Time4Tea
Feb 25 at 17:51
That seems correct thanks for the clarification.You were a great help sir.
â user7841468
Feb 25 at 17:53
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
PATH is an environment variable (one of many) that stores the path that Bash searches when you type in a command on the command line. If you add a folder to the PATH, then any commands in that folder will be available for you to type at the command line (although, be careful, if the same commands exist elsewhere, earlier in the path).
However, if you change PATH on the command line, that won't persist outside of that session, after you log out. The .bashrc
script is run every time Bash starts, so if you put a command in there to edit the PATH (or any other environment variable), that change will persist every time you log in to Bash.
Does that help?
PATH is an environment variable (one of many) that stores the path that Bash searches when you type in a command on the command line. If you add a folder to the PATH, then any commands in that folder will be available for you to type at the command line (although, be careful, if the same commands exist elsewhere, earlier in the path).
However, if you change PATH on the command line, that won't persist outside of that session, after you log out. The .bashrc
script is run every time Bash starts, so if you put a command in there to edit the PATH (or any other environment variable), that change will persist every time you log in to Bash.
Does that help?
answered Feb 25 at 17:36
Time4Tea
866119
866119
So the path to a directory I set is for that session only. But if I put the same in .bashrc it is permanent.Did I get it right ?
â user7841468
Feb 25 at 17:42
@user7841468 essentially, yes. In general, environment variables are internal to Bash and not persistent. If you change one from the command line, that will only last for that session. However, all of the commands in .bashrc are run every time you log in to Bash, which effectively makes them persistent.
â Time4Tea
Feb 25 at 17:51
That seems correct thanks for the clarification.You were a great help sir.
â user7841468
Feb 25 at 17:53
add a comment |Â
So the path to a directory I set is for that session only. But if I put the same in .bashrc it is permanent.Did I get it right ?
â user7841468
Feb 25 at 17:42
@user7841468 essentially, yes. In general, environment variables are internal to Bash and not persistent. If you change one from the command line, that will only last for that session. However, all of the commands in .bashrc are run every time you log in to Bash, which effectively makes them persistent.
â Time4Tea
Feb 25 at 17:51
That seems correct thanks for the clarification.You were a great help sir.
â user7841468
Feb 25 at 17:53
So the path to a directory I set is for that session only. But if I put the same in .bashrc it is permanent.Did I get it right ?
â user7841468
Feb 25 at 17:42
So the path to a directory I set is for that session only. But if I put the same in .bashrc it is permanent.Did I get it right ?
â user7841468
Feb 25 at 17:42
@user7841468 essentially, yes. In general, environment variables are internal to Bash and not persistent. If you change one from the command line, that will only last for that session. However, all of the commands in .bashrc are run every time you log in to Bash, which effectively makes them persistent.
â Time4Tea
Feb 25 at 17:51
@user7841468 essentially, yes. In general, environment variables are internal to Bash and not persistent. If you change one from the command line, that will only last for that session. However, all of the commands in .bashrc are run every time you log in to Bash, which effectively makes them persistent.
â Time4Tea
Feb 25 at 17:51
That seems correct thanks for the clarification.You were a great help sir.
â user7841468
Feb 25 at 17:53
That seems correct thanks for the clarification.You were a great help sir.
â user7841468
Feb 25 at 17:53
add a comment |Â
up vote
0
down vote
To modify the PATH
in such a way that future shells see the modified value, the change should be made in the shell startup files (~/.bashrc
in the case of bash
for example).
However, that change will not be visible in the current shell, so executing the equivalent command on the command line introduces the new value for PATH
for the currently running shell session as well.
If you only changed the shell startup file, you would have to close the current shell session and start a new one to see the effect of the change.
add a comment |Â
up vote
0
down vote
To modify the PATH
in such a way that future shells see the modified value, the change should be made in the shell startup files (~/.bashrc
in the case of bash
for example).
However, that change will not be visible in the current shell, so executing the equivalent command on the command line introduces the new value for PATH
for the currently running shell session as well.
If you only changed the shell startup file, you would have to close the current shell session and start a new one to see the effect of the change.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
To modify the PATH
in such a way that future shells see the modified value, the change should be made in the shell startup files (~/.bashrc
in the case of bash
for example).
However, that change will not be visible in the current shell, so executing the equivalent command on the command line introduces the new value for PATH
for the currently running shell session as well.
If you only changed the shell startup file, you would have to close the current shell session and start a new one to see the effect of the change.
To modify the PATH
in such a way that future shells see the modified value, the change should be made in the shell startup files (~/.bashrc
in the case of bash
for example).
However, that change will not be visible in the current shell, so executing the equivalent command on the command line introduces the new value for PATH
for the currently running shell session as well.
If you only changed the shell startup file, you would have to close the current shell session and start a new one to see the effect of the change.
answered Feb 25 at 21:37
Kusalananda
103k13202318
103k13202318
add a comment |Â
add a comment |Â
@Jesse_b Thanks for the edit.It makes more sense of what I wanted to ask.
â user7841468
Feb 25 at 17:54