Today we had a strange corrupted file end up on one of our backup servers, and was not allowing any kind of chown or rm operations. We couldn’t take ownership through a chown, could not do chmod, rm -f, etc. A stat of the directory (“tulip” in our case) showed some ridiculous timestamps (last accessed was 1988 and changed was 2040), a sign of an obviously corrupt file.

First, to view the file attributes, do the following:


This will show you the file attributes on all files in the directory, look for anything without a bunch of dashes (most files will have a set of dashes like below).

-------------e- ./kb-logo.gif
-------------e- ./Firefox_wallpaper.png
----------I--e- ./Downloads
-------------e- ./navPrimeRight3.png
-------------e- ./
-------------e- ./Desktop

To remove the attributes, try the following (of course replace filename with the filename or directory you’re having trouble with):

for i in a c d i t u A D S T; do chattr -${i} ; done

Later we searched for other files that might have the same issue with (replace “.” with your directory name). Note in my case I’m throwing out the error stream from the initial lsattr command…

find . -exec lsattr 2>/dev/null {} \; | awk '!/\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-/ {print $1 $NF}'

From the chattr man page:

The letters `acdeijstuADST' select the new attributes for the files:
append only (a), compressed (c), no dump (d), extent format (e),
immutable (i), data journalling (j), secure deletion (s), no tail-merg‐
ing (t), undeletable (u), no atime updates (A), synchronous directory
updates (D), synchronous updates (S), and top of directory hierarchy