본문 바로가기
Linux/Linux Shell Command

file - 파일 종류 및 속성 확인하기

by 드로니뚜벅이 2022. 4. 27.

파일시스템의 특정 파일에 대해서 파일의 종류나 파일 속성 값을 확인하기 위해 사용하는 명령어입니다.

 

형식: $ file [옵션] <파일명>

Options

Option Description
-b --brief 지정한 파일명은 출력하지 않고 파일의 유형만 출력
-f --file-from <파일목록> 파일목록에서 지정한 파일들에 대해서만 명령을 실행
-i --mime MIME 타입 문자로 출력
(예: text/plain; charset=us-ascii)
-L --dereference 심볼릭 링크된 파일을 추적하여 원본 파일 정보를 출력
-m --magic-file <매직파일> 임의로 매직파일을 지정
-z --uncompress 압축된 파일의 내용을 출력
-v --version 버전 정보를 출력

사용 예시

$ file smartgit-20_1_3.deb
smartgit-20_1_3.deb: Debian binary package (format 2.0), with control.tar.gz, data compression gz
$ file ~/.bashrc          
.bashrc: ASCII text
$ file $(which tar)
/bin/tar: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=6d12f862ac9c490023b61e89a4bcba05cbdcac9c, for GNU/Linux 3.2.0, stripped