How does linux query the directory
This article is mainly for everyone to analyze the linux directory how to query the relevant knowledge points, the content is detailed and easy to understand, the operation details are reasonable, with certain reference value. If you are interested, you may wish to follow Xiao Bian to have a look. Let's follow Xiao Bian to learn more about "how to query Linux directory".
Methods: 1. Use pwd command to view the current directory, the syntax is "pwd [--help][--version]";2. Use find command to query the specified directory, the syntax is "find path -option [-print] [-exec -ok command]".
Operating environment: Linux 7.3 system, Dell G3 computer.
How to search Linux directory
Open the shell connection tool, connect to the server, pwd view the current directory, generally come in by default in the home directory ~ under:
Switch to the home directory by command: cd /, then pwd to view the current directory, and ls to view files and directories in the current directory
If we want to find an nginx configuration file nginx.conf, we can find it by using the find command: find . -name 'nginx.conf'
In the order above. Indicates the current directory. If we want to specify a directory to look up without switching directories, we can find it by: find directory-name 'nginx.conf':
If we don't know the exact name of the file but vaguely remember a few key words, then we can search through fuzzy matching: find directory-name '*nginx*' Find:
If we remember a limited number of file names and find too many files, but we remember the contents of some files, then we can filter the contents of the files through the pipe command: find directory-name '*nginx*'| xargs grep 'content', you can find all files with.conf results and location content as follows
If we don't remember anything, just vaguely remember when the file was created, we can also find it by looking at the file creation time.
find command is a powerful search command, the above only introduced by file name, file content and file modification time to find, and we can also by file permissions, file size, file users and so on to find information
About "linux how to query the directory" on the introduction to this, more related content can be searched for previous articles, I hope to help you answer questions, please support the site!