How to Check the Size of a Folder in Linux

du command: View current directory and subdirectory folder/file size

du = disk usageDisk usage, output the total size of each file or directory

# 查看当前目录的总大小
$ du -sh  
# 查看当前目录所有子目录的大小
$ du -sh * 
# 查看当前目录和所有子目录大小,最后一行会显示当前目录的总大小,不包括隐藏文件
$ du -ach *
# du -sh 目录路径
$ du -sh /usr
  • -c, --total cumulative size
  • -d, --max-depth=N determines the depth of each directory
  • -B, --block-size=SIZE determines the unit to display the file size; for example, '-BM' is MB, '-BK' is KB
  • -h, --human-readable print in human-readable format (e.g. 1K 234M 2G)
  • -s, --summarize show total size

df command: used to display the available disk space on the disk partition

df = disk freecommand to display the available disk space on a disk partition. The default display unit is KB. You can use this command to obtain information such as how much space the hard disk is occupied and how much space is left.

# 以可读性高的结果展示磁盘分区上的可使用的磁盘空间
$ df -h

ls command: List the names of all files/folders in the current working directory

# 显示成字节大小
$ ls -l
# 以KB、MB等为单位进行显示更加直观
$ ls -lh
# 按照文件大小排序(由大到小)
$ ls -lhS
# 可将隐藏文件的大小显示出来
$ la -lh

find command: Find the path of a file

$ sudo find / -name osg

$ sudo find /usr -name osg

$ sudo find /usr -name "*osg*"

Guess you like

Origin blog.csdn.net/Cappuccino_jay/article/details/125168388