Command line to delete folder in remote Windows from Linux host

0

I use Linux and I have a remote Windows. I would like to try to delete folder in remote Windows (ex: C:\Temp) from my Linux by using command line.

My attempts are:

rm -rf IEUser@10.2.2.240/C/Temp

rm -rf //10.2.2.240/C/Temp

Both don't work, and I don't get any error.

Is is possible to delete folder in remote Windows by using command line? If yes, what would be the correct command line?

Ragnarsson

Posted 2018-05-07T08:47:56.173

Reputation: 101

Answers

3

Yes, but: unlike Windows, there is no automatic network share setup in Linux. You need to:

  • mount the share manually (as a cifs filesystem):

    # mount -t cifs //10.2.2.240/C /mnt/thatcomputer
    # rm -rf /mnt/thatcomputer/Temp
    
  • or use the "smbclient" program:

    $ smbclient //10.2.2.240/C
    smb:\> deltree \Temp
    

user1686

Posted 2018-05-07T08:47:56.173

Reputation: 283 655

Thanks. Sorry, my knowledge of Linux is very little (i am new to Linux) :(. When you say thatcomputer, that means IP address of my Linux, right? So I tried: mount -t cifs //10.2.2.240/C /mnt/10.x.x.xxx, but I get this messagemount: only root can use "--types" option, and I am not root/admin so I can't either install smbclient – Ragnarsson – 2018-05-07T09:16:48.030

Then you might be out of luck. Do you have gio or gvfs-mount? – user1686 – 2018-05-07T09:25:58.433

oh yes, I have gvfs-mount. I just tried gvfs-mount //10.2.2.240/C/Temp, but I got this message Error mounting location: volume doesn't implement mount – Ragnarsson – 2018-05-07T09:35:13.440

Note: C:\Temp is a folder I created everytime I run my automation test scripts on this remote Windows – Ragnarsson – 2018-05-07T09:36:10.310

Good, then use gvfs-mount smb://10.2.2.240/C. – user1686 – 2018-05-07T09:39:28.653

I tried your suggestion, unfortunately, I got this message: Error mounting location: Location is not mountable – Ragnarsson – 2018-05-07T09:55:58.290

Maybe that means you have the gvfs core but not gvfs-smb, which again isn't fixable without administrator help. – user1686 – 2018-05-07T09:59:01.107

yes what a pity. I will see about that. Thank you so much for your help. Much appreciated – Ragnarsson – 2018-05-07T10:08:52.843