I'm new to Linux and Ubuntu. People keep using ~/filename
in their answers to my questions. What does ~/
mean?
3 Answers
~/
is shorthand for the current user's home folder. So if your user name is "foobar" it expands to /home/foobar/
-
8And if you want to refer to another
user
home directory you can use~user
, as inls -l ~enzotib/Documents/
.– enzotibDec 4, 2011 at 20:05 -
2
-
1I did not say invalid :) Generally we see
~
instead of~/
, since/
is not necessary there. Dec 4, 2011 at 20:47 -
8This is only usually correct, but not technically correct.
~
actually expands to the value of the environment variableHOME
. If you change the value ofHOME
,~
will also no longer point to that user's home directory.– kojiroDec 5, 2011 at 2:41 -
1
An important thing is, if you are using the root user, ~/
will be the /root
directory, not /home/user_name
.
In this case, do:
> cd ~/ ; pwd ;
It will exit:
> /root
-
This is a direct result of the fact that
/root
is listed as the home directory of the root user in your/etc/passwd
table. It isn't a special case. Aug 8, 2018 at 0:51
In general the tilde ~ represents your home folder. Use it to refer to your home directory at the command line.