AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Find file name linux4/1/2023 ![]() However, we can restrict the number of directories recursively traveled from one directory, this is called the depth. To find files modified less than two days ago, you will run the following command $ find / -mtime -2 Find files with dynamic depthĪs you probably noticed, since the beginning of this tutorial, we are giving examples of files searches starting from the root directory.Īs a consequence, all folders are browsed recursively. To find files modified more than one week ago, you would run the following command $ find / -mtime +7 ![]() ![]() Similarly to the size option, you can append a “ plus” or a “ minus” operator to the time to look for files modified more than days ago, or less than days ago.įor example, to look for files modified exactly 3 hours ago, you would run the following command. Where time represents the files modified 24* hours ago.Īs a consequence, time is expressed in days. To search for files using find by modification date, run the following command $ find -mtime This command is very handy and used quite often by system administrators to find files or directories that have been recently modified. Using the find, you are also able to find files given a modification date, recent or not. The command just defined will find all files that are exactly 1024 Kbs in size on your host. To find files lower than 10 MBs on your system, run the following command $ find / -size -10Mįinally, to search for files that are exactly the size specified in the query, you should not append any plus or minus prefixes to the command. You can specify a “+” if you are looking for files greater than the size specified.įor example, in order to find files greater than 1 GB on your system, run the following command $ find / -size +1G The size is defined by the following prefixes : To search for files by size, use the following command $ find -size The size option allows you to search for files that are exactly the size you are specifying, greater than a specific size or lower than a specific size. $ find / -type l -name *.serviceĪnother very handy way to find and locate files on Linux is to find the find command with the size option. Parameters can be combined, for example if I am looking for all symbolic links whose filenames are ending with “.service” (to isolate all systemd services for example), I would run the following command. $ find -type įor example, if we search for all the symbolic links on the host, we would issue the following command. Knowing all those file types, you are now able to search for files by file type with the find command. c : character devices (serial ports, sound cards).b : block devices (such as a hard drive for example).Here is a recap of all the file types used on Linux. Find files using find by filetypeĪs we previously discussed in our article on hard and soft links, files are assigned file types and it is used as a way to differentiate them. I redirected the error output to /dev/null using output redirection to avoid error messages on the console. The main difference between find and locate when it comes to searching for files is that find will lookup for filenames while locate will look for paths to the file.įor example, if we go back to the runlevel example we used before, here’s how to look for runlevel files using the find command. The most common usage of the find function is to locate files given their filenames. Here are all the possibilities of the find function on Linux. ![]() Remember that for the grEP is Expression Path, and find is the opposite, so Path Expression!įind is a pretty powerful command as it has way more options than the locate command. Quick tip : do you have some trouble remembering if path or expression comes first? The first way to find and locate files on a Linux host is to use the find command.īy default, the find command is available on all distributions and it has the following syntax $ find
0 Comments
Read More
Leave a Reply. |