
Useful options when searching by owner are -user and -group, which search by name, and -uid and -gid, which search by ID.ġ. The find command can search for files based on their ownership or permissions. Searching Files Based on Ownership or Permission usr/share/vim/vim80/lang/zh_CN.cp936/LC_MESSAGES usr/share/vim/vim80/lang/zh_CN.UTF-8/LC_MESSAGES To search files with case-insensitive text, messages, in their names in the / directory on host, run the following command: ~]# find / -iname '*messages*' To perform a case-insensitive search for a given file name, use the -iname option, followed by the file name to search. To search for files in the /etc/ directory that contain the word, pass, anywhere in their names on host, run the following command: ~]# find /etc -name '*pass*' When using wildcards, it is important to quote the file name to look for to prevent the terminal from interpreting the wildcard In the following example, search for files starting in the / directory that end in. Wildcards are available to search for a file name and return all results that are a partial match.
Find file on linux host full#
Note: With the find command, the full word options use a single dash and options follow the path name argument, unlike most other Linux commands. For example, to search for files named sshd_config starting from the / directory, run the following command: ~]# find / -name sshd_config With this option, find returns the path to files matching FILENAME exactly. To search for files by file name, use the -name FILENAME option. If the directory argument is omitted, find starts the search in the current directory and looks for matches in any subdirectory. The first argument to the find command is the directory to search. The user invoking the find command must have read and execute permission on a directory to examine its contents. The find command looks at files in the file system using the user account that executed the search. It can also search for files based on criteria other than the file name, such as the permissions of the file, type of file, its size, or its modification time. It is slower than locate, but more accurate. The find command locates files by performing a real-time search in the file-system hierarchy. usr/share/icons/HighContrast/32x32/status/weather-snow.png usr/share/icons/HighContrast/256x256/status/weather-snow.png usr/share/icons/HighContrast/24x24/status/weather-snow.png usr/share/icons/HighContrast/22x22/status/weather-snow.png usr/share/icons/HighContrast/16x16/status/weather-snow.png The following example limits the search results returned by locate to the first five matches: ~]$ locate -n 5 snow.png The -n option limits the number of returned search results by the locate command. usr/share/vim/vim80/syntax/msmessages.vim usr/share/vim/vim80/lang/zh_TW.UTF-8/LC_MESSAGES/vim.mo usr/share/vim/vim80/lang/zh_TW.UTF-8/LC_MESSAGES usr/share/vim/vim80/lang/zh_TW/LC_MESSAGES/vim.mo usr/share/vim/vim80/lang/zh_TW/LC_MESSAGES With this option, all possible combinations of upper and lowercase letters match the search. The -i option performs a case-insensitive search. usr/lib/firewalld/services/ovirt-imageio.xml etc/selinux/targeted/contexts/virtual_image_context Results are returned even when the file name or path is only a partial match to the search query. usr/bin/gpasswd /usr/bin/grub2-mkpasswd-pbkdf2 Search for files with passwd in the name or path in directory trees readable by user on host. In order to see the resulting file name, the user must have search permission on the directory in which the file resides. The locate command restricts results for unprivileged users. However, at any time the root user can issue the updatedb command to force an immediate update. The locate database is automatically updated every day.
Find file on linux host update#
This also means that locate will not find files that have been created since the last update of the database.


However, this database is not updated in real-time, and it must be frequently updated for results to be accurate. It is fast because it looks up this information from the mlocate database. The locate command finds files based on the name or path to the file. The find command searches for files in real-time by crawling through the file-system hierarchy.The locate command searches a pre-generated index for file names or file paths and returns the results instantly.This section discusses two commands that can search for files in the file-system hierarchy. A system administrator needs tools to search for files matching certain criteria on the file system.
