Home  >  Article  >  Operation and Maintenance  >  How to check the file size in a directory in Linux

How to check the file size in a directory in Linux

尊渡假赌尊渡假赌尊渡假赌
尊渡假赌尊渡假赌尊渡假赌Original
2023-09-08 16:21:401809browse

In Linux systems, you can use the "ls" command combined with the "-lh" option to view detailed information about the files in the specified directory and display the file size in a readable format. The specific usage method is "ls -lh" /path/to/directory", where "/path/to/directory" represents the path of the directory that needs to be viewed.

How to check the file size in a directory in Linux

#The operating system of this tutorial: linux6.4.3 system, Dell G3 computer.

In Linux systems, you can use the ls command with the -lh option to view detailed information about the files in the specified directory and display the file size in a human-readable format. The specific usage is as follows:

ls -lh /path/to/directory

Among them, /path/to/directory represents the path of the directory that needs to be viewed. After executing the above command, all files and subdirectories in the directory will be listed, and detailed information of each file will be displayed, including file size, creation time, permissions, etc.

The -l option represents displaying file information in long format, and the -h option represents displaying file size in human-readable format (for example, if the file size exceeds 1K, it will be in KB or MB units Show file size).

Also, if you just want to check the size of a specific file, you can use the du command. The specific usage is as follows:

du -h /path/to/file

The -h option also indicates that the file size is displayed in a human-readable format.

The above is the detailed content of How to check the file size in a directory in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn