Linux s locate command returning the path of a deleted file

0 votes

I am writing a bash shell script which removes a file using the following command

rm abc.xsl

I handled the case of getting the prompts and providing the required 'y' or 'n' inputs.

In order to verify that the file has been removed, I validate the same by running the locate command in the following manner

locate */abc.xsl

Note : the desired file is present at a specific directory, so in my case this particular command is not giving me any other file's address

I noticed that despite of file being deleted, the locate command is still reflecting the deleted file's path.

I debugged the issue by manually executing each of the required commands

FYR

admin@sharad-server$ pwd
/usr/local/myserver/myapplication/lib
admin@sharad-server$ rm abc.xsl
rm: remove write-protected regular file 'abc.xsl'? y
admin@sharad-server$ locate */abc.xsl
/usr/local/myserver/myapplication/lib/abc.xsl

The file was deleted as it was not reflected when I executed the ls command and also the cat command as follows

admin@sharad-server$ cat /usr/local/myserver/myapplication/lib/abc.xsl
cat: /usr/local/myserver/myapplication/lib/abc.xsl: No such file or directory

FYR my application is deployed on GCP and my server's platform details are as follows:

admin@sharad-server$ uname -a
Linux sharad-server 3.10.0-1127.8.2.el7.x86_64 #1 SMP Tue May 12 16:57:42 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

The details of the shell where all these commands were executed in a standalone manner are as follows:

admin@sharad-server$ ps -p $$
  PID TTY          TIME CMD
32296 pts/0    00:00:00 bash

Why the locate command is still reflecting the deleted file's path?

Update:

As per one of the suggestion I tried the updatedb command as well but it gave me an error.

admin@sharad-server$ updatedb
updatedb: can not open a temporary file for `/var/lib/mlocate/mlocate.db'

Final Update:

The updatedb command worked with the root user and has successfully updated the locate command functioning.

Apr 21, 2022 in Linux Administration by Edureka
• 13,690 points
482 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Linux Administration

0 votes
1 answer

Is there a limit on the number of words in bash command 'for file in words'?

Anyway, you need to print everything except ...READ MORE

answered May 27, 2022 in Linux Administration by Korak
• 5,820 points
628 views
0 votes
2 answers

how to loop through the content of a file using bash

#!/bin/bash for i in  `cat peptides.txt` do echo $i done READ MORE

answered Sep 5, 2020 in Linux Administration by Prakash K. Aithal
2,985 views
0 votes
1 answer
0 votes
1 answer

How to check permissions of a file in the Linux system?

Hi@akhtar, If you prefer using the command line, ...READ MORE

answered Aug 13, 2020 in Linux Administration by MD
• 95,460 points
1,750 views
0 votes
0 answers

Linux Command for getting a dump of hex values bytes from Pcap File

I require a Linux command to display ...READ MORE

Apr 13, 2022 in Linux Administration by Rahul
• 9,680 points
917 views
0 votes
0 answers

Linux Command for getting a dump of hex values bytes from Pcap File

I require a linux command to display ...READ MORE

Apr 20, 2022 in Linux Administration by Edureka
• 13,690 points
618 views
0 votes
0 answers

What does "&" at the end of a linux command mean?

I am a system administrator and I ...READ MORE

Apr 21, 2022 in Linux Administration by Edureka
• 13,690 points
582 views
0 votes
0 answers

How can I convert a series of images to a PDF from the command line on linux?

I have a scanning server I wrote ...READ MORE

Apr 21, 2022 in Linux Administration by Edureka
• 13,690 points
583 views
0 votes
1 answer

Why do you need to put #!/bin/bash at the beginning of a script file?

It's a show so the *nix shell ...READ MORE

answered Jun 20, 2022 in Linux Administration by Rahul
• 3,380 points
1,152 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP