{"id":20164,"date":"2016-11-23T07:48:20","date_gmt":"2016-11-23T13:48:20","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=20164"},"modified":"2022-06-03T03:42:31","modified_gmt":"2022-06-03T08:42:31","slug":"linux-find-file","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/linux-find-file\/","title":{"rendered":"Linux Find File"},"content":{"rendered":"
<\/p>\n
Linux find file command explained. Finding files using the command line on a Linux machine could be very uncomfortable experience, especially for the beginners. Without a GUI it is very difficult to navigate through the directories and find the files you need. In this tutorial, we will show you how to find a specific file in Linux, using the command line.<\/p>\n
<\/p>\n
The first thing your need to do is to connect to your Linux VPS via SSH<\/a>. There are two common ways to search for a file under Linux. The one way is to use the The Linux find file command<\/strong> allows you to search the directory tree using various search criteria such as name, type, ownership, size etc. This is the basic syntax:<\/p>\n Here is a brief example on how to use the Linux find command to find a specific file by its name:<\/p>\n The command will search the entire directory tree for a file named Sometimes it may take few minutes for the find command to search the entire directory tree, especially if there are many files and directories on your system. To save a significant amount of time you can specify the searching directory. For example, if you know that the There is also an option to search for a file by time, size, ownership, permissions etc. For more information about these options, you can check the Linux find file command<\/strong> man page.<\/p>\n In order to be able to use the Linux If you are using an Ubuntu VPS<\/a>, run the following commands to install locate:<\/p>\n If you are using a CentOS VPS<\/a>, run the following command to install locate:<\/p>\n Locate is a faster option to find a file since it searches for the files in a database. To update the search databases run the following command:<\/p>\n To find files in Linux with locate, use the following syntax:<\/p>\n Just like with the find command, there are many options to filter the search output. To learn more about this you can check the Linux locate command<\/strong> man page.<\/p>\n Of course, you don\u2019t have to use the Linux find file, if you use one of our Linux hosting services<\/a>, in which case you can simply ask our expert Linux admins to look and find the files on Linux for you. They are available 24\u00d77 and will take care of your request immediately. For more updates, you might want to consider reading Find Large Files in Linux<\/a>.<\/p>\n PS. If you liked this post on how to use the Linux find file command, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":" Linux find file command explained. Finding files using the command line on a Linux machine could be very uncomfortable experience, … <\/p>\nfind<\/code> command and the other way is to use the
locate<\/code> command. Let’s start with the former.<\/p>\n
1. Linux Find File Command<\/h2>\n
# find path expression search-term<\/pre>\n
# find -name test.file<\/pre>\n
test.file<\/code> and will provide you with the location. You can try using a name of a file that actually exists on your Linux VPS.<\/p>\n
test.file<\/code> is somewhere in the
\/var<\/code> directory, there is no need to search other directories. Therefore, you can use the command below:<\/p>\n
# find \/var -name test.file<\/pre>\n
# man find<\/pre>\n
2. Locate File command<\/h2>\n
locate<\/code> command, you need to install it first.<\/p>\n
# apt-get update\n# apt-get install mlocate<\/pre>\n
# yum install mlocate<\/pre>\n
# updatedb<\/pre>\n
# locate test.file<\/pre>\n
# man locate<\/pre>\n
\n