You work as the Network Administrator for McNeil Inc. The company has a Linux- based network.
You are working as a root user on the Red Hat operating system. Joe is a user in your company.
You want to remove Joe’s tmp files that are 3 days older. Which of the following command
syntaxes should you use to accomplish the task?
A.
find /tmp -cmin +3 -user Joe -ok rm {} \;
B.
find /tmp -ctime +3 user Joe -ok rm {} \;
C.
find /tmp -ctime +3 -user Joe -ok rm {} \;
D.
find /tmp -cmin +3 user Joe -ok rm {} \;
Explanation:
This command will prompt you to remove Joe’s tmp files that are 3 days older. When the -ok
option is used with the find command it causes find to execute the rm command once for each
/tmp file that is 3 days older. {} can be used as a filename placeholder.
The -ok option with the find command is used to execute a command once for each file that
matches the given criteria. This is commonly used in situations such as removing files or renaming
files to have a certain extension. The -ok option causes find to ask for each file before removing it.What is the find command?
The find command is a versatile method for locating files on a file system. The syntax for this
command is as follows:
find <start directory> -<criteria>
Some of the important criteria are described in the table below:What are some numeric criteria that the find command uses?
The find command can search your system for files that comply with certain numeric criteria. For
example, -ctime, -atime, -cmin, -amin, etc. The -ctime and -atime are measured in days and the -cmin and -amin are
measures in minutes.
For example:
find /tmp -ctime +10
This command searches for files that are more than 10 days older.
find /tmp -cmin +10
This command searches for files that are more than 10 minutes older.
What is the purpose of using \; at the end of the find command?
The purpose of using \; at the end of the find command is that when find is used with -exec and
–ok the find command uses ; as the delimiting character. Unfortunately ; is also a delimiting
character for the bash shell so we must prevent bash from interpreting it. When a character is
preceded with a backslash (\), bash instructs it literally, so typing \; at the bash command prompt
will send ; to find command after bash has done its interpretation.
Answer option A is incorrect. This command will prompt you to remove Joe’s tmp files that are 3
minutes older.
Answer options D and B are incorrect. These are the incorrect command syntaxes.