Permission denied when using mv in Windows 7 Cygwin

7

2

I have Cygwin installed on Windows 7 in a windows domain sign-on environment. I can run most typical commands without issue, but I cannot for the life of me use the "mv" command to move or rename files, regardless of the file or directory.

I can copy and create files without issue.

┌─[12:27:57]─[mbutl2@MYHOSTNAME]
└──> tmp $ >> pwd
/tmp
┌─[12:27:58]─[mbutl2@MYHOSTNAME]
└──> tmp $ >> touch test.txt
┌─[12:28:02]─[mbutl2@MYHOSTNAME]
└──> tmp $ >> mv test.txt hello
-bash: /usr/bin/mv: Permission denied

I have already tried running Cygwin terminal as Administrator and the problem is the same.

I'm open to workarounds, such as trying another exe for moving files and redirecting the mv command to it. Moving files works in the Windows Command Prompt.

UPDATE: It appears that there may be a security restriction on my laptop that either prevents accessing/copying/executing the "mv.exe" program by its name or by its heuristics. Still willing to accept workarounds that replace the mv command as mentioned above.

UPDATE 2: Screenshots in windows command line and when I open mv.exe in Windows.

windows command prompt

enter image description here

UPDATE 3: output of file command:

┌─[12:36:09]─[mbutl2@MYHOSTNAME]
└──> ~ $ >> file /usr/bin/mv
/usr/bin/mv: writable, executable, regular file, no read permission
┌─[12:36:15]─[mbutl2@MYHOSTNAME]
└──> ~ $ >> chmod 777 /usr/bin/mv
chmod: changing permissions of `/usr/bin/mv': Permission denied
┌─[✗]─[12:36:29]─[mbutl2@MYHOSTNAME]
└──> ~ $ >> mv
-bash: /usr/bin/mv: Permission denied
┌─[✗]─[12:36:35]─[mbutl2@MYHOSTNAME]
└──> ~ $ >>

ldd also reports permission denied.

Michael Butler

Posted 2013-07-01T16:39:34.447

Reputation: 197

try changing the file permissions Mv.exe,see this article:http://www.uwec.edu/Help/drives/permissions.htm

– stderr – 2013-07-08T19:32:34.767

Does this also happen in the Windows command prompt (cmd) ? – harrymc – 2013-07-08T19:58:25.850

It's worth checking that the permissions on c:\cygwin\bin\mv.exe, in both Windows and Cygwin, permit execution for the accounts you're using. Also, see what happens when you double-click that executable in Windows Explorer -- if you see a UAC prompt, then that's why you're getting the error in Cygwin, and it will occur regardless of permissions; I do not know a way of working around that except to disable UAC entirely, which is rarely desirable. – Aaron Miller – 2013-07-08T20:58:25.943

I updated the question with screenshots on what happens in the proposed scenarios. If UAC is causing this, is that controlled by the file name, file path, or some kind of hash key of the executable. In other words, could I change the executable (or create a new one) that does the same thing but lives somewhere else, with a different hash signature? – Michael Butler – 2013-07-09T13:18:38.543

What does 'ldd /usr/bin/mv' or 'file /usr/bin/mv' say? – golimar – 2013-07-09T13:21:50.683

1@MichaelButler: what is your antivirus? – stderr – 2013-07-09T16:49:01.037

have you checked ownership / tried chmod 755 on ~ ? – Ben Plont – 2013-07-13T03:14:53.700

Yes I did Ben, that didn't fix it. The problem is an enterprise McAfee policy rule blocking all access to mv.exe at the kernel level. – Michael Butler – 2013-07-15T13:04:27.993

Answers

2

The workaround was to re-download Cygwin's mv.exe utility, saving it as a different name like mvvv.exe (before actually downloading it, since I don't have access to rename mv.exe). Then, I set up a symbolic link to point mv to mvvv.exe so I can use it normally.

Michael Butler

Posted 2013-07-01T16:39:34.447

Reputation: 197

You should be able to create a symbolic link: ln -s mmv /usr/bin/mv to use mv on prompt and/or scripts. Except something is special with the filename mv on your machine... – mpy – 2013-07-10T18:26:49.403

Since McAfee seems like the problem, is my answer an option here (getting rid of this monster) ? – harrymc – 2013-07-10T18:30:28.630

@mpy Thank you! Brilliant workaround. A lot better than using an alias. 'mv' is fine since I'm in Cygwin and don't need "exe". "mv.exe" is the problem. I did a slink to mvvv.exe called mv and everything is normal now. – Michael Butler – 2013-07-10T21:15:26.817

@harrymc sorry Harry, while McAfee was the problem, I think a solution is the best answer (the symbolic link to a differently named mv.exe) – Michael Butler – 2013-07-15T13:07:01.317

6

  • See if the file has been blocked by Windows.

    Check the properties of the file, there may be a note saying This file came from another computer and might be blocked to help protect this computer To check for and unblock the file, follow these steps: Right-click the blocked file and then click Properties. In the General tab, click Unblock if the option is available.

  • Check to see if your antivirus is blocking the file.

    You can check to see if your antivirus software is blocking a file by temporarily disabling it, and then trying to open the file.


Update:

  1. Right-click the file or folder, and then click Properties.
  2. Click the Security tab.
  3. Under Group or user names click your name to see the permissions you have.
  4. Click Edit, then check the check boxes for the permissions that you need and then click OK.

Result:

enter image description here


Update 2:

Try this:

  • Right click, select Properties.
  • Click the Security tab.
  • Click Advanced.
  • Click the Owner tab.
  • Change owner to yourself.
  • Click Edit.
  • Check Replace owner on subcontainers and objects.
  • Click OK.

stderr

Posted 2013-07-01T16:39:34.447

Reputation: 9 300

Update 2 worked. For me, what had happened was that I had installed Cygwin with one Windows user and tried to access from another. – thameera – 2014-11-07T05:47:58.707

Properties didn't say anything about coming from another computer. Antivirus is VirusScan Enterprise (managed through a network). I can turn the auto-scan off via toggle switch, but this has no effect on opening, moving, or renaming the mv.exe file. – Michael Butler – 2013-07-09T18:02:27.113

Interesting. When I set permissions in the Security tab on the FOLDER, I get "Access denied" on setting permissions on the mv.exe. Screenshot attached. – Michael Butler – 2013-07-09T18:41:55.020

@MichaelButler: Updated my answer. See if you can now. – stderr – 2013-07-09T19:29:03.267

0

Just in case that something went wrong on your disk with mv.exe, I would try to :

  • uninstall Cygwin
  • chkdsk
  • verify that mv.exe was deleted with its entire folder
  • reinstall Cygwin

[EDIT]

You say that your antivirus is McAfee, which in my opinion is one of the most problematic of all antivirus products.

I would suggest to disable real-time protection in McAfee to see if the problem goes away. If it does, my own recommendation is to uninstall McAfee and install some other less-intrusive antivirus product.

harrymc

Posted 2013-07-01T16:39:34.447

Reputation: 306 093

You forgot the "replace the drive" and "reinstall Windows" steps. – Tony – 2015-10-29T13:18:50.040

@Tony: I'm much beyond that : now working on "Reinstalling the planet". Seriously, replacing McAfee is not on the same level as the actions you suggested. My company has had much trouble with client computers that had McAfee installed, so now I'm slightly allergic to it. – harrymc – 2015-10-29T14:01:02.843