24

I read recently that .desktop files that are used as desktop shortcuts are placed in the $HOME/Desktop directory. Where is this directory?

Also, what does the $ part mean / do?

2 Answers 2

34

$HOME is an environment variable that contains the location of your home directory, usually /home/$USER. The $ tells us it's a variable. So assuming your user is called DevRobot the .desktop files are placed in /home/DevRobot/Desktop/.

If you want to know where $HOME points to, you can run the following in a terminal.

[ajefferiss@localhost ~]$ echo "$HOME"
/home/ajefferiss

You can use it to move around the filesystem, for example cd $HOME but generally you won't see that because you can use ~/ to represent the current users home directory. Or just run cd by itself to move to the home directory.

11
  • 2
    Note that $HOME also varies user to user. Some system users have an oddball $HOME path not on /home/...
    – Thomas Ward
    Oct 19, 2015 at 12:34
  • 4
    Or just run cd by itself to move to the home directory, TIL
    – TMH
    Oct 19, 2015 at 14:59
  • 5
    Holy crap, @TomHart, do you know how many times I've typed cd ~ without realizing I could skip the awkward shift-pinky move? Oct 19, 2015 at 15:48
  • 2
    Probably similar to the amount of times I've typed cd ~/!
    – TMH
    Oct 19, 2015 at 16:20
  • 6
    Actually HOME is the environment variable. The shell needs you to prepend it with $ to signify it.
    – Mark Hurd
    Oct 20, 2015 at 4:34
5

$HOME is an environment variable that points to /home/<username>. It is located under /, and it contains the user's files.

For more information you may want to take a look at Bash Reference Manual

5
  • 4
    There's absolutely no rule that $HOME has to point to /home/<username>. Apache on Ubuntu creates a user www-data whose $HOME is /var/www, e.g.
    – Alex
    Oct 19, 2015 at 15:32
  • @Alex we are talking here in regards to Ubuntu and, Linux. :)
    – Mitch
    Oct 19, 2015 at 16:07
  • Actually HOME is the environment variable. The shell needs you to prepend it with $ to signify it.
    – Mark Hurd
    Oct 20, 2015 at 4:34
  • 1
    I was talking about Ubuntu/Linux too, Mitch. /home/<username> is a convention, not a requirement. It's easy to add a user whose $HOME is at /somewhere/entirely/different.
    – Alex
    Oct 20, 2015 at 14:27
  • I set my $HOME location to something different (another partition from an earlier install) and now can't find it...
    – DPSSpatial
    Jul 4, 2018 at 15:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .