Linux에서 파일 및 디렉터리의 디스크 사용량을 찾는 방법
Linux 'du'(디스크 사용량)은 시스템에 있는 파일 및 디렉터리의 디스크 사용량 정보를 확인하는 데 사용되는 표준 Unix/Linux 명령입니다.
du 명령에는 다양한 형식의 결과를 얻는 데 사용할 수 있는 많은 매개변수 옵션이 있습니다. du 명령은 또한 재귀적인 방식으로 파일과 디렉터리 크기를 표시합니다.
이 문서에서는 Linux에서 파일 및 디렉터리의 크기를 결정하는 데 도움이 되는 유용한 'du' 명령을 예제와 함께 설명합니다. 이 문서에 제공된 정보는 'du' 명령의 매뉴얼 페이지에서 가져온 것입니다.
Linux에서 디렉토리 크기를 찾는 방법
1. 디렉토리 트리 '/home/tecmint' 및 해당 하위 디렉토리에 대한 디스크 사용량 요약을 얻으려면 다음 명령을 사용하십시오.
du /home/tecmint
4 /home/tecmint/bin
4 /home/tecmint/.ffbinaries-cache
672 /home/tecmint/.openjfx/cache/17.0.3-ea
676 /home/tecmint/.openjfx/cache
680 /home/tecmint/.openjfx
36 /home/tecmint/.ssh
92 /home/tecmint/.config/xfce4/xfconf/xfce-perchannel-xml
96 /home/tecmint/.config/xfce4/xfconf
12 /home/tecmint/.config/xfce4/desktop
...
56758808 /home/tecmint
위 명령의 출력에는 하위 디렉토리와 함께 /home/tecmint 디렉토리에 있는 디스크 블록 수가 표시됩니다.
사람이 읽을 수 있는 형식으로 디렉터리 크기를 찾는 방법
2. 'du' 명령과 함께 '-h'
옵션을 사용하면 '사람이 읽을 수 있는 형식으로 결과를 얻을 수 있습니다. 형식'을 사용하면 바이트, 킬로바이트, 메가바이트, 기가바이트 등과 같은 단위로 크기를 볼 수 있습니다.
du -h /home/tecmint
4.0K /home/tecmint/bin
4.0K /home/tecmint/.ffbinaries-cache
672K /home/tecmint/.openjfx/cache/17.0.3-ea
676K /home/tecmint/.openjfx/cache
680K /home/tecmint/.openjfx
36K /home/tecmint/.ssh
92K /home/tecmint/.config/xfce4/xfconf/xfce-perchannel-xml
96K /home/tecmint/.config/xfce4/xfconf
12K /home/tecmint/.config/xfce4/desktop
...
55G /home/tecmint
Linux에서 디렉토리의 전체 크기를 찾는 방법
3. 디렉토리의 총 디스크 사용량 요약을 얻으려면 다음과 같이 '-s'
옵션을 사용하십시오.
du -sh /home/tecmint
55G /home/tecmint
4. 'du' 명령과 함께 '-a'
플래그를 활용하면 모든 파일과 디렉터리의 디스크 사용량이 표시됩니다.
du -a /home/tecmint
4 /home/tecmint/fix-deb-src-error-ubuntu
4 /home/tecmint/tecmint.py
0 /home/tecmint/bin/FoxitReader
4 /home/tecmint/bin
4 /home/tecmint/.ffbinaries-cache
52 /home/tecmint/Eclipse-with-PyDev.jpg
300 /home/tecmint/Screenshot from 2023-07-27 14-02-45.png
16 /home/tecmint/.openjfx/cache/17.0.3-ea/libglass.so
28 /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font_pango.so
20 /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font.so
64 /home/tecmint/.openjfx/cache/17.0.3-ea/libprism_es2.so
512 /home/tecmint/.openjfx/cache/17.0.3-ea/libglassgtk3.so
...
56759528 /home/tecmint
5. '-h'
와 함께 '-a'
플래그를 사용하면 모든 파일과 폴더의 디스크 사용량이 사람이 읽을 수 있는 형식으로 표시됩니다. 체재. 결과 출력은 파일 크기를 킬로바이트, 메가바이트 등과 같은 단위로 표시하므로 이해하기가 더 쉽습니다.
du -ah /home/tecmint
4.0K /home/tecmint/fix-deb-src-error-ubuntu
4.0K /home/tecmint/tecmint.py
28K /home/tecmint/download.php?file=%2Foomph%2Fepp%2F2023-06%2FR%2Feclipse-inst-jre-linux64.tar.gz.1
0 /home/tecmint/bin/FoxitReader
4.0K /home/tecmint/bin
4.0K /home/tecmint/.ffbinaries-cache
52K /home/tecmint/Eclipse-with-PyDev.jpg
300K /home/tecmint/Screenshot from 2023-07-27 14-02-45.png
16K /home/tecmint/.openjfx/cache/17.0.3-ea/libglass.so
28K /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font_pango.so
20K /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font.so
64K /home/tecmint/.openjfx/cache/17.0.3-ea/libprism_es2.so
512K /home/tecmint/.openjfx/cache/17.0.3-ea/libglassgtk3.so
...
55G /home/tecmint
6. 킬로바이트 블록 단위로 디렉토리 트리와 해당 하위 디렉토리의 디스크 사용량을 확인하려면 '-k'
옵션을 활용하세요(크기는 다음 단위로 표시됨). 1024바이트 단위).
du -k /home/tecmint
4 /home/tecmint/bin
4 /home/tecmint/.ffbinaries-cache
672 /home/tecmint/.openjfx/cache/17.0.3-ea
676 /home/tecmint/.openjfx/cache
680 /home/tecmint/.openjfx
8 /home/tecmint/.uk.co.screamingfrog.seospider.ui.b/webview
12 /home/tecmint/.uk.co.screamingfrog.seospider.ui.b
36 /home/tecmint/.ssh
92 /home/tecmint/.config/xfce4/xfconf/xfce-perchannel-xml
96 /home/tecmint/.config/xfce4/xfconf
12 /home/tecmint/.config/xfce4/desktop
4 /home/tecmint/.config/xfce4/xfwm4
8 /home/tecmint/.config/xfce4/panel/launcher-18
8 /home/tecmint/.config/xfce4/panel/launcher-17
8 /home/tecmint/.config/xfce4/panel/launcher-14
8 /home/tecmint/.config/xfce4/panel/launcher-3
8 /home/tecmint/.config/xfce4/panel/launcher-16
8 /home/tecmint/.config/xfce4/panel/launcher-5
...
56769128 /home/tecmint
7. 하위 디렉토리를 포함한 디렉토리 트리의 디스크 사용량 요약을 메가바이트(MB) 단위로 얻으려면 '-mh'
를 사용하세요. 옵션은 다음과 같습니다. '-m'
플래그는 블록 수를 MB 단위로 계산하고 '-h'
는 사람이 읽을 수 있는 형식을 나타냅니다.
du -mh /home/tecmint
4.0K /home/tecmint/bin
4.0K /home/tecmint/.ffbinaries-cache
672K /home/tecmint/.openjfx/cache/17.0.3-ea
676K /home/tecmint/.openjfx/cache
680K /home/tecmint/.openjfx
8.0K /home/tecmint/.uk.co.screamingfrog.seospider.ui.b/webview
12K /home/tecmint/.uk.co.screamingfrog.seospider.ui.b
36K /home/tecmint/.ssh
92K /home/tecmint/.config/xfce4/xfconf/xfce-perchannel-xml
96K /home/tecmint/.config/xfce4/xfconf
12K /home/tecmint/.config/xfce4/desktop
4.0K /home/tecmint/.config/xfce4/xfwm4
8.0K /home/tecmint/.config/xfce4/panel/launcher-18
8.0K /home/tecmint/.config/xfce4/panel/launcher-17
8.0K /home/tecmint/.config/xfce4/panel/launcher-14
8.0K /home/tecmint/.config/xfce4/panel/launcher-3
...
55G /home/tecmint
8. '-c'
플래그는 마지막 줄에 디스크 공간 사용량의 총계를 제공합니다. 디렉터리가 55GB의 공간을 차지하는 경우 출력의 마지막 두 줄은 다음과 같이 나타납니다.
du -ch /home/tecmint
4.0K /home/tecmint/bin
4.0K /home/tecmint/.ffbinaries-cache
672K /home/tecmint/.openjfx/cache/17.0.3-ea
676K /home/tecmint/.openjfx/cache
680K /home/tecmint/.openjfx
8.0K /home/tecmint/.uk.co.screamingfrog.seospider.ui.b/webview
12K /home/tecmint/.uk.co.screamingfrog.seospider.ui.b
36K /home/tecmint/.ssh
92K /home/tecmint/.config/xfce4/xfconf/xfce-perchannel-xml
96K /home/tecmint/.config/xfce4/xfconf
12K /home/tecmint/.config/xfce4/desktop
4.0K /home/tecmint/.config/xfce4/xfwm4
8.0K /home/tecmint/.config/xfce4/panel/launcher-18
8.0K /home/tecmint/.config/xfce4/panel/launcher-17
8.0K /home/tecmint/.config/xfce4/panel/launcher-14
8.0K /home/tecmint/.config/xfce4/panel/launcher-3
8.0K /home/tecmint/.config/xfce4/panel/launcher-16
...
55G /home/tecmint
55G total
du 명령을 사용하여 파일을 제외하는 방법
9. 다음 명령은 주어진 패턴과 일치하는 파일을 제외한 모든 파일 및 디렉터리의 디스크 사용량을 계산하고 표시합니다.
제공된 예에서 명령은 디렉터리의 전체 크기를 계산할 때 '.txt'
파일을 제외합니다. 이 접근 방식을 사용하면 '--exclude'
플래그를 사용하여 특정 파일 형식을 제외할 수 있습니다.
출력을 검토하면 '.txt'
파일에 대한 항목이 없음을 알 수 있습니다.
du -ah --exclude="*.txt" /home/tecmint
4.0K /home/tecmint/fix-deb-src-error-ubuntu
4.0K /home/tecmint/tecmint.py
0 /home/tecmint/bin/FoxitReader
4.0K /home/tecmint/bin
4.0K /home/tecmint/.ffbinaries-cache
52K /home/tecmint/Eclipse-with-PyDev.jpg
300K /home/tecmint/Screenshot from 2023-07-27 14-02-45.png
16K /home/tecmint/.openjfx/cache/17.0.3-ea/libglass.so
28K /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font_pango.so
20K /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font.so
64K /home/tecmint/.openjfx/cache/17.0.3-ea/libprism_es2.so
512K /home/tecmint/.openjfx/cache/17.0.3-ea/libglassgtk3.so
28K /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font_freetype.so
672K /home/tecmint/.openjfx/cache/17.0.3-ea
...
55G /home/tecmint
수정 시간별로 디렉터리 사용량을 찾는 방법
10. 수정 시간을 기준으로 디스크 사용량을 표시하려면 아래와 같이 '--time'
플래그를 사용합니다.
du -ha --time /home/tecmint
4.0K 2023-07-06 13:15 /home/tecmint/fix-deb-src-error-ubuntu
4.0K 2023-06-14 12:50 /home/tecmint/tecmint.py
0 2021-12-07 12:26 /home/tecmint/bin/FoxitReader
4.0K 2021-12-07 12:26 /home/tecmint/bin
4.0K 2022-10-10 11:02 /home/tecmint/.ffbinaries-cache
52K 2023-05-12 12:09 /home/tecmint/Eclipse-with-PyDev.jpg
300K 2023-07-27 14:02 /home/tecmint/Screenshot from 2023-07-27 14-02-45.png
16K 2022-10-01 12:41 /home/tecmint/.openjfx/cache/17.0.3-ea/libglass.so
28K 2022-10-01 12:41 /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font_pango.so
20K 2022-10-01 12:41 /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font.so
64K 2022-10-01 12:41 /home/tecmint/.openjfx/cache/17.0.3-ea/libprism_es2.so
512K 2022-10-01 12:41 /home/tecmint/.openjfx/cache/17.0.3-ea/libglassgtk3.so
28K 2022-10-01 12:41 /home/tecmint/.openjfx/cache/17.0.3-ea/libjavafx_font_freetype.so
672K 2022-10-01 12:41 /home/tecmint/.openjfx/cache/17.0.3-ea
676K 2022-10-01 12:41 /home/tecmint/.openjfx/cache
...
55G 2023-08-14 10:22 /home/tecmint
du 명령은 다목적이며 다양한 옵션과 플래그를 사용하여 필요에 맞게 조정할 수 있습니다. 옵션 및 사용법에 대한 자세한 내용을 보려면 터미널에서 man du
를 사용하세요.