The ~
or ~/
refers to the absolute path of your home directory a.k.a. /home/username
.
Additionally, if you try cd ~
or cd ~/
they will both do the same thing; the shortest option being simply cd
. All three options take you to your home directory. NOT /home.
Since .bashrc
is located in your home directory, you must specify its location by adding the tilde, which allows you to point to home directory from wherever you are and thus access the .bashrc
.
Of course, this works for any other files and folders located in your ~
, for example:
cd ~/myFolder
~/myScript.sh
What you were trying to do is open .bashrc
, but since vim checks in your current location if the file already exists or not, it will create a new .bashrc file in your current pwd
, since there is no current .bashrc where you were trying to open it.
In other words, if you were in /home/username/someFolder/someSubFolder
, doing the vim .bashrc
command will create a new .bashrc
file, since there is no already existing .bashrc
and you did not point to the right path, which is /home/username/.bashrc
(or ~/.bashrc
).
:w
) and see where it was saved. That should be the directory where you opened vim. – Al.G. Jun 13 '18 at 09:48~
is expanded to your home directory, so it doesn't make sense. Are you sure your $PWD is the same as your $HOME? – choroba Jun 13 '18 at 09:49filename
notfilename.extension
Unix does not have file extensions. a.
us just a.
. Except when the.
is the first character, in this case it tellsls
not to list it (it is hidden). – ctrl-alt-delor Jun 13 '18 at 14:18/home
is not the home you are looking for.$HOME
is where the home is. Your home will (probably) be/home/yourname
. – ctrl-alt-delor Jun 13 '18 at 14:20