Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Linux by (18.4k points)
What is the difference between ~ and / in a Linux environment?

Can anyone please explain this difference?

1 Answer

0 votes
by (36.8k points)

Tilde(~) is used to denote this user's home directory whereas the slash(/) is used for separators for filesystem objects in both absolute paths and relative the paths. Also, it is used to represent the root directory.

On a side note:

~/ is used to denote the beginning of a path to the file or directory below the user's home directory.

~ contains the path to a current user home directory (it gets expanded to the $HOME env variable). If you run:

echo ~

It will print this path. Slash character / is used by Linux (and other OSs) as the path separator. In Linux additionally, if you do:

cd /

It will bring you to a root directory (topmost directory of your filesystem)

Want to be a Linux expert? Come and join this linux course

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Dec 13, 2020 in Linux by blackindya (18.4k points)

Browse Categories

...