![]() ![]() To limit file searches to a given depth, run the following query $ find -maxdepth Īs an example, here is how you can restrict files searches to the current directory, with no children directories being browsed. 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). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |