Common users do not have administrator rights on Linux. So the find command often encounters Permission denied.
Here are two solutions:
1. Using Python script, I wrote a Python script that can run the function of searching for specific files on the server without the error of Permission denied
import os
import re
def findInPath(dirname):
pattern = re.compile(r'libcuda\.so\.1') This is where you set the name of the file you are looking for
result = []
for maindir, subdir, file_name_list in os.walk(dirname):
for filename in file_name_list:
apath = os.path.join(maindir, filename)
result = pattern.findall(apath)
if result[0] == ' ':
pass
else:
print(apath)
if __name__ == "__main__":
path = '/opt'
findInPath(path)
Copy the code
Set up the actual starting directory to look for and the name of the file to find can have fun. The best way to use this script is to commit to a task using clustered computing power, which is much faster than running it from the command line
2. Use a shell script alias findfile = ‘find. – the depth -type f -iname “* 2” > / dev/null | xargs md5sum 2 > / dev/null | grep – color – nE The -ir’ shell command can do similar things, but I don’t think it’s as fast as a Python script