You can find all files with permissions of exactly 775 inside the /var/www/ html directory. To filter the files based on the file / directory permissions, use the -perm option followed by permission number. – ctime n: File’s status was last changed n*24 hours ago. – cnewer file: File’s status was last changed more recently than file was modified. cmin n : File’s status was last changed n minutes ago. When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match – atime +1, a file has to have been accessed at least two days ago. – atime n: File was last accessed n*24 hours ago. – anewer: file File was last accessed more recently than file was modified. ![]() amin n: File was last accessed n minutes ago. $find /etc/dovecot/conf.d -name “*.conf” -mtime 5 The find command also allows searching files based on its last modification, access, and change time. Find a File in Linux by Modification Date For example if you want to search file greater than 100 MB then use +100 MB and for less than 100 MB use -100 MB. You can also search file with greater of less than a specified size. For example if you want to search file has 256 bytes exactly. To find the file with accurate size, you can give the size after using -size option. After -size you must define size criteria.įollowing suffix can be used to define file size You can use -size option to search file based on size. ![]() var/log/installer/initial-status.gz : ~$ Find a File in Linux by Size var/log/apt/history.log : ~$ : ~$ sudo find /var/log -type f -name *.gz var/log/unattended-upgrades/unattended-upgrades-shutdown.log The syntax would we following : ~$ sudo find /var/log -type f -name *.log log.gz extension files in my home directory. I want to have a look over all files with. home/vijay/vijay.txt : ~$ Find a File in Linux by Extension : ~$ find /home -type f -name VIJAY.txt : ~$ : ~$ find /home -type f -iname VIJAY.txt Example given below, look and compare the result. If you are searching a case sensitive file, use -iname instead of -name. To search for a file called vijay.txt in the /home/ vijay directory you would use the following command: : ~$ find /home -type f -name vijay.txt To find a file by its name by using -name expression followed by file name. The most common use of find command is finding files by name. You know the file name but forget where is it? you cand find it by using find command. $find /etc/ -type d -name passwd : ~$ find /etc -type d -name passwdįind: ‘/etc/polkit-1/localauthority’: Permission denied : ~$ : ~$ find /etc -type f -name passwdįind: ‘/etc/polkit-1/localauthority’: Permission denied : ~$ Find a File in Linux by Name If you want to search from your current directory then syntax will as followingįrom specific directory you must give the right path Specifying path is really important because if you don’t define path it will search only in current directory. If you want to search file by type then you can use the following expressions: you can use -type expression to specify file type. : ~$ find -L /etc -name passwdįind: ‘/etc/ssl/private’: Permission deniedįind: ‘/etc/polkit-1/localauthority’: Permission denied : ~$ : ~$ find -L /home/ -name vijayĪs you know, different files have different types, regular file, directory and more. Expression: -name which allow to search with given name.Path: /etc/ which allow to search entire directory as per path.Options is -L which allow to follow symbolic links. ![]() Let’s take a look at the following example: The attribute is made up of options, search patterns and actions separated by operators.If you want to search in complete system use only / or if you want to search file in etc directory path would be /etc/ ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |