1

I was wondering about a simple event that occurred while I was installing node version manager on my 64bit Amazon Linux 2014.09 Web Server. When I executed this install script

curl https://raw.githubusercontent.com/creationix/nvm/v0.23.3/install.sh | bash

NVM installed onto my filesytem at ~/.nvm/

What is the significance of the ~/.nvm as opposed to ~/nvm ? Specifically, what does the ' . ' mean before nvm?

This is especially important because when I execute " ll " in the ~/ folder, I do not see any files. However, when I execute cd ~/.nvm , I am taken to the ~/.nvm folder.

Also, in order to get nvm working in the terminal, I had to "source" the nvm.sh file in this way

source ~/.nvm/nvm.sh

What did this source command accomplish?

Note: everything is working, this is just a curiosity I would like to understand better so that I feel more comfortable with server configurations etc.

Thanks a bunch!

1 Answers1

3

The character . at the beginning of the filename makes it hidden.
To see an hidden file from shell you can do ls -a (or ls -A).

Note the differences:

 .myfile.sh       # hidden file
 .   myfile.sh    # source the file myfile.sh

source (or .) are internal command of bash. You can have access to their definition with help.

With the command type you can understand if a command is a built-in shell or not.

E.g. the command type source /bin/ls will answer

source is a shell builtin
/bin/ls is /bin/ls

Then you can ask to the system information about the commands respectively with help or man.


From help source you can read

source: source filename [arguments]
Execute commands from a file in the current shell. Read and execute commands from FILENAME in the current shell. The entries in $PATH are used to find the directory containing FILENAME. If any ARGUMENTS are supplied, they become the positional parameters when FILENAME is executed.

From man ls

-a, --all
do not ignore entries starting with .

Hastur
  • 19,483
  • 9
  • 55
  • 99