Friday, July 12, 2019

Install locate command in Linux

'locate' is quite a familiar command to many of you guys to find a directory or file quickly in a linux server, and many of the set-ups would already have it installed. 

Just in case this is not available and you get a error like below, here're my findings to help you install it on your own  : 











1.Find out what linux are you using :

uname -a
lsb_release -d | awk -F"\t" '{print $2}'







In my case, it's SUSE Linux



2. If the linux platform is Ubuntu , run the below commands : 


sudo apt-get update
sudo apt-get install mlocate

The locate command builds a databse to keep a tab on all the server entries. Run this command as root user with the sudo command, otherwise you will get an error. The default database storage location is /var/lib/mlocate/mlocate.db.


sudo updatedb

you can also run this once  a month to keep the locate db updated with new file entries in server.

3. If the linux platform is CentOS,run the below commands: 

sudo yum -y update
sudo yum -y install mlocate
and create the db  :  
sudo updatedb

4. If the linux platform is SUSE,run the below commands: 

The glibc development files are in the package "glibc-devel" on openSUSE, which you could install by typing:
sudo zypper in glibc-devel
 

sudo zypper in findutils-locate
sudo updatedb

Here're my outputs from the server  : 

user@server:/> sudo zypper in glibc-devel
Refreshing service 'spacewalk'.
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following package is going to be upgraded:
  glibc-devel

1 package to upgrade.
Overall download size: 4.9 MiB. After the operation, additional 264.0 KiB will be used.
Continue? [y/n/?] (y): y
Retrieving package glibc-devel-2.11.3-17.84.1.x86_64 (1/1), 4.9 MiB (31.2 MiB unpacked)
Retrieving: glibc-devel-2.11.3-17.84.1.x86_64.rpm [done]
Installing: glibc-devel-2.11.3-17.84.1 [done]

user@server:/> sudo zypper in findutils-locate
Refreshing service 'spacewalk'.
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following NEW package is going to be installed:
findutils-locate

1 new package to install.
Overall download size: 57.0 KiB. After the operation, additional 140.0 KiB will be used.
Continue? [y/n/?] (y): y
Retrieving package findutils-locate-4.4.0-38.26.1.x86_64 (1/1), 57.0 KiB (140.0 KiB unpacked)
Retrieving: findutils-locate-4.4.0-38.26.1.x86_64.rpm [done]
Installing: findutils-locate-4.4.0-38.26.1 [done]
Additional rpm output:
Updating etc/sysconfig/locate...

user@server:/> sudo updatedb

As always, thanks for reading ! 

No comments:

Post a Comment