[adsense id=”0514458240″ width=”468″ height=”60″]
Recently I discovered that my files were either owned by the wrong user or that they did not have the correct permissions to do what was needed. I needed to consolidate all of these under one user and set all the files to the same permissions. The Linux/UNIX find command allowed me to first identify all those files as well as correct them.
To identify the files in question i.e. those now owned by “me” OR (-o) not owned by “mygroup” group.
$ find $HOME \( -not -owner me -o -not -group mygroup \) -ls
To identify the files that did not have a specific permission
$ find $HOME -not -perm 750 -ls
We could have also tried to find all files that are not owned by me or mygroup and with permissions that do not permit me to view i.e. others = read (Octal 4)
$ find $HOME \( -not -owner me -o -not -group mygroup \) -a -not -perm +004 -ls
Once we have correctly verified that these are the correct files and could be changed we issue the following commands:
$ find $HOME \( -not -owner me -o -not -group mygroup \) -exec chown my:mygroup {} \; -ls
and the permissions
$ find $HOME -not -perm 750 -exec chmod 750 {} \; -ls