Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between '~' and '/' in linux [closed]

Tags:

linux

What is the difference between ~ and / in Linux environment?

Can anyone please explain the difference?

like image 224
user5312249 Avatar asked Oct 01 '15 09:10

user5312249


People also ask

What does '~' do in Linux?

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.

What is the difference between $@ and $* in Linux?

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.

What does Slash mean in Linux?

Slash is the path separator in Linux. We use it to separate the current directory (.) from the file name.

What is the difference between and ~/?

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.


2 Answers

~ 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)

like image 169
rkachach Avatar answered Sep 18 '22 05:09

rkachach


the simple answer is :
/ is your root directory
~ is your home directory

like image 42
spazmantiz Avatar answered Sep 19 '22 05:09

spazmantiz