I'm new to Linux and Ubuntu. People keep using ~/filename in their answers to my questions. What does ~/ mean?
Asked
Active
Viewed 9.5k times
45
jrg
- 60,611
andrewsomething
- 37,412
3 Answers
53
~/ is shorthand for the current user's home folder. So if your user name is "foobar" it expands to /home/foobar/
andrewsomething
- 37,412
5
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
/rootis listed as the home directory of the root user in your/etc/passwdtable. It isn't a special case. – thomasrutter Aug 08 '18 at 00:51
2
In general the tilde ~ represents your home folder. Use it to refer to your home directory at the command line.
haziz
- 2,929
userhome directory you can use~user, as inls -l ~enzotib/Documents/. – enzotib Dec 04 '11 at 20:05~is the shorthand for current user's home folder :) – heartsmagic Dec 04 '11 at 20:17~/is equally valid. – Knowledge Cube Dec 04 '11 at 20:40~instead of~/, since/is not necessary there. – heartsmagic Dec 04 '11 at 20:47~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. – kojiro Dec 05 '11 at 02:41~is what refers to the user's home folder. The slash at the end is not required, and is just equivalent to adding the slash at the end of a directory path, and will have the same effect (ie, varies according to context). That is,~is equivalent to/home/userand~/is equivalent to/home/user/. The former concisely points to the directory, the latter can be used when using that directory as the root of some operation such as a destination for copying. – thomasrutter Aug 08 '18 at 00:48