LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   Unable to delete a file (https://www.linuxquestions.org/questions/linux-security-4/unable-to-delete-a-file-4175583433/)

quintze 06-30-2016 09:07 AM

Unable to delete a file
 
Hello,

I am running Ubuntu 14.04 and I have a mounted drive to a network storage device (buffalo drive). I have been able to delete files within the folder that I am working in, logged in as USER1. The file permissions of a folder that I am trying to delete is below:

drwxr-xr-x 2 root root 0 Oct 10 2012 Long Short Fund

When I run rsync, I am getting an error saying that it can't be copied. There is a permission denied error below:

rsync: readdir("/media/winacctbuffalo/New_Acct/Saved_K_GP2000/Maher/Long Short Fund"): Permission denied (13) rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.0]rsync: readdir("/media/winacctbuffalo/New_Acct/Saved_K_GP2000/Maher/Long Short Fund"): Permission denied (13) rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.0]

When I try to delete it, I am getting the same error. I tried sudo chmod -R 777 foldername

but, I am still unable to delete it. I also tried to
sudo chown user1:user1

but that didn't work.

I posted this in security thread but feel free to move if this is incorrectly place. Any ideas of what it might be or how I can delete it. The buffalo drive is viewable in a windows environment and I tried to delete it from the gui in windows but it wouldn't delete either. Not an urgent matter but it would be good to learn a new trick of how to delete the file.

Thanks

lazydog 06-30-2016 01:16 PM

How are you running rsync? As a USER or as ROOT? That directory is 755 so only Root can write anything into it while a user can read or execute anything in that directory. If you are running rsync as a USER try running it as ROOT and it should work.

Same goes with Deleting it are you trying to delete is as a USER or ROOT? Root owns it so Root is the only one who can delete it.

another thing crossed my mind how is it mounted as rw or ro? You can see this with;

Code:

mount

quintze 06-30-2016 03:40 PM

I run a bash script and execute it by SUDO CRONTAB -E so I believe I am running it as root. The bash script (.sh) file that I am executing is owned by root as well:

-rw-r--r-- 1 root root 345 Jun 30 14:24 myscript.sh


Here is also the mount output for the drive in question:

//10.140.6.100/share on /media/winacctbuffalo type cifs (rw,username=specialist,password=password,iocharset=utf8,sec=ntlm)


I think I have tried to run:
SUDO RMDIR /media/"Long Short Fund"

but, this didn't work. Not sure if it is some weird thing going on with the file, but I can't even delete it in Windows.


thanks for looking at this lazydog!

JJJCR 07-01-2016 12:21 AM

Please try below, enclosed the whole path with quotes.

Quote:

sudo rmdir -rf "/media/Long Short Fund"
-rf is force recursive deletion. It will delete sub folders as well, make sure you're doing the right thing.

And please watch out for case sensitivity in Linux commands.

lazydog 07-01-2016 09:18 AM

Quote:

Originally Posted by quintze (Post 5568597)
//10.140.6.100/share on /media/winacctbuffalo type cifs (rw,username=specialist,password=password,iocharset=utf8,sec=ntlm)

Is this a windows machine? If it is, does the user have the rights to remove directories from the system?
Just because you mounted it as 'rw' doesn't mean you will have those right is the hosting server does not allow you to do this.

quintze 07-01-2016 12:19 PM

It is a Buffalo NAS drive. I am going to try the suggestions and get back to you. I seem to have rights to all other files other than this folder. I am suspecting a corrupt folder....

quintze 07-05-2016 09:01 AM

I haven't been able to delete the file, but I am assuming it may be a corrupt folder. I also tried deleting it with fileassasin and that didn't work either because it is a folder. However, I think this is probably a corrupt folder. Let me know if anyone else thinks of anything. I will close thread for now. Cheers!

rknichols 07-05-2016 12:14 PM

For a local filesystem, the last resort is to run debugfs on the partition holding the filesystem, use the clri command to clear the bad inode, then run fsck to clean up the resulting filesystem inconsistencies. Whether you can log into your NAS device and have the necessary access to do that is another question.


All times are GMT -5. The time now is 10:32 PM.