명령어의 위치를 찾을 때 사용할 수 있는 명령어에는 which, whereis, locate가 있습니다.
명령어의 위치만 찾을 때는 which를 사용하고, 관련된 파일들의 위치까지 찾을 때는 whereis나 locate를 사용합니다.
각 명령어로 find 명령어를 찾아보겠습니다.
[root@localhost ~]# which find
/usr/bin/find
[root@localhost ~]# whereis find
find: /usr/bin/find /usr/share/man/man1/find.1.gz
[root@localhost ~]# locate find
/usr/bin/find
/usr/bin/find2perl
/usr/bin/findmnt
/usr/bin/nl-link-ifindex2name
/usr/bin/nl-link-name2ifindex
/usr/bin/oldfind
/usr/lib64/python2.7/modulefinder.py
/usr/lib64/python2.7/modulefinder.pyc
/usr/lib64/python2.7/modulefinder.pyo
/usr/sbin/btrfs-find-root
/usr/sbin/findfs
/usr/share/bash-completion/completions/findmnt
/usr/share/doc/findutils-4.5.11
/usr/share/doc/findutils-4.5.11/AUTHORS
/usr/share/doc/findutils-4.5.11/COPYING
/usr/share/doc/findutils-4.5.11/ChangeLog
/usr/share/doc/findutils-4.5.11/NEWS
/usr/share/doc/findutils-4.5.11/README
/usr/share/doc/findutils-4.5.11/THANKS
/usr/share/doc/findutils-4.5.11/TODO
/usr/share/doc/wpa_supplicant-2.6/examples/p2p/p2p_find.py
/usr/share/doc/wpa_supplicant-2.6/examples/p2p/p2p_stop_find.py
/usr/share/info/find-maint.info.gz
/usr/share/info/find.info.gz
/usr/share/locale/be/LC_MESSAGES/findutils.mo
/usr/share/locale/bg/LC_MESSAGES/findutils.mo
/usr/share/locale/ca/LC_MESSAGES/findutils.mo
/usr/share/locale/cs/LC_MESSAGES/findutils.mo
/usr/share/locale/da/LC_MESSAGES/findutils.mo
/usr/share/locale/de/LC_MESSAGES/findutils.mo
/usr/share/locale/el/LC_MESSAGES/findutils.mo
/usr/share/locale/eo/LC_MESSAGES/findutils.mo
/usr/share/locale/es/LC_MESSAGES/findutils.mo
/usr/share/locale/et/LC_MESSAGES/findutils.mo
/usr/share/locale/fi/LC_MESSAGES/findutils.mo
/usr/share/locale/fr/LC_MESSAGES/findutils.mo
/usr/share/locale/ga/LC_MESSAGES/findutils.mo
/usr/share/locale/gl/LC_MESSAGES/findutils.mo
/usr/share/locale/hr/LC_MESSAGES/findutils.mo
/usr/share/locale/hu/LC_MESSAGES/findutils.mo
/usr/share/locale/id/LC_MESSAGES/findutils.mo
/usr/share/locale/it/LC_MESSAGES/findutils.mo
/usr/share/locale/ja/LC_MESSAGES/findutils.mo
/usr/share/locale/ko/LC_MESSAGES/findutils.mo
/usr/share/locale/lg/LC_MESSAGES/findutils.mo
/usr/share/locale/lt/LC_MESSAGES/findutils.mo
/usr/share/locale/ms/LC_MESSAGES/findutils.mo
/usr/share/locale/nl/LC_MESSAGES/findutils.mo
/usr/share/locale/pl/LC_MESSAGES/findutils.mo
/usr/share/locale/pt/LC_MESSAGES/findutils.mo
/usr/share/locale/pt_BR/LC_MESSAGES/findutils.mo
/usr/share/locale/ro/LC_MESSAGES/findutils.mo
/usr/share/locale/ru/LC_MESSAGES/findutils.mo
/usr/share/locale/rw/LC_MESSAGES/findutils.mo
/usr/share/locale/sk/LC_MESSAGES/findutils.mo
/usr/share/locale/sl/LC_MESSAGES/findutils.mo
/usr/share/locale/sr/LC_MESSAGES/findutils.mo
/usr/share/locale/sv/LC_MESSAGES/findutils.mo
/usr/share/locale/tr/LC_MESSAGES/findutils.mo
/usr/share/locale/uk/LC_MESSAGES/findutils.mo
/usr/share/locale/vi/LC_MESSAGES/findutils.mo
/usr/share/locale/zh_CN/LC_MESSAGES/findutils.mo
/usr/share/locale/zh_TW/LC_MESSAGES/findutils.mo
/usr/share/man/man1/find.1.gz
/usr/share/man/man1/find2perl.1.gz
/usr/share/man/man1/oldfind.1.gz
/usr/share/man/man8/btrfs-find-root.8.gz
/usr/share/man/man8/findfs.8.gz
/usr/share/man/man8/findmnt.8.gz
locate 명령어는 -n 옵션으로 출력 개수를 정할 수 있습니다.
[root@localhost ~]# locate find -n 10
/usr/bin/find
/usr/bin/find2perl
/usr/bin/findmnt
/usr/bin/nl-link-ifindex2name
/usr/bin/nl-link-name2ifindex
/usr/bin/oldfind
/usr/lib64/python2.7/modulefinder.py
/usr/lib64/python2.7/modulefinder.pyc
/usr/lib64/python2.7/modulefinder.pyo
/usr/sbin/btrfs-find-root
locate 명령어의 경우 설치가 필요할 수도 있습니다. CentOS라면 다음과 같이 명령하여 설치합니다.
yum install mlocate
사용 전에 DB를 업데이트해야 합니다.
updatedb
DB에서 검색하므로 검색 결과를 빠르게 나옵니다.
'OS > Linux' 카테고리의 다른 글
AWS EC2 우분투(Ubuntu) 서버 - 타임존(Timezone) 한국시간설정 (0) | 2021.02.14 |
---|---|
AWS - EC2 인스턴스 FileZilla(sftp)로 접속하기 (0) | 2021.02.07 |
리눅스 파일 찾기, 파일속 문자열 찾기 (0) | 2021.01.11 |
리눅스 명령어 (0) | 2020.12.02 |
/etc/group 사용자 그룹에 추가 (0) | 2020.09.18 |
댓글