Linux - 디렉토리 용량 확인

터미널에서 디렉토리(폴더) 용량 확인 방법을 소개합니다.

1. du -sh

다음 명령어는 파일을 제외한 디렉토리의 크기만 출력합니다.

$ du -sh static
11M	static

옵션에 대한 설명은 다음과 같습니다.

  • -s : 파일을 제외한 디렉토리 크기만 출력
  • -h : 사람이 읽기 편한 용량 단위로 출력

-h 대신에 다음 명령어로 출력되는 단위를 변경할 수 있습니다.

  • -k : KB로 출력
  • -m : MB로 출력
$ du -sm static
11	static

$ du -sk static
10492	static

du -h

파일과 디렉토리 용량이 모두 출력되고, 크기는 읽기 편한 단위로 출력

$ du -h static
2.1M	static/posts/android-jetpack-paging
7.0M	static/posts/android-adaptive-icon
516K	static/posts/autosizing-textviews
9.6M	static/posts
8.0K	static/assets/js
152K	static/assets/old-icon
152K	static/assets/icon
420K	static/assets/css
736K	static/assets
11M	static

du -s

파일을 제외한 디렉토리의 용량만 출력, 단위는 KB

$ du -s static
10492	static

2. du -h --max-depth=

--max-depth=1는 디렉토리의 파일 용량을 모두 출력할 때, 하위 1개 depth에 해당하는 파일들만 출력하라는 명령어입니다.

아래와 같이 static 폴더의 하위 1개 디렉토리까지만 출력되었습니다.

$ du -h static --max-depth=1
9.6M	static/posts
736K	static/assets
11M	static

--max-depth=<depth> 옵션으로 depth를 조절할 수 있습니다.

Loading script...

Related Posts

codechachaCopyright ©2019 codechacha