Home>Article>Operation and Maintenance> How to check file size in linux
How to check the file size in Linux: 1. Use the stat command to view the detailed information display of the file system; 2. Use the wc command to calculate the number of Bytes of the file, etc.; 3. Use the du command to view the used space; 4. The ls command is used to display a list of targets.
The operating environment of this tutorial: linux7.3 system, DELL G3 computer.
How to check the file size in Linux:
1. stat command
stat command: details of file/file system the message says.
The stat command is mainly used to display detailed information of a file or file system. The syntax format of this command is as follows:
-f does not display the information of the file itself, but displays the information of the file system where the file is located
-L Display symbolic links
-t Simple mode, only display summary information
stat ljl.txt
2. wc command
wc command Used to calculate numbers. We can use the wc command to calculate the number of Bytes, words, or columns of a file. If the file name is not specified, or the file name is given as "-", the wc command will read data from the standard input device.
wc -c filename parameter -c represents statistical characters, because one character is one byte, so the number of bytes is obtained
wc -c ljl.txt
3. du command
The du command also checks the space used, but unlike the df command, the Linux du command checks the space used by files and directory disks, which is somewhat different from the df command.
du -b filepath The parameter -b indicates counting in bytes
du -b ljl.txt
or
du -h filepath directly obtains the file size that people can recognize
du -h ljl.txt
4. ls command
The ls command is used to display the target list and is a highly used command in Linux. The output information of the ls command can be displayed with color highlighting to partition different types of files.
ls -l filepath The fifth column is the number of file bytes
ls -l ljl.txt
ls -h filepath h means human, add the -h parameter to get the file size that is easy for humans to read
ls -lh ljl.txt
Related learning recommendations:linux video tutorial
The above is the detailed content of How to check file size in linux. For more information, please follow other related articles on the PHP Chinese website!