Chmod doesn’t work on folder ‘d — — —‘ permissions

chmodchownpermissions

In /var/www I've got a folder:

d--------- 2 www-data www-data  4096 May 20  2012 update

reported by ls -la.

I'm logged in as root, but I can't change permissions or ownership. chown and chmod returns 'Operation not permitted'

An automatic update procedure demands all files and folders to be owned by 'www-data' and permissions set to 'u+w'.

Best Answer

As I searched through the list of unanswered questions for ones that I might be able to answer, I saw this question’s title and I figured that it might be an issue with file attributes. As detailed in the question’s comments, the immutable attribute had been set and @slm posted the solution:

sudo chattr -i /var/www/update

However, @slm also asked a very pertinent question, “why is that bit set in the first place?” The first time I learned of the immutable bit was when I was asked to look at a server that had been rooted. The binaries for ps and lsof had been replaced with modified versions (in order to hide other malicious processes) and the immutable bit had been set to prevent any future OS updates from replacing the malicious executables with updated genuine versions.

Related Question