I have one Mac set up with file sharing on the desktop, and I am trying to connect to it from my other Mac from the Terminal. I made a folder mount in /Volumes/, then I used the following command.

sudo mount -t afp afp://user:pass@ipaddress/Desktop /Volumes/mount

(obviously I changed the user/pass/ip to the correct information)

Though whenever I try to access it, it says I do not have permission. When I access it through Finder with the same username and password, it works perfectly fine.

Is there any reason this is not working?

Edit - If I run the ls command with sudo I can access the files. So update to the question:

Is there a way to change the ownership of the Volume? chown is throwing the error Operation not permitted, even with sudo.

  • Clarification requested- if you can access the remote share using Finder, can you not drag the mounted volume into a terminal window after typing in "cd " instead of trying to mount it directly? – KarlC Mar 7 '16 at 21:54
  • @KarlC When I get bored, I try various things. For example this time I was going to make a web-based file explorer on my local computer to access file shares on my network. This can easily be done with PHP and the right permissions, but to do that I need to be able to mount the Volume via the Terminal. I Googled it and only found the above code. It mounts the Volume properly, but when I go to open the Volume it just says that I do not have permission to view the contents of the Volume. – ZomoXYZ Mar 7 '16 at 22:31
  • @klanomath if I use the sudo it mounts (unreadable but it mounts). If I remove it I get the following error: mount_afp: AFPMountURL returned error 1, errno is 1. – ZomoXYZ Mar 8 '16 at 0:32
  • @klanomath The "server" mac is 10.10.5, the mac I am using is 10.11.3. – ZomoXYZ Mar 8 '16 at 0:35

To mount a share in Terminal use the following commands:

mkdir /Volumes/mount
mount -t afp afp://user:pass@ipaddress/Desktop /Volumes/mount

This works because the folder /Volumes is world read & writable.

If you use sudo mkdir /Volumes/mount mount has the following permissions:

drwxr-xr-x+ 2 root  admin  -       68  8 Mär 02:40 . <- mount
drwxrwxrwt@ 5 root  admin  hidden 170  8 Mär 02:40 .. <- /Volumes

and the only possible command to mount a share is:

sudo mount -t afp afp://user:pass@ipaddress/Desktop /Volumes/mount

because you are not allowed to "write" (=mount) to the folder mount as non-root user.

with the following result:

drwx------  1 root  wheel  -        264  8 Mär 02:38 . <- mount (the share "Desktop")
drwxrwxrwt@ 5 root  admin  hidden   170  8 Mär 02:42 .. <- /Volumes

and you can't even open (=read) the folder with your user.

If you create the mount folder with mkdir /Volumes/mount the permissions looks like this:

drwxr-xr-x+ 2 user  admin  -       68  8 Mär 02:42 . <- mount
drwxrwxrwt@ 5 root  admin  hidden 170  8 Mär 02:42 .. <- /Volumes

After mounting the share with:

mount -t afp afp://user:pass@ipaddress/Desktop /Volumes/mount

the permissions look like this:

drwx------  1 user  staff  -        264  8 Mär 02:38 . <- mount (the share "Desktop")
drwxrwxrwt@ 5 root  admin  hidden   170  8 Mär 02:42 .. <- /Volumes
  • 2
    Missing step is sudo chown $(whoami) /Volumes/mount after sudo mkdir. /Volumes is not world read and writable on mine. – vaughan Jul 11 '18 at 21:49

You must log in to answer this question.

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