{"id":3908,"date":"2026-06-06T12:48:52","date_gmt":"2026-06-06T11:48:52","guid":{"rendered":"https:\/\/kudzia.eu\/b\/?p=3908"},"modified":"2026-06-06T21:46:19","modified_gmt":"2026-06-06T20:46:19","slug":"recovering-debian-from-accidental-chown-r","status":"publish","type":"post","link":"https:\/\/kudzia.eu\/b\/2026\/06\/recovering-debian-from-accidental-chown-r\/","title":{"rendered":"recovering debian from accidental chown -R www-data:www-data \/"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>chown root:root -R \/root\nchown man:man -R \/var\/cache\/man\nchown -h root:root \/initrd.img \/initrd.img.old \/lib \/lib64 \/sbin \/vmlinuz \/vmlinuz.old \/\napt-get install --reinstall $(dpkg --get-selections | awk '$2==\"install\"{print $1}')\n# ^- that did not help much.\n\n# on a clean \/ fresh server:\nfind \/ \\( -path \/proc -o -path \/sys \\) -prune -o  -printf '%P\\t%u\\t%g\\n'  > \/tmp\/ownership.txt\n# transfer that file to the problematic server\n<\/code><\/pre>\n\n\n\n<p>on the destination server create and run fix.sh:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\nwhile IFS=$'\\t' read -r path user group; do\n    &#91; -e \"\/$path\" ] || continue\n    chown \"$user:$group\" \"\/$path\"\ndone &lt; \/tmp\/ownership.txt\n\n<\/code><\/pre>\n\n\n\n<p>command that helped me to spot wrongly owned files\/directories:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>find \/ -group www-data|egrep -v \"^(\/var\/www|\/proc|\/var\/log\/nginx|\/var\/spool\/github-rollback\/|\/var\/lib\/nginx\/proxy\/)\"|less\nfind \/ -user www-data|egrep -v \"^(\/var\/www|\/proc|\/var\/log\/nginx|\/var\/spool\/github-rollback\/|\/var\/lib\/nginx\/proxy\/)\"|less<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>on the destination server create and run fix.sh: command that helped me to spot wrongly owned files\/directories:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51],"tags":[28],"class_list":["post-3908","post","type-post","status-publish","format-standard","hentry","category-unimportant","tag-debian"],"_links":{"self":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/3908","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/comments?post=3908"}],"version-history":[{"count":4,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/3908\/revisions"}],"predecessor-version":[{"id":3915,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/3908\/revisions\/3915"}],"wp:attachment":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/media?parent=3908"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/categories?post=3908"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/tags?post=3908"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}