What is the difference between ~ directory_name and / directory _name in linux

I am using Mac OS 10.10.3 and I am new to using Linux commands. This doubt I have -

Real working directory: / Dir _name

when i run this command: cd ~

Directory path changes to: ~ Dir_name

What does ~ or / change in the directory path mean?

+4
source share
4 answers

~equivalent in itself $HOME. This applies to your home directory, usually something like /home/yourname.

~foorefers to the user's home directory foo.

~ . , , fopen("~/foo/file.txt", "r") C, ~ ; , (, , ) , ~ .

/ .

cd cd ~ cd $HOME.

+5

cd ~ . cd $HOME

cd /

+2

~ ./ .

cd ~

cd / .

+1

~ .

/

pwd ( ), , .

cd ~
pwd
cd /
pwd
0

All Articles