Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
When you run a script, the shell creates a new sub-shell. That's why it doesn't work. The PATH is updated in the sub-shell, but when the script finishes, that sub-shell and all of its settings (including environment variables) are lost. There is no way to "push" a sub-shell's settings into its parent.
You need to source the file instead of running it. Source'ing a file acts as if you input each line in the file directly at the command prompt. You can source a file in one of two ways:
I've a few more questions though. i tried putting the same code in my .bash_profile then closed the terminal and opened another terminal. how come nothing happened. do i need to reset my pc for that?
sorry for this stupid question. i could have found out the answer by restarting the PC myself, but I cant and I dont have the liberty to shut it down.
The .bash_profile script is invoked for login shells, and .bashrc for non-login shells (e.g. opening up a new xterm in X). Usually the way to do it is have one source the other so you have a consistent environment regardless of whether the shell is login or non-login.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.