Search This Blog

Showing posts with label find. Show all posts
Showing posts with label find. Show all posts

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 \)

Wednesday, June 1, 2011

How to find Big Size File and Folder in Linux?

Here is the trick

Use the following to find the spacious directory.
#find / -type d -exec ls -ld {} \; |sort -nrk5|head

Use the following to find the spacious file.
#find / -type f -exec ls -ld {} \; |sort -nrk5|head

The output may take time depending on your system performance.