Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the find file commands in linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

What are the find file commands in linux? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

1. Find

Find is the most common and powerful search command, and you can use it to find any file you want.

The format of find is as follows:

$find

-: the directory to search for and all its subdirectories. The default is the current directory.

-: the characteristics of the file to be searched.

-: specific processing of search results.

If no parameters are added, find searches the current directory and its subdirectories by default, and does not filter any results (that is, returns all files) and displays them all on the screen.

Examples of using find:

$find. -name 'my*'

Search for all files whose names begin with my in the current directory (including subdirectories, the same below).

$find. -name 'my*'-ls

Searches the current directory for all files whose names begin with my and displays their details.

$find. -type f-mmin-10

Search the current directory for all ordinary files that have been updated in the past 10 minutes. If you do not add the-type f parameter, search for normal files + special files + directories.

2. Locate

The locate command is actually another way to write "find-name", but much faster than the latter, because instead of searching for a specific directory, it searches for a database (/ var/lib/locatedb) that contains all the local file information. The Linux system automatically creates this database and automatically updates it once a day, so you can't find the most recently changed files using the locate command. To avoid this, you can manually update the database using the updatedb command before using locate.

Examples of use of the locate command:

$locate / etc/sh

Search for all files that start with sh in the etc directory.

$locate ~ / m

Search for all files that start with m in the user's home directory.

$locate-I ~ / m

Search for all files that start with m in the user's home directory, ignoring case.

3. Whereis

The whereis command can only be used to search for program names, and only binary files (parameter-b), man description files (parameter-m), and source code files (parameter-s) are searched. If the parameter is omitted, all information is returned.

Examples of use of the whereis command:

$whereis grep

4. Which

The which command searches for the location of a system command in the path specified by the PATH variable and returns the first search result. That is, using the which command, you can see whether a system command exists and where the command is being executed.

Examples of use of the which command:

$which grep

5. Type

The type command is not really a lookup command, it is used to tell whether a command is native to shell or provided by a separate binary outside of shell. If a command is an external command, using the-p argument displays the path to the command, which is equivalent to the which command.

Examples of use of the type command:

$type cd

You will be prompted that cd is the native command (build-in) of shell.

$type grep

You are prompted that grep is an external command and display the path to the command.

$type-p grep

With the-p argument added, it is equivalent to the which command.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report