看内存
1、看内存大小
- df -h
- du -sh .#查看当前总目录的使用情况:
- du -h #看当前目录下所有子文件大小
2、看GPU运行内存
- nvidia-smi 看GPU有几块 占比多少
一块GPU 核占比99%
三块GPU
3、看提交任务
- top
- c #看细节
- q #退出
4、查看文件夹目录下有多少子文件
- ls file_path/*.txt | wc -l
- find /path/to/directory -mindepth 1 -maxdepth 1 -type d | wc -l。
- -mindepth 1 避免包括顶层目录本身。
- -maxdepth 1 确保只查找直接子目录。
- -type d 指定只查找目录。
- wc -l 用于计数。
- find /path/to/directory -mindepth 1 -type d | wc -l 查所有目录包括子子目录、子子子目录。。。。
- ls -l /path/to/directory | grep "^d" | wc -l
- ls -l /path/to/directory 列出目录内容详细信息。
- grep "^d" 过滤结果只保留目录条目(以 d 开头的行)。
- wc -l 计算结果行数。
- tree -d /path/to/directory
- tree -d /path/to/directory | tail -1 | awk '{print $3}'
5、看内存大小
1. 使用 free 命令(Linux)
- free 命令是查看内存使用情况的标准工具。它显示系统中空闲和已用的总物理内存及交换空间,以及缓冲和缓存占用的内存。
- free -h
- -h 选项表示“human-readable”,它会把输出格式化为易于阅读的格式,如 MB 或 GB。
2. 使用 cat 查看 /proc/meminfo(Linux)
- Linux 系统提供了 /proc/meminfo 文件,其中包含了详尽的内存信息。你可以用 cat 或者 grep 命令来查看它。
- cat /proc/meminfo
3.使用 grep 命令来获取特定的内存信息:
- grep MemTotal /proc/meminfo
- grep MemFree /proc/meminfo
6、看文件内存大小
1. 使用 du 命令
- 查看单个文件的大小:du -h /path/to/file
- -h 参数表示“human-readable”,使输出更易于阅读(例如,显示 KB、MB 或 GB)
- 查看目录及其所有子目录的总大小:du -sh /path/to/directory
- -s 参数表示“summarize”,这将只显示总计,而不列出每个子目录的大小。
- 查看目录及其每个子文件和子目录的大小:du -ah /path/to/directory
- -a 参数表示“all”,它将列出每个文件和目录的大小。
2. 使用 ls 命令
- 查看单个文件的大小:ls -lh /path/to/file
- -l 参数表示“long format”,显示详细信息。
- -h 参数使大小易于阅读(如 KB、MB)
- 查看目录下所有文件的大小:ls -lh /path/to/directory
- 这会列出目录中每个文件的大小,但不会递归到子目录中。
3. 组合 find 和 du 查看目录及所有子目录和文件的大小
- find /path/to/directory -type f -exec du -ch {} +
- find /path/to/directory -type f 查找目录及其所有子目录中的所有文件。
- -exec du -ch {} + 对每个找到的文件执行 du 命令,-c 显示总计,-h 使输出易于阅读。