Search code examples
linuxterminalbackup

How to recursively change permissions with backup file comparing permissions


So in my work i did a mistake and it change all the file permissions (file owner and group) recursively inside a folder. I have the backup of that folder. I'm working inside a nsf server and my idea is to copy the permissions of the backup directory to the directory where i did the mistake recursively. All the folders and files have the same name and i want to grab the permissions from each file/directory from the backup and copy the permissions to the original directory, recursively.


Solution

  • chown can be uded to change ownership of a file or firectort

    chown -R root:user /dir

    changes the file ownership to user

    -R perform the command recursively in a directory

    same for

    chmod -R 600 /dir

    then you specify your permission and ownership in your own format