我试图查看系统中的文件系统空间,但即使我更改位置,它仍然显示相同的空间。我看到了手册页,据我所知,我正在传递正确的论点。为什么它仍然向我显示而不是我给它的文件(系统)中的空间?
(metalearning_gpu) brando9~ $ df -h anaconda
Filesystem Size Used Avail Use% Mounted on
ilnfs1:/pool0/scratch0 53T 53T 14G 100% /dfs/scratch0
(metalearning_gpu) brando9~ $ cd anaconda/
(metalearning_gpu) brando9~/anaconda $ df -h .
Filesystem Size Used Avail Use% Mounted on
ilnfs1:/pool0/scratch0 53T 53T 14G 100% /dfs/scratch0
手册页:
NAME
df - report file system disk space usage
SYNOPSIS
df [OPTION]... [FILE]...
答案1
df
显示整个文件系统的空间。当您给它一个路径时,它会显示该路径所在的整个文件系统的空间。
如果您只想查看特定路径下文件的使用情况,您应该尝试该du
命令。具体来说是这样的:du -h -s .
或者du -h -s /path/to/my/directory
编辑添加:
当您想要特定路径下的文件大小以及文件系统统计信息(例如总空间和可用空间)时,您不能仅使用du
或df
,您必须同时使用它们:
df
显示文件系统级别的统计信息,例如总空间和可用空间(但不包括文件和目录级别的使用情况)du
显示文件和目录级别的使用情况,但不显示文件系统中的总空间/可用空间
答案2
感谢@sotto voco的回答,但这是我的理解。
总括:
For space usage do:
df -h path2inode
above for systemfile usage
du -hs path2inode
du -hs ~ | grep data | head -5
du -hs ~ | sort rh | head -5
above for specific inode. Might be slow.
To see space your using for specific files & total limit run both commands.
df -sh path2file - 显示安装了path2file的文件系统的空间量,而不是path2file的空间
因此,使用 df 来查看您的文件(或特定文件/索引节点)安装在文件系统中使用了多少空间。例如
(iit_synthesis) brando9~ $ df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/md2p1 56T 13T 41T 24% /lfs/ampere4/0
所以我将上面的内容解释为文件/inode .
(路径是/lfs/ampere4/0/brando9
)安装在/lfs/ampere4/0
并且它显示该文件安装位置的文件系统信息——而不是有关文件本身的大小/空间信息。
引用一些有用的描述:
df 显示文件系统中的总空间和可用空间,因为它查看文件系统统计信息。 (来自低声)
df 显示包含每个文件名参数的文件系统上的可用磁盘空间量。 df - 报告文件系统磁盘空间使用情况。 (df 的手册页)。
du - 显示给定文件/索引节点的空间,无法为您提供文件/索引节点安装的总文件系统的信息
du 显示特定文件/路径/inode/dir 上的空间。例如
(iit_synthesis) brando9~ $ du -hs .
8.7G .
(iit_synthesis) brando9~ $ du -hs ~
8.7G /lfs/ampere4/0/brando
获取您占用的文件系统空间(例如您的限制)。依次运行du -h ~
和。du -hs
如果删除的-s
输出太多,您可能需要对其进行排序或 grep 以获得所需的信息。例子在最后。
从手册页;
对目录递归地总结文件集的磁盘使用情况。
常见的例子du
:
(iit_synthesis) brando9~ $ du -h ~ | sort -rh | head -10
8.7G /lfs/ampere4/0/brando9
8.6G /lfs/ampere4/0/brando9/.opam
4.6G /lfs/ampere4/0/brando9/.opam/coq-8.12
3.0G /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch
2.9G /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources
2.0G /lfs/ampere4/0/brando9/.opam/coq-8.10
1.2G /lfs/ampere4/0/brando9/.opam/ocaml-variants.4.07.1+flambda_coq-serapi.8.11.0+0.11.1
917M /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/menhirSdk.dev
917M /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/menhirLib.dev
917M /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/menhir.dev
或者
(iit_synthesis) brando9~ $ du -h ~ | grep data
4.0K /lfs/ampere4/0/brando9/data
8.0K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/dune-configurator.3.6.1/test/blackbox-tests/test-cases/ignored_subdirs/pre-1.6.t/data
16K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/dune-configurator.3.6.1/test/blackbox-tests/test-cases/vendor/self-data-only.t
4.0K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/dune-configurator.3.6.1/test/blackbox-tests/test-cases/vendor/conflicts-with-data-only.t/dir
20K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/dune-configurator.3.6.1/test/blackbox-tests/test-cases/vendor/conflicts-with-data-only.t
16K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/dune-configurator.3.6.1/test/blackbox-tests/test-cases/vendor/deep-subfolder-dataonly.t
116K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/menhirLib.dev/test/dynamic/semantics/data
116K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/menhir.dev/test/dynamic/semantics/data
8.0K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/dune.3.6.1/test/blackbox-tests/test-cases/ignored_subdirs/pre-1.6.t/data
16K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/dune.3.6.1/test/blackbox-tests/test-cases/vendor/self-data-only.t
4.0K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/dune.3.6.1/test/blackbox-tests/test-cases/vendor/conflicts-with-data-only.t/dir
20K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/dune.3.6.1/test/blackbox-tests/test-cases/vendor/conflicts-with-data-only.t
16K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/dune.3.6.1/test/blackbox-tests/test-cases/vendor/deep-subfolder-dataonly.t
116K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/menhirSdk.dev/test/dynamic/semantics/data
8.0K /lfs/ampere4/0/brando9/.opam/coq-8.10/.opam-switch/sources/dune-configurator.3.6.1/test/blackbox-tests/test-cases/ignored_subdirs/pre-1.6.t/data
16K /lfs/ampere4/0/brando9/.opam/coq-8.10/.opam-switch/sources/dune-configurator.3.6.1/test/blackbox-tests/test-cases/vendor/self-data-only.t
4.0K /lfs/ampere4/0/brando9/.opam/coq-8.10/.opam-switch/sources/dune-configurator.3.6.1/test/blackbox-tests/test-cases/vendor/conflicts-with-data-only.t/dir
20K /lfs/ampere4/0/brando9/.opam/coq-8.10/.opam-switch/sources/dune-configurator.3.6.1/test/blackbox-tests/test-cases/vendor/conflicts-with-data-only.t
16K /lfs/ampere4/0/brando9/.opam/coq-8.10/.opam-switch/sources/dune-configurator.3.6.1/test/blackbox-tests/test-cases/vendor/deep-subfolder-dataonly.t
8.0K /lfs/ampere4/0/brando9/.opam/coq-8.10/.opam-switch/sources/dune.3.6.1/test/blackbox-tests/test-cases/ignored_subdirs/pre-1.6.t/data
16K /lfs/ampere4/0/brando9/.opam/coq-8.10/.opam-switch/sources/dune.3.6.1/test/blackbox-tests/test-cases/vendor/self-data-only.t
4.0K /lfs/ampere4/0/brando9/.opam/coq-8.10/.opam-switch/sources/dune.3.6.1/test/blackbox-tests/test-cases/vendor/conflicts-with-data-only.t/dir
20K /lfs/ampere4/0/brando9/.opam/coq-8.10/.opam-switch/sources/dune.3.6.1/test/blackbox-tests/test-cases/vendor/conflicts-with-data-only.t
16K /lfs/ampere4/0/brando9/.opam/coq-8.10/.opam-switch/sources/dune.3.6.1/test/blackbox-tests/test-cases/vendor/deep-subfolder-dataonly.t
或更短
(iit_synthesis) brando9~ $ du -h ~ | grep data | head -5
4.0K /lfs/ampere4/0/brando9/data
8.0K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/dune-configurator.3.6.1/test/blackbox-tests/test-cases/ignored_subdirs/pre-1.6.t/data
16K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/dune-configurator.3.6.1/test/blackbox-tests/test-cases/vendor/self-data-only.t
4.0K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/dune-configurator.3.6.1/test/blackbox-tests/test-cases/vendor/conflicts-with-data-only.t/dir
20K /lfs/ampere4/0/brando9/.opam/coq-8.12/.opam-switch/sources/dune-configurator.3.6.1/test/blackbox-tests/test-cases/vendor/conflicts-with-data-only.t