0

I want to copy (tar and zip) a directory hierarchy that doesn't even have read permissions for root enabled - WITHOUT changing the permissions (it is part of the system and I assume they have these permissions for a reason).

How can this be done?

Linux.

d-b
  • 1,891
  • 3
  • 18
  • 30

1 Answers1

2

The root user account in Linux/Unix does not favor read/write permissions and can access all filesystem objects regardless. Do it normally without thinking about permissions.

P.S. There are situations when root cannot access files but it's not your case. More on it here: How do file permissions work for the "root" user?

  • Is there a difference between root and sudo in this respect? Because when I perform a sudo grep in this hierarchy I get "access denied" on the files. – d-b Oct 19 '20 at 18:12
  • Is this hierarchy on the local disk or in a distributed filesystem such as NFS? – patbarron Oct 19 '20 at 18:27
  • @patbarron It is on a server I have SSH access to. I used SSH to run sudo grep, with all these access denied errors. – d-b Oct 20 '20 at 09:49
  • And this is on a locally mounted filesystem (e.g., ext4)? The reason I'm trying to nail this down is that, on a locally mounted filesystem, permissions have no effect on root (as the person who posted this answer points out). Using sudo or otherwise doesn't matter, it's treated the same. Long ago, it used to be that directories needed to have at least one x bit set in order to be traversed, even by root - but even that is no longer the case. So the only scenario I can think up where you'd see this is on a network-mounted filesystem. If that's not the case, then I'm truly puzzled... – patbarron Oct 20 '20 at 16:25