본문 바로가기

Academy I/Tech Academy

[Linux]설치된 Command의 경로, 정보를 얻는 명령들

제목이 좀 이상하긴 하지만,
설치된 Command(예, ls 혹은 openssh-client 등등)의 실행 경로나 정보를 찾는 방법을 공부해 봅니다.

~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
현재의 PATH를 표시한다.

~$ which ls
/bin/ls
PATH 상에서 처음으로 발견된 파일을 찾는다.

~$ find /usr -name ls
/usr/lib/klibc/bin/ls
/usr 디렉토리 하부에 지정된 이름의 파일을 찾는다.

~$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz
첫음으로 발견된 파일과 man 문서의 경로를 표시한다.

~$ locate ls
/bin/false
/bin/ls
...
해당 이름에 대해 디렉토리 리스트를 찾아준다.

~$ apropos ls
_llseek (2)          - reposition read/write file offset
...
ls (1)               - list directory contents
...
해당 키워드에 해당되는 man 설명 부분을 나열한다.

~$ man 1 ls
해당 명령에 대해 Section 1의 내용을 표시한다.

~$ apt-cache search openssh-client
openssh-client - secure shell (SSH) client, for secure access to remote machines
ssh-askpass-gnome - interactive X program to prompt users for a passphrase for ssh-add
Package Cache 리스트에 해당 명령이나 설명을 찾아준다.

~$ dpkg-query -S openssh-client
openssh-client: /usr/share/apport/package-hooks/openssh-client.py
openssh-server: /usr/share/doc/openssh-client/examples/sshd_config
openssh-client: /usr/share/doc/openssh-client/faq.html
openssh-client, openssh-server, ssh: /usr/share/doc/openssh-client
openssh-client: /usr/share/doc/openssh-client/README.compromised-keys.gz
openssh-client: /usr/share/doc/openssh-client/changelog.gz
openssh-client: /usr/share/doc/openssh-client/README
openssh-client: /usr/share/doc/openssh-client/OVERVIEW.gz
openssh-client: /usr/share/doc/openssh-client/copyright
openssh-client: /usr/share/doc/openssh-client/README.tun.gz
openssh-client: /usr/share/doc/openssh-client/README.Debian.gz
openssh-client: /usr/share/doc/openssh-client/README.dns
openssh-client: /usr/share/doc/openssh-client/ChangeLog.gssapi
openssh-client: /usr/share/doc/openssh-client/changelog.Debian.gz
openssh-client: /usr/share/lintian/overrides/openssh-client
openssh-client: /usr/share/doc/openssh-client/NEWS.Debian.gz
openssh-server: /usr/share/doc/openssh-client/examples
해당 이름에 대해, 설치된 Package에서 찾고, 그 안에 있는 것들을 표시한다.

~$ dpkg -L openssh-client
/.
/usr
/usr/share
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/openssh-client
/usr/share/doc
/usr/share/doc/openssh-client
/usr/share/doc/openssh-client/ChangeLog.gssapi
/usr/share/doc/openssh-client/README
/usr/share/doc/openssh-client/README.dns
/usr/share/doc/openssh-client/changelog.gz
/usr/share/doc/openssh-client/faq.html
/usr/share/doc/openssh-client/README.Debian.gz
/usr/share/doc/openssh-client/changelog.Debian.gz
/usr/share/doc/openssh-client/copyright
/usr/share/doc/openssh-client/NEWS.Debian.gz
/usr/share/doc/openssh-client/OVERVIEW.gz
/usr/share/doc/openssh-client/README.tun.gz
/usr/share/doc/openssh-client/README.compromised-keys.gz
...
/var
/var/run
/etc
/etc/ssh
/etc/ssh/ssh_config
/etc/ssh/moduli
/usr/share/man/man1/slogin.1.gz
/usr/bin/slogin
지정된 이름의 Package가 포함한 파일들을 나열한다.



[출처 : http://greenfishblog.tistory.com/35]