How to install locate command in Linux Redhat and Centos

To install the locate command (mlocate) in Redhat or Centos, use the ’YUM’ command, install function. 

  • Logon as ‘root’ or use with ‘sudo’ permissions
  • Then, run a ’man’ command to confirm that the locate command is not already installed: ‘man locate’

Example ‘man’ command (as root user)

[root@blog-server ~]# man locate

  • If the ’man’ documentation page returns, then it is already installed.  If no ’man’ documentation page is returned, then run the ‘yum install’ command.
  • Run the ‘yum install’ command as ‘root’ or ‘sudo’ user:

Example ‘yum install’ command (as root user)

[root@blog-server ~]# yum install mlocate

Example ‘yum install’ command (as sudo user)

[root@blog-server ~]# sudo yum install mlocate

Then run the [root@data-server ~]# updated

Example Run ‘updatedb’ Command (as Root user)

[root@blog-server ~]# updated

Example Run ‘updatedb’ Command (as sudo user)

[root@blog-server ~]# sudo updatedb

How To quit the Linux vi editor without saving changes

To quit the Linux ’vi’ editor without saving any changes which have been made:

To Exit the insert or append mode

  1. From within insert or append mode, press the ‘Esc‘ key.

To Enable VI Command Line

  1. Press the ‘:’ (colon) Key. The cursor should reappear in the lower-left corner of the screen beside a colon prompt.
  2. Then, Enter the ‘q!’ Command and press the ‘Enter’ Key.

Example VI Command Line

: q!

This will quit the Linux VI editor, and all changes the document made in this session will be lost.