I am using a Mac OS 10.10.3 and I am new to using linux commands. This is the doubt I have-
The present working directory: /dir_name
when I run this command: cd ~
The directory path changes to: ~dir_name
What does the ~ or / change in the directory path mean?
~ by itself is equivalent to $HOME. It refers to your home directory, typically something like /home/yourname.
~foo refers to the home directory of the user foo.
Both these uses of ~ are handled by the shell. That means, for example, that if you call fopen("~/foo/file.txt", "r") in a C program, it won't expand ~ to your home directory; rather, it will look for (and probably not find) a directory literally named ~ in the current directory.
/ is the root directory.
Invoking cd with no argument is equivalent to cd ~ or cd $HOME.
cd ~ redirect you to home directory.
It is equivalent to cd $HOME
cd / redirect you to root directory
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With