How to go to remote directory in Cygwin?

55

9

I'm using the latest version of Cygwin to try to cd into a network drive on Windows XP Pro Service Pack 3. The path in Windows Explorer to this directory is something like:

\\myserver\photos\original

I tried mounting it to a drive letter ('X') in Explorer, which worked just fine, but then when I ran the command:

ls /cygdrive/x/

It just froze there and hung. Any ideas how I can go into this directory and at least taking a listing of the files in there?

daveslab

Posted 2010-01-29T16:07:05.247

Reputation: 915

I was able to use "ls /cygdrive/x/" on Windows 7 Enterprise – Salvador Valencia – 2019-11-08T00:28:58.047

Answers

60

To add to quack's answer: You can access the network drive also via

ls //myserver/photos

However, on my machine (Windows Vista) it works only after at first pointing the explorer there (\\myserver\photos) and entering my username and password.

In the Cygwin docs they lose a short word about this.

Boldewyn

Posted 2010-01-29T16:07:05.247

Reputation: 3 835

2ls //VBOXSRV/<vbox share name>/ - for those who wants to access VirtualBox shares through cygwin. – FelikZ – 2015-02-17T15:35:02.917

Awesome. This works without mounting the drive in windows as a letter. – Brent Faust – 2013-06-03T05:56:20.063

13

You're doing it correctly -- this process works on my setup. The /cygdrive/X notation should work for any drive that Windows has mounted and given a drive letter.

  • Can you browse this network share in Explorer? (Your question doesn't state so explicitly, so double-check.)

  • You can try a standard Windows cmd shell (not Cygwin) -- Windows' builtin pushd will auto-mount the share to a temporary drive.

    C:> pushd \\myserver\photos\original
    
    Z:\original>
    

If neither of those work, you've got another problem. (Is the computer with the network share up?)

If those work but Cygwin still can't view /cygdrive/X (or /cygdrive/z after your Windows pushd test), I'd try rebooting your workstation. If the problem persists after a reboot, you may have a broken Cygwin installation; I honestly can't think of any other reasons why it wouldn't work.

quack quixote

Posted 2010-01-29T16:07:05.247

Reputation: 37 382

Thanks very much for your help! I can browse it in Explorer, actually, and it was definitely up and running. I just tried the pushd command and that worked, but not in cygwin. It seems that I can't list any files in any network drive. Is there a tool I need to download from setup.exe? – daveslab – 2010-02-02T13:47:58.887

i can't think of anything in particular; this functionality should just work. i mean, Cygwin is just using regular filesystem access calls, nothing special, so it should be able to list directories and read files on any mounted filesystem. if i were you i'd try uninstalling Cygwin then reinstalling. if you have an old version, consider reinstalling the latest version (v1.7.x of the cygwin.dll). – quack quixote – 2010-02-02T20:50:59.727

The mounted share is hidden on my setup if mounted after the start of Cygwin. It is shown if I restart Cygwin afterwards. – tricasse – 2014-05-11T09:48:39.903

3

I had the same symptoms. The problem appeared to be related to running the application in administration mode. As soon as I turned off the option to 'Run this program as an administrator' and restarted the application I was able to access the network drives via the /cygdrive/ directory.

Note: I'm running Windows Server 2012 R2 but I would bet this would work on windows7 and up.

Note: You must open the properties dialog of the binary itself (ie mintty.exe) and not the short cut to access the administration option for the application.

Hope this helps!

Adam Parsons

Posted 2010-01-29T16:07:05.247

Reputation: 41

0

Stumbled here with the same problem. I know this is an old post but hope it will help others just in case. I had no luck with the suggested solutions. However this worked for me: cd //remotehost/d$ if the the remote host is a Windows machine. The dollar sign does the trick.

Tony

Posted 2010-01-29T16:07:05.247

Reputation: 1

The d$ may get you into the root of the D: drive on that machine, if it's not disallowed. What the OP is looking for is how to get into a specific share on the box. – Taegost – 2013-07-11T14:13:12.973