Raspberry Pi

How to Check File Size on Raspberry Pi

The Raspberry Pi is based on the Linux operating system which is capable of handling tasks through terminal. However, in some cases you can use both GUI and terminal to do a task, such as file sharing to other folder, renaming, copying, and deleting the files. Besides, performing the tasks, you may need to delete some files to free up the space or want to compare the file size while performing the compression operation. In that scenario, you will surely need finding the file size on the system.

If you are looking for help regarding finding the file size on Raspberry Pi, follow this article for a detailed guidance.

Check File Size on Raspberry Pi

There are two ways to identify the file size through Raspberry Pi:

    • Check File Size Through GUI
    • Check File Size Through Terminal

Method 1: Check File Size Through GUI

Checking the file size using GUI is a straightforward method because there you can find the size of a file.

You can directly find the file size by single-click on the desired file as shown in the following image.


You can also find the file size on Raspberry Pi by right-click on the file and select the “Properties” option.


After clicking the Properties, a window will pop out where you can have the total size of the designated file.

Method 2: Checking File Size Through Terminal

For the case of checking the file size through terminal, you can use the “du” command with the file name as shown below:

$ du <file_name>.format

 

However, the above command only provides you with the file size in number, which might be confusing for the users whether it’s in KB or MB.

To get the result with the unit file size, you can use the following command:

$ du -h <file_name>.format

 

If you are trying to check the actual size of the file, then execute the following command:

$ du -bsh <file_name>.format

 

You can also use the “ls” command to check for the file size on the terminal. The syntax for checking the file size through the command is given below:

$ ls -lh <file_name>.format

 

The “stat” command can also be used on Raspberry Pi terminal to check for the file size.

$ stat <file_name>.format

 

To retrieve only the file size information from “stat” command, use the following syntax:

$ stat -c%s” <file_name>.format

 

Conclusion

Checking the file size on Raspberry Pi system is crucial if someone wants to delete larger files or compares the size of the files during the compression operation. You can check the file size on Raspberry Pi system easily through GUI, while for the case of terminal, you have to use commands like “du”, “ls” and “stat” to get the file size information on Raspberry Pi system.

About the author

Muhammad Nasir

Hi! I am an engineer and technical blogger by profession and I enjoy getting things done with electronics. I am using this platform to share my knowledge in the field of Raspberry Pi, Linux, and Embedded Systems with others.