리눅스 / 명령어 / 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 18.04 Server / apt / 패키지 설치, 삭제, 업그레이드하는 명령어

Ubuntu에서 패키지를 관리하는 명령어는 여러 가지가 있습니다. 그 중 널리 사용되는 것은 apt-get과 apt입니다. 아래는 apt를 이용하여 패키지를 설치하고 삭제하고 업그레이드하는 방법입니다. 대부분의 경우 apt-get을 사용해도 작동합니다. APT 사용법 패키지 목록을 갱신합니다 # apt update 모든 패키지를 최신 버전으로 업그레이드합니다. # apt upgrade abc 패키지를 설치합니다. 의존성있는 패키지도 함께 설치합니다. # apt install abc abc 패키지를 삭제합니다. 설정 ...

CentOS 7 / Apache, PHP, MariaDB 설치하는 방법

CentOS 7 / Apache, PHP, MariaDB 설치하는 방법

CentOS에 Apache, PHP, MariaDB를 설치하는 방법을 간략히 정리합니다. APM 설치 Apache, PHP, MariaDB을 설치합니다. yum install httpd php mariadb-server php-mysql 서비스 설정 Apache가 부팅 시 자동으로 시작되도록 합니다. systemctl enable httpd.service MariaDB가 부팅 시 자동으로 시작되도록 합니다. systemctl enable mariadb.service Apache를 시작합니다. systemctl start httpd.service MariaDB를 시작합니다. systemctl start mariadb.service 방화벽 설정 http로 접속할 수 있도록 포트를 열어줍니다. firewall-cmd --permanent --add-service=http https로 접속할 수 있도록 포트를 ...

Ubuntu 24.04 / 언어 변경하는 방법

현재 언어 확인하기 locale 명령어로 현재 언어를 확인할 수 있다. # locale LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL= 언어 추가하기 사용 가능한 언어는 locale -a로 확인할 수 있다. # locale -a C C.utf8 en_US.utf8 POSIX 예를 들어 한국어를 추가하고 싶다면 아래와 같이 명령한다. # apt install language-pack-ko locale -a로 설치 확인을 한다. # locale -a C C.utf8 en_US.utf8 ko_KR.utf8 POSIX 언어 변경하기 다음과 같이 명령하면 사용하는 언어가 한국어로 바뀐다. update-locale LANG=ko_KR.utf8 로그아웃 후 다시 로그인하거나, 컴퓨터를 다시 시작하면 ...

Rocky Linux 8 / 원격 데스크톱으로 연결하는 방법

Rocky Linux 8 / 원격 데스크톱으로 연결하는 방법

패키지 설치 다음과 같이 명령하여 EPEL(Extra Packages of Enterprise Linux) 저장소를 추가한다. dnf install epel-release xrdp 패키지를 설치한다. dnf install xrdp 방화벽 설정 원격 데스크톱이 사용하는 포트는 3389이다. firewall-cmd로 3389 포트를 열어준다. firewall-cmd --permanent --add-port=3389/tcp 방화벽을 다시 로드한다. firewall-cmd --reload 서비스 설정 systemctl 명령어로 xrdp 서비스를 시작한다. systemctl start xrdp 시스템 재부팅 후에도 자동으로 실행되게 하려면 다음과 같이 명령한다. systemctl enable xrdp 재부팅 위와 같이 했을 때 원격 ...

Ubuntu 16.04 Server / 고정 IP 설정하는 방법

네트워크 설정 파일은 /etc/network/interfaces이다. 우분투를 DHCP로 설치했다면 설정 파일의 내용은 다음과 비슷하게 되어 있다. # The primary network interface auto enp0s3 iface enp0s3 inet dhcp 이를 다음처럼 변경하고 저장한다. xxx.xxx.xxx.xxx는 네트워크 환경에 맞게 수정한다. # The primary network interface auto enp0s3 iface enp0s3 inet static address xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx gateway xxx.xxx.xxx.xxx dns-nameservers xxx.xxx.xxx.xxx 다음과 같이 명령하여 네트워크를 재시작한다. systemctl restart networking.service 만약 위와 같이 해도 ...

CentOS 7 / SSH / 포트 변경하는 방법

CentOS 7 / SSH / 포트 변경하는 방법

리눅스 서버에 SSH 접속을 하는 공격이 있습니다. SSH Brute Force라고 하는데, 여러 아이디와 비밀번호로 로그인을 시도하는 공격입니다. 이 공격을 방어하는 방법은 여러가지가 있습니다. root 계정으로 로그인 못하게 하기 암호를 복잡하게 만들기 접속 가능 IP를 정하기 SSH 포트 번호 바꾸기 이 중에서 SSH 포트 번호 바꾸는 방법을 정리해보겠습니다. CentOS 7 기준이며, 포트 번호를 1980으로 바꾼다고 가정하겠습니다. SSH 설정 파일 ...

Rocky Linux 8 / DNF 사용법

Rocky Linux 8 / DNF 사용법

dnf는 패키지를 관리하는 명령어이다. 도움말 도움말 보기 # 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 httpd와 php 설치 # dnf install httpd php Server ...

Ubuntu 18.04 Server / 설치하기

Ubuntu 18.04 Server / 설치하기

다운로드 Ubuntu Server 다운로드 페이지는 다음과 같다. https://ubuntu.com/download/server 최신 버전에 대한 안내가 주로 있으므로, 구버전을 다운로드하고 싶다면 아래 링크가 편하다. https://mirror.kakao.com/ubuntu-releases/ 가상 머신에 설치한다면 다운로드한 ISO 파일을 그대로 사용하면 되고, 물리 서버에 설치한다면 Rufus 같은 툴을 이용하여 부팅 USB를 만든다. 설치 설치 미디어로 부탕하고 잠시 기다리면 언어를 선택하는 화면이 나온다. 원하는 언어를 선택하고 엔터키를 누른다. 키보드 레이아웃을 정하고 ...

CentOS / 버전 확인하는 방법

CentOS / 버전 확인하는 방법

cat /etc/redhat-release # cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) cat /etc/*release* # cat /etc/*release* CentOS Linux release 7.4.1708 (Core) Derived from Red Hat Enterprise Linux 7.4 (Source) NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:7" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7" CentOS Linux release 7.4.1708 (Core) CentOS Linux release 7.4.1708 (Core) cpe:/o:centos:centos:7

Ubuntu 18.04 Server / phpMyAdmin 설치하는 방법

Ubuntu 18.04 Server / phpMyAdmin 설치하는 방법

phpMyAdmin은 MySQL, MariaDB를 웹브라우저에서 관리할 수 있게 해주는 소프트웨어입니다. Ubuntu 18.04에 phpMyAdmin을 설치하고 설정하는 방법을 알아보겠습니다. 설치 apt install phpmyadmin 설치하는 과정에서 몇 가지 질문을 합니다. 사용하는 웹서버를 선택합니다. 비밀번호를 정하고... 다시 한 번 입력합니다. Yes를 선택하고 진행하면 설치가 끝납니다. 접속 웹브라우저로 서버 주소에 phpmyadmin을 붙여서 접속합니다. MySQL 또는 MariaDB의 사용자명과 암호를 입력해서 로그인하는데... root 계정으로 접속이 불가능할 수도 있습니다. 만약 root으로 ...