Search This Blog

Sunday, October 30, 2011

Advanced Find Command.

my requirement was to list all root owned hidden (dot) files for shell configuration, including but not limited to ~root/.login, ~root/.logout, ~root/.cshrc and ~root/.profile, ~/root/.kshrc ~/root/.bash* must be owned by root,and must have permissions of 0400, 0600 or 0700.

I have gathered below information.

root owned Hidden files for shell configuration lies in /root folder. So i used find to list only hidden files in /root folder.

#find /root -type f -iname ".*"

Then i listed files which are not having permissions of 700,400,600.

#find . -type f -iname ".*" \( ! -perm 700 -and ! -perm 400 -and ! -perm 600 \)

Later added root user condition to display files not owned by root.

#find . -type f -iname ".*" \( ! -perm 700 -and ! -perm 400 -and ! -perm 600 -or ! -user root \)

No comments:

Post a Comment