The locate command builds a database of files on the system, so searches tend to be faster. The -exec command allows you to execute an action against all of the files that are output from the find command.įind a file named file1 and change permissions to 644:įind / -name “file1” -exec chmod 664 How to Use the Locate Command On LinuxĪn alternative to the find command is the locate command. In order to find a file that is exactly 1GB in size, simply type in the phrase:įind / -size -1G Performing Actions based on Find Output SImply use the -size flag with the following size conventions: This will list all files with 755 permissions:įind can filter files based on their size. We can even find files based on permissions. The -user and -group flags can be used to find a file located by a specific user or groupįind all files owned by group “mc” with the case sensitive name “mirrorlist.txt” Let’s find a file modified more than 5 days ago:įind / -mmin +25 Finding Files by User or Group You can find files based on access time (-atime), modified time (-mtime), and change time (-ctime) flags. In order to find a regular file called “file1” use:įind -type f -name “file1” Finding Files by Time If you want to search for files by type, you can do so with the following command: This will return all files that don’t contain the string “file” in them, and is applicable to other strings. What if we only want to return files with names that don’t contain a certain string? Then we will use: This search will return both uppercase and lowercase results: If we want to run a case insensitive search, we can do this: This is a case sensitive search, so it returned just one file: In order to find a file by name, simply type: This will open the handy “find” manual page for you. If you are ever lost, just type the phrase: See Also: (Live Webinar) Meet ServerMania: Transform Your Server Hosting Experience How to Use the Find Command On Linux Getting StartedĪlways remember that Linux has your back! There is a handy manual page for every command. The directory contains each of the following files: We’re going to navigate into a directory with the following files in order to demonstrate what will be returned when various commands are used. This article will walk you through how to locate files on Linux using the find and locate commands. Linux file navigation may seem daunting at first, but it’s quite easy once you know the right commands to use.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |