What are ~/, / and /home/

Discussion in 'Mac Basics and Help' started by hajime, Oct 24, 2013.

  1. hajime macrumors 68030

    Joined:
    Jul 23, 2007
    #1
    Hello,

    I am confused about the following which some users use often in xterm;

    1. ~/
    2. /
    3. /home/

    What does each stand for? What are the differences? Could anybody please explain? thanks
     
  2. MacUser2525 macrumors 68000

    MacUser2525

    Joined:
    Mar 17, 2007
    Location:
    Canada
    #2
    Code:
    MacUser2525:~$ cd ~/
    MacUser2525:~$ pwd
    /Users/MacUser2525
    MacUser2525:~$ cd /
    MacUser2525:/$ pwd
    /
    MacUser2525:/$ cd /home/
    MacUser2525:/home$ pwd
    /home
    MacUser2525:/home$ cd ~
    MacUser2525:~$ pwd
    /Users/MacUser2525
    
    
    As you can see just different directories located on your machine. The ~ means your user home directory which is different as you can see from the /home/ the / is always the root directory of your install. pwd= print working directory it shows you where you are located in the file system at the moment.
     
  3. mslide macrumors 6502a

    Joined:
    Sep 17, 2007
    #3
    This is your home directory. On OSX, it's the same as /Users/<your username>

    This is the root directory.

    On Linux and some flavors of Unix, /home is the directory where all users' home directories are located. While OSX does have a /home directory, local users' home directories are at /Users and not /home. I've never used /home on OSX but my guess as to why it's there is for remote mounted home directories, remote users, directory services, etc.
     
  4. Peace macrumors Core

    Peace

    Joined:
    Apr 1, 2005
    Location:
    Space--The ONLY Frontier
    #4
    The part in bold is redundant .

    All you need to type is cd /home
     
  5. MacUser2525, Oct 24, 2013
    Last edited by a moderator: Oct 24, 2013

    MacUser2525 macrumors 68000

    MacUser2525

    Joined:
    Mar 17, 2007
    Location:
    Canada
    #5
    You would be correct there I think every time I shutdown/reboot I see that unmounting remote /home in the messages as I have my machine setup to verbose boot therefore same at shutdown.

    I was showing him exactly what he typed, same as the ~/ is redundant as I show in my last example.
     
  6. hajime thread starter macrumors 68030

    Joined:
    Jul 23, 2007
    #6
    I cannot move any file to /home/

    I recall recently somebody mentioned that it is not a good idea to store things in /home/ as it is supposed to be used by the OS to store system files. That is why I got an error when I tried to move things to that directory.

    What if I am also the root (administrator) user? Is ~/ the same as / ?
     
  7. mslide, Oct 25, 2013
    Last edited: Oct 25, 2013

    mslide macrumors 6502a

    Joined:
    Sep 17, 2007
    #7
    Exactly. You shouldn't be able to with the way OSX ships.

    As a user, you should only be storing things in your home directory (i.e. /Users/<your username> and not in /home) unless you really know what you're doing. It's certainly possible to use /home but the way OSX ships by default, the operating system "owns" /home for directory services (according to /etc/auto_master and /etc/auto_home). It sounds like you don't have a reason to use /home on OSX so I won't go into more detail.

    No. On OSX, the root user's home directory is /var/root. Other operating systems might have it someplace else, like at /root. Most Mac users never interact with this directory because OSX ships with the root user disabled (and it should only be enabled if you have a really good reason to enable it and you really know what you're doing).

    BTW, if you really want to learn more about how these sorts of things work, I recommending doing it in a virtual machine and not on your main OSX install. It's easy to mess things up once you start playing around in Terminal. Download VirtualBox and install Linux or FreeBSD and go nuts. If you mess things up, it's no big deal because you can re-install. Even though OSX is a different operating system, once you understand how one Unix (like) operating system works, you'll have a much better understanding of how all of them work.
     

Share This Page