LFCS · Question #845
What does the following script do? #!/bin/bash find/ -perm +4000 | mail -s "Daily find output" root
The correct answer is A. Emails a report of all suid files to root. The script finds files with the SUID bit set across the entire filesystem and emails the list of these files to the 'root' user.
Question
Options
- AEmails a report of all suid files to root.
- BEmails a report of all important files to root.
- CEmails a report of all writeable files to root.
- DEmails a report of all guid files to root.
- ECorrects permissions on files and emails the results to root.
How the community answered
(62 responses)- A87% (54)
- B2% (1)
- C3% (2)
- D6% (4)
- E2% (1)
Why each option
The script finds files with the SUID bit set across the entire filesystem and emails the list of these files to the 'root' user.
A is correct because `find / -perm +4000` specifically searches the entire filesystem (`/`) for files with the SUID (Set User ID) bit set (`+4000`). The output of this `find` command, which lists all such files, is then piped (`|`) to the `mail` command, sending it as an email with the subject "Daily find output" to the `root` user.
The command specifically looks for `+4000` permissions, not "important" files, which is a subjective term.
Writeable files would typically involve `w` permissions, not the SUID bit.
GUID (Set Group ID) files are identified by the `+2000` permission bit, not `+4000`.
The script only finds and reports files; it does not correct or modify any permissions.
Concept tested: `find` command (permissions, SUID) and basic scripting
Source: https://man7.org/linux/man-pages/man1/find.1.html
Topics
Community Discussion
No community discussion yet for this question.