If you want to search for files with Linux, it works quite simply on the command line. It's up to you whether you can easily locatewith locate files or find it extremely flexible with the help of find . We've put together search tips for you in this post, all of which work on Mac OS.
So you can quickly find files in Linux by name
The query by locate is quite fast, because the search is not live in the file system, but in a database, which should be automatically updated by the system at night. If this does not happen by itself, you can create this database with the command updatedb .
If locate brings an error
In this case, most likely just the program package that includes locate is not installed .
On a Debian system, install it with the following commands and let it fill up the database:
sudo apt-get install locate
sudo updatedb
Search for large files
In contrast to locate, the find command does not use its own database, but searches live for all currently available files in a directory tree according to specific criteria such as name, type, size or age. For example, the following command gives you all the files in the / var / www folder that are more than 100 MB in size:
find /var/www -size +100M -ls
The first parameter specifies the start folder for the search. The -size + 100M part limits the results to hits larger than 100 MB in size. The -ls causes the ad not only to contain the file name, but also detailed information such as owner, size, and creation date.
You can also use two sizes to define a range. If you want to search for all files between 100 and 120 MByte, use:
find /var/www -size +100M -size -120M-ls
Find recently changed files
Also, to find files that were last modified, find help .
Write this command line:
find . -name '*.doc' -type f -mtime -1
The command looks for the current directory (that is the period) and its subdirectories for all files ending in * .doc that are less than a day old. If you want to search over all files, just omit the part name '* .doc' . The parameter -type f ensures that only files are output, not directories that fit into the schema.
If you do not just want the path and file names as answers, but a detailed list, add -ls to the end:
find . -name '*.doc' -type f -mtime -1 -ls
Responsible for these age questions is the parameter -mtime . The number behind it stands for days, so -mtime -1 for the past day, ie the last 24 hours.
Depending on the sign you control the days. Write for example
find . -name '*.doc' -type f -mtime +1
and come out all files and directories that are older than a day.
If the number is unsigned find finds files that are the specified days plus an old one. With -mtime 5 looking place so all files that have between five and six days under his belt.