리눅스 / 명령어 / which, whereis, locate / 명령어 위치 찾기

명령어의 위치를 찾을 때 사용할 수 있는 명령어에는 which, whereis, locate가 있다. 명령어의 위치만 찾을 때는 which를 사용하고, 관련된 파일들의 위치까지 찾을 때는 whereis나 locate를 사용한다.

  • which 명령어로 find 명령어를 찾는다.
# which find
/usr/bin/find
  • whereis 명령어로 find 명령어를 찾는다.
# whereis find
find: /usr/bin/find /usr/share/man/man1/find.1.gz
  • locate 명령어로 find 명령어를 찾는다.
# 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에서 검색하므로 검색 결과가 빠르게 나온다.

같은 카테고리의 다른 글
Ubuntu 20.04 / 글꼴 설치하는 방법

Ubuntu 20.04 / 글꼴 설치하는 방법

Ubuntu 20.04 Desktop 설치하려는 글꼴을 더블 클릭하거나, 글꼴 선택 후 엔터키를 누르거나, 마우스 우클릭 후 를 클릭합니다. 상단에 있는 를 클릭합니다. 설치가 완료되면 으로 바뀝니다. 글꼴이 잘 설치되었는지 확인합니다.

리눅스 / 배포판 / 수세 리눅스(SUSE Linux) - 역사, 특징, 장점

수세 리눅스의 역사 수세 리눅스(SUSE Linux)는 독일의 뉘른베르크에 본사를 두고 있는 SUSE 회사에 의해 개발된 리눅스 배포판입니다. SUSE는 "Software- und System-Entwicklung"의 약자로, "소프트웨어 및 시스템 개발"을 의미합니다. 초기 역사 SUSE 리눅스는 1992년에 설립되어, 처음에는 Slackware를 기반으로 한 리눅스 배포판을 제공했습니다. SUSE는 독일어권 지역을 중심으로 인기를 끌었으며, 이후 독자적인 리눅스 배포판을 개발하게 되었습니다. 노벨(Novell) 인수 2003년 ...

리눅스 / 배포판 / 데비안(Debian) - 역사, 특징, 장점

데비안의 역사 데비안(Debian)은 자유 소프트웨어 재단의 리눅스 배포판으로 1993년에 이안 머독(Ian Murdock)에 의해 시작되었습니다. 데비안 프로젝트는 커뮤니티 기반의 오픈 소스 프로젝트로서, 전 세계의 개발자와 기여자들이 협력하여 발전시켜 왔습니다. 데비안은 GNU 프로젝트의 일환으로 시작되었으며, 현재는 리눅스 커널뿐만 아니라 다양한 커널을 지원하는 운영체제를 제공합니다. 초기 역사 1993년 8월 16일, 이안 머독은 데비안 프로젝트를 발표했습니다. 데비안의 ...

CentOS 7 / Let’s Encrypt에서 무료 SSL 인증서 발급 받는 방법

CentOS 7 / Let’s Encrypt에서 무료 SSL 인증서 발급 받는 방법

CentOS 7에서 Let’s Encrypt 인증서를 발급 받는 방법을 요약합니다. 환경 CentOS 7 Apache Web Server 설치 저장소 추가 yum install epel-release 설치 yum install python-certbot-apache 인증서 발급 abc.com 인증서 발급 certbot --apache -d abc.com abc.com과 www.abc.com 인증서 동시 발급 certbot --apache -d abc.com -d www.abc.com 인증서 갱신 certbot renew Let’s Encrypt 인증서는 90마다 갱신해야 합니다.

Ubuntu 16.04 / 메모

PHP intl 설치 apt install php-intl service apache2 reoad APCu 설치 apt install php-apcu service apache2 reload

Rocky Linux 9 / hostname 변경하는 방법

Rocky Linux 9 / hostname 변경하는 방법

CLI 다음과 같이 명령하면 hostname을 출력한다. hostname 다음과 같이 명령하면 hostname을 rocky로 변경한다. hostnamectl set-hostname rocky GUI 의 Device Name에서 변경한다.

Ubuntu Server / 22.04 / 네트워크 세팅에 이더넷(Wired) 보이지 않을 때 해결 방법

Ubuntu Server / 22.04 / 네트워크 세팅에 이더넷(Wired) 보이지 않을 때 해결 방법

우분투 설정의 네트워크에 Wired가 보이지 않는다. 그것이 보여야 GUI로 IP 설정이 가능한데 말이다. 이를 보이게 하는 방법이 여러 가지가 있는 거 같은데, 내가 성공한 방법은... /etc/netplan/00-installer-config.yaml의 내용은 다음처럼 생겼을 것이다. # This is the network config written by 'subiquity' network: ethernets: eth0: dhcp4: true ...

리눅스 / 명령어 / scp

scp는 ssh 프로토콜을 이용하여 파일을 송수신하는 명령어이다. local → remote remote → local remote → remote 모두 가능하다. local → remote 파일 복사 # scp a.txt root@192.168.3.211:/temp/a.txt root@192.168.3.211's password: 명령어를 실행한 디렉토리에 있는 a.txt 파일을 192.168.3.211 컴퓨터에 root 계정으로 연결하여 복사한다. 원격 컴퓨터에 /temp 디렉토리가 없으면 복사되지 않는다. 원격 컴퓨터에 /temp 디렉토리가 있으면 a.txt로 복사된다. a.txt 파일이 이미 있다면 덮어쓴다. root 계정의 ...

리눅스 / 그룹 / 그룹 조회, 그룹 추가, 그룹 삭제, 그룹 수정

그룹 조회 그룹 목록은 /et/group 파일에 있습니다. cat 명령어로 전체를 조회하거나... cat /etc/group tail 명령어로 마지막 부분을 조회할 수 있습니다. # tail -n 5 /etc/group avahi:x:70: slocate:x:21: rngd:x:974: tcpdump:x:72: vboxsf:x:973: X:Y:Z 형식으로 나오는데, X는 그룹 이름, Y는 그룹 비밀번호, Z는 그룹 ID입니다. 그룹 추가 groupadd 명령으로 그룹을 추가합니다. # groupadd group-1 # tail -n 5 /etc/group slocate:x:21: rngd:x:974: tcpdump:x:72: vboxsf:x:973: group-1:x:1000: 그룹 삭제 groupdel 명령으로 그룹을 삭제합니다. # ...

CentOS 8 / DNF 사용법

CentOS 8 / DNF 사용법

DNF는 CentOS 8에 추가된 패키지 관리 명령어입니다. YUM과 사용법이 비슷합니다. 도움말 보기 dnf -h 패키지 목록 보기 dnf list 그룹 목록 보기 dnf grouplist zip 관련 패키지 검색 dnf search zip zip 패키지 정보 출력 dnf info zip Server with GUI 그룹 정보 출력 dnf groupinfo 'Server with GUI' zip 패키지 설치 dnf install zip zip 패키지 삭제 dnf remove zip httpd와 php 설치 dnf install httpd php Server ...