Fedora Linux search locate find file



   The command example below show how to search or find file on Linux system... there is many way to find file on the Linux system... but on this example we use find command and locate command to find file on our Linux Fedora 15 system.

Use find command to find file
Execute find command and the name of file that you want to search or find on the system... please note that in this example the file name is sshd.service
[root@localhost ~]# find / -name sshd.service

find: `/proc/3031/task/3031/ns/net': No such file or directory
find: `/proc/3031/task/3031/ns/uts': No such file or directory
find: `/proc/3031/task/3031/ns/ipc': No such file or directory
find: `/proc/3031/ns/net': No such file or directory
find: `/proc/3031/ns/uts': No such file or directory
find: `/proc/3031/ns/ipc': No such file or directory
find: `/proc/4496/task/4496/ns/net': No such file or directory
find: `/proc/4496/task/4496/ns/uts': No such file or directory
find: `/proc/4496/task/4496/ns/ipc': No such file or directory
find: `/proc/4496/ns/net': No such file or directory
find: `/proc/4496/ns/uts': No such file or directory
find: `/proc/4496/ns/ipc': No such file or directory
find: `/proc/4628/task/4628/ns/net': No such file or directory
find: `/proc/4628/task/4628/ns/uts': No such file or directory
find: `/proc/4628/task/4628/ns/ipc': No such file or directory
find: `/proc/4628/ns/net': No such file or directory
find: `/proc/4628/ns/uts': No such file or directory
find: `/proc/4628/ns/ipc': No such file or directory
/sys/fs/cgroup/cpu/system/sshd.service
/sys/fs/cgroup/systemd/system/sshd.service
find: `/home/jason/.gvfs': Permission denied
[root@localhost ~]# 


Find file with locate command
locate command suppose give you the result mush faster then find command because the locate command search and use database that run on cron.  the only disadvantages, locate cannot find newly created file before the locate database updated.  the command locate example below use to search for sshd file
[root@localhost ~]# locate -b '\sshd*'

/etc/pam.d/sshd
/etc/rc.d/init.d/sshd
/etc/ssh/sshd_config
/usr/lib/fipscheck/sshd.hmac
/usr/sbin/sshd
/usr/share/augeas/lenses/dist/sshd.aug
/usr/share/man/man5/sshd_config.5.gz
/usr/share/man/man8/sshd.8.gz
/usr/share/setroubleshoot/plugins/sshd_root.py
/usr/share/setroubleshoot/plugins/sshd_root.pyc
/usr/share/setroubleshoot/plugins/sshd_root.pyo
/usr/share/vim/vim73/syntax/sshdconfig.vim
/var/empty/sshd
[root@localhost ~]# 



0 comments: