# Unable to delete files



## balanga (May 25, 2017)

I am unable to delete some files and directories which exist under /mnt, presumably because symbolic links were created during mounts (just guessing...)
When I attempt to delete (as root) various files and directories, I get an 'Operation not permitted' msg. Even booting from a different device and mount that directory does not permit removal of these files.

Any suggestions as to how to delete them?


----------



## ShelLuser (May 25, 2017)

Impossible to say without knowing how the remote file system got mounted. This is most likely a problem on the remote host.

(edit): By default /mnt is empty and it's only used to mount other file systems on it.

(edit2): Look into /etc/fstab and/or the output from `mount`, that should give you some more hints.


----------



## ralphbsz (May 25, 2017)

A: Are you root?  Obviously I know that you are balanga and not root, so my real question should be: is your id zero?

B: What is the ownership of the files, what are the permissions of the files, and what is the id and group membership of your process?

C: What type of files are they?  Are they regular files, pipes, soft links, purple flying elephants, mount points, ... ?  If the file is an elephant, make sure it doesn't fall on you when you delete it.

D: If they are mount points, or on a separate file system: What type of file system, and is it a remote file system?  Does the remote file system use some sort of id or permission translation system?

E: Do the files have ACLs?  In that case, what do the ACLs mean (that depends on the type of file system)?

By the way, I buried a few jokes in the answers; some days I think that the only way to not go insane when administering computers is humor.


----------



## tobik@ (May 26, 2017)

balanga said:


> I am unable to delete some files and directories which exist under /mnt


If those files are extracted from e.g. base.txz they might have the immutable flag set. You can unset it with `chflags -R noschg /mnt/*`


----------



## balanga (May 26, 2017)

They were extracted from base.txz... I'll give this a try when I have chance.


----------



## phoenix (May 26, 2017)

balanga said:


> They were extracted from base.txz... I'll give this a try when I have chance.



You can check the file flags by adding *-o* to the ls(1) command:
`$ ls -lo /path/to/files/`

That will add a column of text between "group" and "file size" in the output.

See the chflags(1) page for details on what the different flags mean, how to set them, and how to unset them.


----------



## balanga (May 26, 2017)

```
schg
```


----------

