问题
I am trying to change the permissions of a files present in a directory and subdirectories using the below command and running into below error..can anyone help?
user@machine:/local/mnt/workspace$ find . -type f -exec chmod 644 {} \;
chmod: changing permissions of `./halimpl/ncihal/adaptation/NonVolatileStore.cpp': Operation not permitted
回答1:
you can run the following command:
#chown -R directory_path
But it will change the permissions of directories also.
For only files, you can run.
#find directory_path -type f -exec chmod 644 {} \;
It also looks like you dont have enough permissions. try
#sudo find directory_path -type f -exec chmod 644 {} \;
or run the command as root user.
回答2:
It looks to me like you don't have permission to change NonVolatileStore.cpp.
Are you aware of chmod
's -R
switch that recursively changes permissions?
回答3:
if you have the root privilege, try:
sudo find . -type f -exec chmod 644 {} \;
回答4:
It could be that you simply don't own that file. Run an ls -l
on it to see full permissions and who the owner is.
It could also be the filesystem is read only.
来源:https://stackoverflow.com/questions/17892593/changing-permissions-of-files-in-a-directory-recursively