In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use linux to find file locations". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
In linux, you can use the find or locate commands to find the file location, with the syntax formats of "find /-name file name" and "locate file name". The find command is used to find files in the specified directory, and the locate command is used to find documents that meet the criteria.
The operating environment of this tutorial: centos7 system, thinkpad T480 computer.
Because you want to install pl/sql, you need to find the tnsnames.ora file. See how to find out which directory this file is under linux
Find /-name tnsnames.ora
Found:
/ opt/app/oracle/product/10.2/network/admin/tnsnames.ora
/ opt/app/oracle/product/10.2/network/admin/samples/tnsnames.ora
You can also use locate to find
Locate tnsnames.ora
The result is: / opt/app/oracle/product/10.2/hs/admin/tnsnames.ora.sample
/ opt/app/oracle/product/10.2/network/admin/tnsnames.ora
/ opt/app/oracle/product/10.2/network/admin/samples/tnsnames.ora
one。 Look up through the file name:
For example, if you forget which directory the httpd.conf file is in, or even somewhere on the system, you can use the following command:
Find /-name httpd.conf
The syntax of this command seems easy to understand, just write-name after find, indicating that the system is required to look up the file name, and finally write the target file name httpd.conf. In a moment, the system will display a list of search results on the computer screen:
Etc/httpd/conf/httpd.conf
This is the full path of the file httpd.conf in the Linux system. The search was successful.
If the system does not display the results after entering the above search command, then do not think that the system did not execute the find /-name httpd.conf command, but may not have installed an Apache server in your system, as long as you installed the ApacheWeb server, and then use find /-name httpd.conf to find this configuration file.
two。 Error-free finding techniques:
In Linux systems, the "find" command is available to most system users and is not exclusive to ROOT system administrators. However, the average user can also encounter such a problem when using the "find" command, that is, the system administrator ROOT in the Linux system can set some file directories to disable access mode. In this way, ordinary users do not have the permission to query these directories or files with the "find" command. When the average user uses the "find" command to query these file directories, the words "Permissiondenied." (forbidden) often appear. The system will not be able to query the file you want. To avoid such errors, we can try to find the file by transferring the error prompt, such as typing:
Find /-name access_log 2 > / dev/null
three。 Find the method based on some file names:
For example, if we know that a file contains the letters srm, it is possible to find all the files in the system that contain these three letters. Enter:
Find / etc-name'* srm*'
This command indicates that the Linux system will search the entire / etc directory for all files containing the three letters srm, such as absrmyz,tibc.srm and other eligible files can be displayed. If you also know that the file starts with the letters srm, we can also omit the first asterisk, as follows:
Find/etc-name 'srm*'
Only files like srmyz can be found, and files like absrmyz or absrm do not meet the requirements and are not displayed, so the efficiency and reliability of finding files are greatly enhanced.
four。 Query method according to the characteristics of the file:
If you only know the size of a file, the modification date and other features can also be found using the "find" command, which is basically the same as the "search" function in the WINDOWS system. In Microsoft's "search", "search Assistant" makes it easier to search for files and folders, printers, users, and other computers on the network. It even makes it easier to search on Internet. Search Assistant also includes an indexing service that maintains indexes of all files on your computer, making searches faster. When using search Assistant, users can specify multiple search criteria. For example, users can search for files and folders by name, type, and size. Users can even search for files that contain specific text. If you are using Active Directory, you can also search for printers with a specific name or location.
For example, if we know that a Linux file size is 1500bytes, we can use the following command to query find /-size
1500c, the character c indicates that the size of the file you are looking for is in bytes. If we don't even know the exact size of this file, we can also use fuzzy lookup in Linux to solve the problem. For example, if we enter the command find /-size+10000000c, it indicates that our designated system looks up files greater than 10000000 bytes in the root directory and displays them. The "+" in the command means that the system is required to list only files larger than the specified size, while the use of "-" means that the system is required to list files less than the specified size. The following list is the search action to be made by the system after Linux uses different "find" commands, from which we can easily see that there are many ways to use the "find" command in Linux. As long as the "find" command is used flexibly, it is no worse than looking for files in WINDOWS.
Find /-amin-10 # finds the files accessed in the last 10 minutes of the system
Find /-atime-2 # finds the files accessed in the last 48 hours of the system
Find /-empty # looks for files or folders that are empty in the system
Find /-groupcat # finds files that belong to groupcat in the system
Find /-mmin-5 # finds files that have been modified in the last 5 minutes of the system
Find /-mtime-1 # finds files that have been modified in the last 24 hours of the system
Find /-nouser # finds files that belong to invalid users in the system
Find /-user fred # finds files that belong to the user FRED in the system
The following list is some of the criteria for finding the characteristics of a file that can be specified by the find command. Not all the search criteria are listed here. Refer to the relevant books on Linux to know the search functions of all find commands.
-amin n
Find the files accessed in the last N minutes of the system
-atime n
Find the last 24-hour access file in the system
-cmin n
Find the files in the system that were changed in the last N minutes.
-ctime n
Find the files in the system that were changed in the last 24 hours.
-empty
Find blank files in the system, or blank file directories, or folders that do not have subdirectories
-false
Find files in the system that are always wrong
-fstype type
Find files in the system that exist on the specified file system, for example: ext2.
-gid n
Find files in the system where the file number group ID is n
-group gname
Find files in the system that belong to the gnam filegroup and specify the group and ID
"how to use linux to find file location" content is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.