When the script is done, any changes that it made to the environment are discarded. . script The above sources the script. It is as if the commands had been typed in directly. Any environment changes are kept. source script This also sources the script. The source command is not required by POSIX and therefore is less portable than the shorter ..
source is a shell keyword that is supposed to be used like this: source file where file contains valid shell commands. These shell commands will be executed in the current shell as if typed from the command line.
So the main difference is that you are sourcing a script that will update variables/aliases in the current shell vs (what the OP was doing) running a script which starts a new shell that then sources i.e. doesn't update the current shell.
That being said... +1 bump for asking a common question that should be answered for all newcomers to *nix systems. :) Building from source sometimes means the difference between fixing a nasty bug and just suffering until the next software release. It's really not that bad, and as many here have pointed out, once you know what to look for and how to do it, fairly painless.
The source command will: Read and execute commands from the filename argument in the current shell context. If filename does not contain a slash, the PATH variable is used to find filename. This behaviour is defined (for ., its alias) by POSIX. Why? Well, you can put sourceable configuration scripts inside PATH and access them without a qualified path. To access the file you want, give an ...
I want to try my hand at writing a linux driver. I am trying to set up my environment. My current kernel: $ uname -r 4.10.0-37-generic I then download the source code: $ apt-get source linux-imag...
5 Do 100% open source linux distro's exist? i.e. distros which contain absolutely no closed source components anywhere at all? Apparently distros like Ubuntu contains bits and pieces which are closed source.
I'm trying to setup a firewall-cmd rule for incoming source IPv4 addresses using CentOS 7. At present, I've managed to add-port for zone=public, but cannot find a way to do "granular filtering" for external access - like what is mentioned above.
$ sudo ./myfile.sh ./myfile.sh: 2: ./myfile.sh: source: not found I found this but if I try to add sudo -s to the top of the file it seems to change the prompt to a # -- but the python does not run as expected. I'm not sure what the program is doing when I have sudo -s at the top of the file like that. How can I get this program to run as root?
When you say source and have two files, I am thinking that you are wanting to have the two commands available at the command line and want provider to set the variable for the consumer to use later.