What is the difference between ~ and / in Linux environment?
Can anyone please explain the difference?
The tilde (~) is a Linux "shortcut" to denote a user's home directory. Thus tilde slash (~/) is the beginning of a path to a file or directory below the user's home directory. For example, for user01, file /home/user01/test. file can also be denoted by ~/test.
There is no difference if you do not put $* or $@ in quotes. But if you put them inside quotes (which you should, as a general good practice), then $@ will pass your parameters as separate parameters, whereas $* will just pass all params as a single parameter.
Slash is the path separator in Linux. We use it to separate the current directory (.) from the file name.
1 Answer. 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.
~ contains the path to the 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 path separator. In Linux additionally if you do:
cd /
It will bring you to the root directory (topmost directory of your filesystem)
the simple answer is :/
is your root directory~
is your home 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