Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

hajime

macrumors 604
Original poster
Jul 23, 2007
7,747
1,220
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
 

MacUser2525

Suspended
Mar 17, 2007
2,097
377
Canada
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

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.
 

mslide

macrumors 6502a
Sep 17, 2007
707
2
This is your home directory. On OSX, it's the same as /Users/<your username>

This is the root directory.

3. /home/
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.
 

Peace

Cancelled
Apr 1, 2005
19,546
4,556
Space The Only Frontier
Code:
MacUser2525:~$ cd ~/
MacUser2525:~$ pwd
/Users/MacUser2525
MacUser2525:~$ cd /
MacUser2525:/$ pwd
/
[B]MacUser2525:/$ cd /home/[/B]
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.

The part in bold is redundant .

All you need to type is cd /home
 

MacUser2525

Suspended
Mar 17, 2007
2,097
377
Canada
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.

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.

The part in bold is redundant .

All you need to type is cd /home

I was showing him exactly what he typed, same as the ~/ is redundant as I show in my last example.
 
Last edited by a moderator:

hajime

macrumors 604
Original poster
Jul 23, 2007
7,747
1,220
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.

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 / ?
 

mslide

macrumors 6502a
Sep 17, 2007
707
2
I cannot move any file to /home/

Exactly. You shouldn't be able to with the way OSX ships.

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.

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.

What if I am also the root (administrator) user? Is ~/ the same as / ?

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.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.