195k views
0 votes
Find all the files and directories in /var (including subdirectories) that are owned by user root. Send the list of full path names to s8. Your find command may produce "Permission Denied" errors during this search. This will have no effect on the answer, and this error can be safely ignored for this question.

User Zerowords
by
6.7k points

1 Answer

2 votes

Answer:

find /var -user root > s8

Step-by-step explanation:

To look for a file matching multiple conditions with find, what you do is to simply list each condition in turn. For instance, to look for a file owned by root (-user root) and writable by its owner (-perm -u+w) on the root filesystem (-xdev, meaning not to recurse underneath mount points such as /proc and /sys) and called hello:

find / -xdev -user root -perm -u+w -name hello

If you're looking for world-writable files, replace -u+w by -a+w. (The - before the permissions means that the file must have at least these permissions; without it find would search for a file that has exactly the distinct permissions.) With GNU find, you can also look for a file that is writable by the user running find: replace -perm -u+w by -writable.

In this case, frame the command as required.

Code: find

Everywhere

code: /

Only directories

code: var

Root owned file

code: - user root

Permission bits

Code: > s8

User Guo Huang
by
6.0k points