리눅스
[명령어] which, whereis, locate 명령어
변군이글루
2020. 12. 18. 17:42
반응형
which, whereis, locate 명령어
- 명령어 위치을 찾는 명령어
which 명령어
: 명령의 전체 경로를 보여준다
$ which ls
alias ls='ls --color=auto'
/usr/bin/ls
$ which ifconfig
/usr/sbin/ifconfig
whereis 명령어
: 명령의 실행파일, 소스, 매뉴얼 페이지가 어디 있는지 보여준다.
$ whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz
$ whereis ifconfig
ifconfig: /usr/sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz
###실행 파일만 찾는다
$ whereis -b ls
ls: /usr/bin/ls
###매뉴얼 페이지만 찾는다
$ whereis -m ls
ls: /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz
###소스만 찾는다
$ whereis -s ls
locate(mlocate) 명령어
: 이름으로 파일을 찾기
: 데이터베이스화로 되어 있는 목록에서 파일 검색, 데이터베이스가 업데이트되기 전에 검색하면 삭제된 파일도 검색된다.(최신 상태에서 검색하고자 하면 updatedb 명령어를 실행하고 검색하면 된다.)
mlocate(locate) 패키지 설치
$ yum install -y mlocate
locate 명령어 실행
locate [filename]
$ locate ifconfig
/usr/libexec/hypervkvpd/hv_set_ifconfig
/usr/sbin/ifconfig
/usr/share/man/de/man8/ifconfig.8.gz
/usr/share/man/fr/man8/ifconfig.8.gz
/usr/share/man/man8/ifconfig.8.gz
/usr/share/man/pt/man8/ifconfig.8.gz
###
$ locate -n 3 ifconfig
/usr/libexec/hypervkvpd/hv_set_ifconfig
/usr/sbin/ifconfig
/usr/share/man/de/man8/ifconfig.8.gz
updatedb
: locate(mlocate)를 파일 이름 업데이트를 위한 데이터베이스
$ updatedb
The Linux man-pages project
https://www.kernel.org/doc/man-pages
The Linux man-pages project
www.kernel.org
728x90
반응형