Marco Linux Learning Query (command query and file query)

Source: Internet
Author: User

Linux operations are generally done using commands, and in so many different commands it is obviously unlikely and unnecessary to remember them all, and the search for files is essential in daily operations. Let's summarize how to find commands and files in Linux.

the run File path query for the command. This method of finding is also using the command, which is called which, which can help us find the path to the command. Detailed description of it we can man a bit oh.

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px; border-right:0px; "title=" 1428406667279625.png "alt=" Blob.png "src=" http://www.178linux.com/ueditor/php/upload/ Image/20150407/1428406667279625.png "/>

Next, we use which to view the path of the command. Let's take a look at the most common LS command.

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px; border-right:0px; "title=" 1428406746107082.png "alt=" Blob.png "src=" http://www.178linux.com/ueditor/php/upload/ Image/20150407/1428406746107082.png "/>

In the diagram, you can see that the results of the execution are displayed, not only the path of the LS command is displayed, but also that the command has an alias defined. OK, a dead-eye classmate will definitely come out of the problem, I don't want to see this alias definition, can not display let it look pleasing a little ah, oh, good, omnipotent Linux meet your perverted requirements, in the command plus –skip-alias option can skip aliases, Other places may also use Kazakhstan, the table forgot.

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px; border-right:0px; "title=" 1428407004710666.png "alt=" Blob.png "src=" http://www.178linux.com/ueditor/php/upload/ Image/20150407/1428407004710666.png "/>

OK, you see, which command can be very good to find out the command of the running file path, Remember to write scripts, scripts, non-shell built-in commands to use the full path of the command , for example. /bin/ls/home/student. This way of writing can ensure that the success rate of execution is hundred percent.


Another command that resembles a function is the type command. It can determine the type of a command, and if it is a shell built-in command, it is displayed as follows:

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px; border-right:0px; "title=" 1428407677161074.png "alt=" Blob.png "src=" http://www.178linux.com/ueditor/php/upload/ Image/20150407/1428407677161074.png "/>

The second command also found the path to this command, of course, which also indicates that this command is not a shell's built-in command.

Well, the command path and type already know how to check, as for the use of commands, you can use man, help, various degrees Niang and Google Oh.


find Dafa for files. then we summarize three common file search methods.

File Lookup method One, Whereis command. Use Whereis to find files and commands. The use method is #whereis COMMAND or FILENAME.

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px; border-right:0px; "title=" 1428409667109740.png "alt=" Blob.png "src=" http://www.178linux.com/ueditor/php/upload/ Image/20150407/1428409667109740.png "/>

You can use options to view only binaries, files under the manual path of the description file, and source files. It is important to note that the Whereis command is queried using a database that is not particularly fast, so the results are not real-time and completely accurate.


File Lookup method Two, locate command. The locate command is similar to Whereis and is used for database queries, and you can use the updatedb command to update the database before you look for the accuracy of the lookup.


File Lookup method Three, the Find command, uses the most powerful find command.

With the Find command, you can find time-based criteria.

For example, look for files that have been changed within 7 days of the/home/directory. Well, finally adding-ls can show the results in LS mode.

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px; border-right:0px; "title=" 1428410276995036.png "alt=" Blob.png "src=" http://www.178linux.com/ueditor/php/upload/ Image/20150407/1428410276995036.png "/>

The time option also has atime (access time) and CTime (creation time), the option parameter has n,+n,-n and so on commonly used three, respectively said n days ago, n days ago not including the day, n days contains n days.

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px; border-right:0px, "alt=" Center "src=" http://img.blog.csdn.net/20140222200758156?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvdglhbmtlzmvuzze5oduwntiw/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/ Gravity/center "/>

The find command also supports lookups as a standard for users or groups of users.

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px; border-right:0px; "title=" 1428410808137732.png "alt=" Blob.png "src=" http://www.178linux.com/ueditor/php/upload/ Image/20150407/1428410808137732.png "/>

In the you can see that I am in the/home directory to find the owner of the root file. -ls after redirection sort is for looking a little better, haha.

The Find command also supports searching by the various attributes of a file, such as the name, size, permissions, type, and so on.

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px; border-right:0px; "title=" 1428411207884837.png "alt=" Blob.png "src=" http://www.178linux.com/ueditor/php/upload/ Image/20150407/1428411207884837.png "/>

To find by name.

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px; border-right:0px; "title=" 1428411346701130.png "alt=" Blob.png "src=" http://www.178linux.com/ueditor/php/upload/ Image/20150407/1428411346701130.png "/>

To find by file type

The rest is not an example, ha, good good Study,day day up└ (^o^) ┘.

This article is from the "Qingxu Temple House" blog, please make sure to keep this source http://360478265.blog.51cto.com/2342533/1632725

Marco Linux Learning Query (command query and file query)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.