You can only change permissions of files that you own. In order to change other files, you need root permissions.
When you pipe the output of one command to another, you do just that:
Code:
sudo find /home/otheruser/ -type d -print0 | xargs -0 chmod 0777
The first command is run with root privileges, the command that receives the output of that first command is running with normal privileges.
You can test that nicely from the output of "ls -l" after running
Code:
sudo touch test1 | touch test2
..."sudo find /home/otheruser/ -type f -print0 | xargs -0 sudo chmod 0777" it gives error message of command length.
To avoid that, use find's "exec" option instead of an xargs construct.
Bookmarks