Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to find files in some folder like /home/mike/www/test where only root has read permissions and not any other user.

EDIT: I have the sudo and permission but I want to list all files where only root has read permission but not any group or public?

share|improve this question

migrated from stackoverflow.com Aug 31 '12 at 7:13

This question came from our site for professional and enthusiast programmers.

1  
Can you sudo to get root permissions? –  Peter Gluck Aug 31 '12 at 0:59
    
i have sudo and root permissions –  user1596900 Aug 31 '12 at 1:04
    
If a file has 0 permissions (or other weird settings like 333), then the owner cannot at the moment read those files (though the owner could change the permission so that they could read those files). Also, if a directory on the path leading to the file is not accessible (the x-bit) to the general world (e.g. the directory is owned by root with 700 permission), then ordinary files under that directory are not readable by others, regardless of who owns them or the permissions on the file. So, there are other possible interpretations for the question, but the selected answer is most plausible. –  Jonathan Leffler Aug 31 '12 at 2:34
    
how can i get those files who have special permissions –  user1596900 Aug 31 '12 at 3:31
add comment

3 Answers

up vote 3 down vote accepted
find /home/mike/www/test -user root -perm +400 ! -perm +044 -print
share|improve this answer
    
thanks buddy , u guys r great –  user1596900 Aug 31 '12 at 1:28
add comment

Try using the sudo command to elevate your permissions.

sudo ls /home/mike/www/test

or

sudo find /home/mike/www/test -name "foo" -print

If you cannot do that you will need to have a system administrator add your login to the /etc/sudoers file.

share|improve this answer
    
i think u didn't understood my questions. I want to list all files in folders and under subfolders where only root has read permission but not any other user or group –  user1596900 Aug 31 '12 at 1:04
    
Ah, yes, I did misunderstand the question. –  Peter Gluck Aug 31 '12 at 1:30
add comment

You need to use the find command to determine just which directories and files are only readable by root. Something like this might do what you want:

sudo find / -uid 0 -perm 600

This will generate a list of all files owned by UID 0 (root) with only read permissions for root. The list will be absolute pathnames.

You can redirect the output to a file, or pipe it to another program.

Do man find for a comprehensive list of options supported.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.