Linux Learning note 6 locate/slocate MV

Source: Internet
Author: User

Both the locate command and the Slocate command are used to locate files or directories.

Locate is different from find: find is to go to the hard drive, locate only in/var/lib/slocate database. This database contains all the local file information. The Linux system automatically creates this database and updates it automatically once a day, so you can't find the latest changed files using the Locate command. In order to avoid this situation, you can use the UpdateDB command before using locate, manually update the database, locate faster than find, it is not really looking, but to check the database,

[Email protected]/]# UpdateDB

[Email protected]/]#

Search all files in the ETC directory that begin with SH:
[Email protected] ~]$ locate/etc/sh

/etc/shadow

/etc/shadow-

/etc/shells

Searches all files that begin with M in the user's home directory, and ignores the case:

[Email protected] ~]$ locate-i ~/m

/home/srd/music

Find all passwd files, but show only - a

[Email protected]/]# locate-n passwd

/etc/passwd

/etc/passwd-

/etc/pam.d/passwd

/etc/security/opasswd

/home/srd/cc/python-3.5.0/lib/test/keycert.passwd.pem

/home/srd/cc/python-3.5.0/lib/test/ssl_key.passwd.pem

/lib64/security/pam_passwdqc.so

/lib64/security/pam_unix_passwd.so

/usr/bin/gpasswd

/usr/bin/htpasswd





[email protected] 2015]# LL

Total 4251356

-rw-rw-r--. 1 SRD srd 4353378304 Jan 13:52 1.iso

-rw-r--r--. 2 root root Jan 17:58 1.txt

MV can rename and move files

[[Email protected] 2015]# MV 1.iso 2.iso

[email protected] 2015]# LL

Total 4251356

-rw-r--r--. 2 root root Jan 17:58 1.txt

-rw-rw-r--. 1 SRD srd 4353378304 Jan 13:52 2.iso






RM Delete files and directories

RmDir only empty directories can be deleted



[email protected] 2015]# LL

Total 4251356

-rw-rw-r--. 1 SRD srd 4353378304 Jan 13:52 1.iso

-rw-r--r--. 2 root root Jan 17:58 1.txt

Touch modify file Time properties and create files

[email protected] 2015]# Touch test1

[email protected] 2015]# Touch test2

[email protected] 2015]# Touch test2

[email protected] 2015]# Touch test3

[email protected] 2015]# Touch test4

[email protected] 2015]# Touch TEST5

[email protected] 2015]# LL

Total 4251356

-rw-rw-r--. 1 SRD srd 4353378304 Jan 13:52 1.iso

-rw-r--r--. 2 root root Jan 17:58 1.txt

-rw-r--r--. 1 root root 0 Jan 11:17 test1

-rw-r--r--. 1 root root 0 Jan 11:17 test2

-rw-r--r--. 1 root root 0 Jan 11:17 test3

-rw-r--r--. 1 root root 0 Jan 11:17 test4

-rw-r--r--. 1 root root 0 Jan 11:17 test5

Rename renaming

[Email protected] 2015]# rename test SRD test?

[email protected] 2015]# LL

Total 4251356

-rw-rw-r--. 1 SRD srd 4353378304 Jan 13:52 1.iso

-rw-r--r--. 2 root root Jan 17:58 1.txt

-rw-r--r--. 1 root root 0 Jan 11:17 srd1

-rw-r--r--. 1 root root 0 Jan 11:17 srd2

-rw-r--r--. 1 root root 0 Jan 11:17 srd3

-rw-r--r--. 1 root root 0 Jan 11:17 srd4

-rw-r--r--. 1 root root 0 Jan 11:17 Srd5








Linux Learning note 6 locate/slocate MV

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.