linux find commands
find / -size +100M -exec rm -rf {} \;
Researching Files: What command would you enter if you wanted to find all files from root that were 100MB and recursively force delete them?
T
T of F With the find command / and . are recursive.
T
T or F A sticky bit permission is one where only the owner of a file can delete it.
T
T or F: The -print action prints the entire filename to standard output. If the filename has a newline you should use -print0
placeholder
Researching Files: In a find command with an -exec, what does { } do with each file or folder instance that the command finds?
terminates it
Researching Files: In the line: find / -type d -perm 777 -print -exec chmod 755 {} \; What does the \; do to each instance that the command finds, (the \ character is an escape character)?
find / -size 50M
Researching Files: What command would you enter if you wanted to find all 50MB files from root?
find / -type d -perm 777 -print -exec chmod 755 {} \;
Researching Files: What command would you enter if you wanted to find all directories from root whose permission was 777 and then change the permission to 755?
find / -type d -name mydirectory
Researching Files: What command would you enter if you wanted to find all directories in the root directory (recursive) whose name was mydirectory?
find /home -user BOB
Researching Files: What command would you enter if you wanted to find all files and folders from the home directory that belong to user BOB?
find / -size +50M -size -100M
Researching Files: What command would you enter if you wanted to find all files from root that were between 50MB and 100MB in size?
find /home -iname myfile.txt
Researching Files: What command would you enter if you wanted to find all files from the home directory named myfile.txt whose characters could be both upper and lower case?
find /home -name myfile.txt
Researching Files: What command would you enter if you wanted to find all files from the home directory named myfile.txt?
find /home -group BOB
Researching Files: What command would you enter if you wanted to find all files from the home directory that belong to group BOB?
find . -type f -perm 777 -print
Researching Files: What command would you enter if you wanted to find all files in the current working directory (recursive) whose file permission was 777?
find . -type f -name "myfile.txt" -exec rm -f {} \;
Researching Files: What command would you enter if you wanted to find all files in the current working directory (recursive) whose name was myfile.txt and then force remove the files?
find / -perm /u=r
Researching Files: What command would you enter if you wanted to find all files in the root directory (recursive) that were read only?
find / -type f -perm 777 -print -exec chmod 644 {} \;
Researching Files: What command would you enter if you wanted to find all files in the root directory (recursive) whose permission was 777 and then change the permission to 644?
find / -type f ! -perm 777
Researching Files: What command would you enter if you wanted to find all files in the root directory whose permission was NOT 777?
find . -name myfile.txt
Researching Files: What command would you enter if you wanted to find all files named myfile.txt in the current working directory (recursive) with this directory?
find . -type f -name "*.txt"
Researching Files: What command would you enter if you wanted to find all the .txt files in the current working directory (recursive)?
find /tmp -maxdepth 1 -type f -empty
Researching Files: What command would you enter if you wanted to find all the empty files, only in the tmp directory?
find / -cmin -60
Researching Files: What command would you enter if you wanted to find all the files from root that were changed within the last 60 minutes?
find / -atime 50
Researching Files: What command would you enter if you wanted to find all the files from root which were accessed within the last 50 days?
find / -mtime +50 -mtime -100
Researching Files: What command would you enter if you wanted to find all the files from root which were modified within the last 50 days to 100 days
find / -mtime 50
Researching Files: What command would you enter if you wanted to find all the files from root which were modified within the last 50 days?
find /tmp -maxdepth 1 -type f -name ".*"
Researching Files: What command would you enter if you wanted to find all the hidden files only in the tmp directory?
find /home -user bob -iname "*.txt"
Researching Files: What command would you enter if you wanted to find all the text files, case-insensitive from the home directory with a user of bob?