LPI Exam Questions

Which of the following find command will print out a list of suid root files in /usr?

Which of the following find command will print out a list of suid root files in /usr?

A.
find /usr -uid 0 -perm +4000

B.
find -user root +mode +s /usr

C.
find -type suid -username root -d /usr

D.
find /usr -ls *s* -u root

E.
find /usr -suid -perm +4000

Explanation/Reference:
find needs the starting directory as first parameter, eliminating B and C as the right answers.

From the man pages:
find – search for files in a directory hierarchy
     -uid n
              File’s numeric user ID is n.
      -perm mode
              File’s permission bits are exactly mode (octal or symbolic).  Since an exact match is required, if  you want to use this form for symbolic modes, you may have to specify a rather complex mode string.  For example -perm g=w will only match files which have mode 0020 (that is, ones for which group write  permission is the only permission set). It is more likely that you will want to use the `/’ or `-‘ forms, for example -perm -g=w, which matches any file with group write permission.