Friday, May 24, 2024

How to use find, locate, which, whereis, whatis and grep commands in Linux

Date:

The first hurdle Linux users face is searching and locating files. Some users may not know how to use each of the following six search commands in Linux, locate, which, whereis, whatis, and grep. The methods differ from others in its results. Because each command is concerned with searching in a specific field and in a specific situation, so you must know how to use all the search commands in Linux, the website we will show you in this article.

search command Find out

The Find command in Linux is used to search directories and files and perform several sequential operations by folder, file, modified date, folder, owner, navigating through files in a pyramid-like fashion. , creation date or name and command are entered according to the following method:

How to Use Search Commands in Linux

Tools used in the Find command

  • Perm Octal: If the declaration is octal, this option is used in the search of the file
  • Links: Used to search for files with N attachment
  • Blank: Enables searching for empty paths and files.
  • Name Demo: It is used to search for classified files with the demo command
  • user Name: Contributes to searching files related to ID number or username.
  • :(expr) True ifexpr is true, and is used for grouping in addition to the OR or AND suffixes
  • EXPERIENCE!: Expert lies are true.
  • New file: This option searches for files created or modified in a file.
  • Imma n: Searches for files with N attachment
  • Size + N/ -N: It is used to scale files of type N followed by C followed by size.
  • – violated CMD: Uses the file you want to search for as the previous method, like the exit option on successful completion of the command.
  • ok CMD: This option remains the same as before, with the username changed and added first.
See also  NASA is developing devices to produce oxygen on Mars after its first successful test

Use the Locate command

Install the detect command function

The locate command is faster than find because it does not rely on the file’s own database, and the locate command functionality is not installed on all versions of Linux. To do this, you can install it by typing the following commands:

  • Type susdi apt-get update and press enter
  • On Debian and Ubuntu, type sudo apt-get install mlocate and hit enter
  • On Arch Linux, using the Pacman cluster manager, type pacman -s mlocate
  • Type emermerm , emermmogate in the Condo app

Update location

  • The locate command cannot find anything if there is no database.
  • But this can happen manually or automatically by adding susdo updated and then pressing the Enter option

Use the find command

  • The Find command is fast, but it’s a shame it doesn’t have the options found in the Find command, so you can just type “locate-i.jpg” and search for files. in jpg format.
  • * -I is completely ignored as with the Find command if it performs the same function as the Find command.

Limit search results

  • Multiple search results can be collapsed with the -n option to show results like “*.jpg -I – 20 -n locate”.
  • Then the first 20 search results are displayed with the locate command.

Use any command

  • By using the which command, you can search the directories found in the user’s path and specify the scope of the command you want to search for, as well as specify the version of the command or program. The name is written in the command field.
  • If you want to search for a specific command or program like Geoloc; It must be in a certain place in the path, and as soon as its name is written, it is immediately executed; So you can use any search command to specify its location via any geolog and then click enter button
See also  Apple enhances mail usage for iPhone, iPad and Mac with Gmail features
Use search commands in Linux

Use the whereis command

  • The whereis command is very similar to the which command, but is more detailed In addition to the program file or command location, the whereis command manually returns data for the location of files and source codes; Most likely, you will not find these files on the computer, but if they are, where will they be displayed?
  • The word package usually refers to page files and command source code. type thereis diff and it will display the location of the diff files and their supporting document file, to narrow down the results, only the location of the supporting document will be displayed; Use the -b option by typing whereis -b diff
  • You must rely on the -m command to narrow down the search results to only display pages, and you must use the -s option to display source code files and find out what range the search command searches. , you can use command -1

Use the whatis search command

  • The whatis command is one of the search commands used in Linux and is characterized by displaying search results quickly through manual pages as it displays short results in one line about the command to be searched for.
  • If you use the whatis command, you will see two descriptions for the same result, a short description and a detailed description. To enter a directory in the description section, use the man command with the addition of man 1 man.
  • Whatis -s “7” man can rely on the -s option to narrow search results to the section corresponding to the directory, and results that refer to directory section 7 will be displayed.
See also  Windows 11 warns that updates to unsupported systems have no "rights"

Use the grep search command

  • The grep search command is used to search a specific text or a specific file for lines that contain links to selected words, as the grep command displays similar lines.
  • Files with a username like harvy can be searched with the grep command; Then type:
    • grep -1 “harvy” /etc/passwd
  • When searching for a specific phrase or word and want to ignore the secondary order, the -w option should be used.
  • A command line in Linux is a program or tool that is used to interact with the computer through a set of options that differ from one tool to another based on their usage and purposes.
  • Search commands in Linux are used to perform necessary operations without requiring RAM.

Finally, we learned in detail how to use find, locate, which, whereis, whatis and grep commands in Linux.

Stuart Wagner
Stuart Wagner
"Professional coffee fan. Total beer nerd. Hardcore reader. Alcohol fanatic. Evil twitter buff. Friendly tv scholar."

Share post:

Popular

More like this
Related

Cost-effective drilling: how to reduce operational expenses by smart equipment choices

Drilling costs affect the profitability and sustainability of oil...

Navigating the World of Cryptocurrencies: How to Choose the Best Crypto Wallet

In the digital age where cryptocurrencies are rapidly gaining...

Unlock the easiest way to get EU citizenship of Slovenia and Romania with Union Permits

Due to the nature of their immigration programs, Slovenia...

The Ultimate Guide to Men’s Facials in Dubai

In the bustling city of Dubai, where the sun...