• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to Install and use locate command on linux

  • 00:35 touch file.txt
  • 00:44 touch File.txt
  • 00:51 locate file.txt
  • 01:06 updatedb
  • 01:17 locate file.txt
  • 01:26 locate -i file.txt
  • 01:41 locate -l 5 passwd
  • 02:07 rm -rf file.txt
  • 02:11 locate file.txt
  • 02:24 locate -e file.txt
{{postValue.id}}

Install and use locate command on Linux

The locate command is used to find files by their filename. The locate command is lightning fast because there is a background process that runs on your system that continuously finds new files and stores them in a database. This video covers the usage of locating command on Linux

Create a file by using the following command

root@linuxhelp:~# touch file.txt
root@linuxhelp:~# touch File.txt

Use the locate command to find the file.txt file, until update the DB the locate cant able to find the file

root@linuxhelp:~# locate file.txt
/usr/share/doc/alsa-base/driver/Procfile.txt.gz

Now update the DB by using the following command

root@linuxhelp:~# updatedb

Now find file.txt using locate command

root@linuxhelp:~# locate file.txt
/root/file.txt
/usr/share/doc/alsa-base/driver/Procfile.txt.gz

Use the -i option to find Case sensitivity

root@linuxhelp:~# locate -i file.txt
/root/File.txt
/root/file.txt
/usr/share/doc/alsa-base/driver/Procfile.txt.gz

Use the following command to list the particular directory using limit

root@linuxhelp:~# locate -l 5 passwd
/etc/passwd
/etc/passwd-
/etc/cron.daily/passwd
/etc/pam.d/chpasswd
/etc/pam.d/passwd

List out the file

root@linuxhelp:~# ls -la
total 55144
drwx------  4 root root     4096 Jan 12 00:22 .
drwxr-xr-x 24 root root     4096 Dec 18 00:28 ..
-rw-------  1 root root     1115 Jan 12 00:21 .bash_history
-rw-r--r--  1 root root     3106 Apr  9  2018 .bashrc
drwx------  2 root root     4096 Aug  6 00:34 .cache
-rw-r--r--  1 root root        0 Jan 12 00:22 file.txt
-rw-r--r--  1 root root        0 Jan 12 00:22 File.txt
-rw-r--r--  1 root root      148 Aug 17  2015 .profile
-r--r--r--  1 root root 56435756 Dec 18 00:59 VMwareTools-10.3.10-12406962.tar.gz
drwxr-xr-x  9 root root     4096 Feb 20  2019 vmware-tools-distrib

Remove the file.txt

root@linuxhelp:~# rm -rf file.txt

Now find the file.txt using locate command until we update the db it will show the file.txt while we use the locate command

root@linuxhelp:~# locate file.txt
/root/file.txt
/usr/share/doc/alsa-base/driver/Procfile.txt.gz

Use the following command to find the file present in the system

root@linuxhelp:~# locate -e file.txt
/usr/share/doc/alsa-base/driver/Procfile.txt.gz

This is the method to install and use locate command on Linux comes to end

Tags:
grayson
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

Can I execute the "locate" command to find any file (or) directory anywhere in the Linux system?

A

You can execute the "locate" command to find any file (or) directory anywhere in the Linux system.

Q

How to set a limit for search queries to a Specific Number of any file?

A

You can use the option of "-n" with the "locate" command to set a limit for search queries to a Specific Number of any file. For Ex: "locate "*.html" -n 20"

Q

How to display the information about the locate DB using the "locate" command?

A

You can use the option of "-S" with the "locate" command to display the information about the locate DB. For Syntax: "locate -S"

Q

How to print a number of found entries while executing the "locate" command?

A

You can use the option of "-c" with the "locate" command to print the number of found entries while executing the "locate" command. For eg: "locate -c file"

Q

Whether the "locate" command is the default package in Linux or not?

A

No. The "locate" command is not a default package in Linux. If you want to use the "locate" functionality, you should install it manually as per your Linux distro.

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Isaac ?
How to run windows application in linux

I need to run the windows application in my Linux machine, instead of installing from yum repo or any other repos. How to do that..??

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.