Linux is a family of operating systems based on the kernel of the same name. There is no single Linux operating system, like Windows or macOS. There are many distributions (a set of files needed to install software) that perform specific tasks.
Today, Linux is a fairly widely used operating system. It’s used especially often by information and cybersecurity professionals. This is because Linux is easy to configure and can be preinstalled with the programs and utilities you need (depending on the distribution).
If you are new to Linux and have only used Windows or MacOS before, you may find it relatively difficult to master the basics of this operating system. However, once you have mastered the console (called Terminal) of Linux, you will truly feel the simplicity and performance.
Well, if you’re reading this article, you’re probably a beginner. If you don’t know how to check the file size in Linux, here is how you can do it.
How to check the file size in Linux using file manager
The easiest way to find out this parameter is in the GUI. In other words, it can be done in the file manager.
If you want to check the file size in the file manager, you have to follow these steps:
- First of all, find the file you want to check and right-click on it.
- In the menu that opens, select “Properties”.
- The program will open a window with the properties of the file, among them will be the size.
Once you have completed these steps, you will be able to check the file size in Linux using file manager. Let’s face it, it’s pretty simple.
How to check the file size in Linux using Terminal and the “ls” command
If you want to check the file size in Linux using Terminal and the “ls” command, you have to follow these steps:
- At first, open the Terminal window.
- In order for the “ls” command to display file sizes in an easy-to-read format, the “-h” parameter should be used. For example, “ls -lh”. The size will be displayed in the fifth column.
- To see the size of a particular file, you must pass its name to the utility: ls -lh ‘Screenshot from 2022-01-10 14-23-32.png’.
- You can also manually specify the units of measurement to show the size. To do this, use the “–block-size” option. For MBytes: ls -l –block-size=M.
- You can use the command “ll” instead of “ls”, its output is completely similar to the command “ls -l”: ll -h.
How to check the file size in Linux using Terminal and the “stat” command
If you want to check the file size in Linux using Terminal and the “stat” command, you have to follow these steps:
- Open the Terminal window.
- In addition to the metadata, the “stat” command allows you to output the file size in bytes. For example: stat ‘Screenshot from 2022-01-10 14-23-32.png’.
- If you only want to show the size, use the “-s” option with the “%s” format: stat -c %s ‘Screenshot from 2020-08-10 20-22-50.png’.
How to check the file size in Linux using Terminal and the “du” command
If you want to check the file size in Linux using Terminal and the “du” command, you have to follow these steps:
- Open the Terminal window.
- The “du” command is specially designed for viewing the size of files in a folder. You can view the size of a particular file, for example: du -h ‘Screenshot from 2022-01-10 14-23-32.png’.
- The “-h” command includes outputting the size in an easy-to-read format. If you want to see the size for all files in a folder, just pass the path to the folder: du -h ~/Images/*.
- And to find out the size of a folder in Linux, use the “-s” command. It sums up the size of all objects: du -sh ~/Images/*.
How to check the file size in Linux using Terminal and the NCDU tool
If you want to check the file size in Linux using Terminal and the NCDU tool, you have to follow these steps:
- The NCDU tool allows you to analyze the disk space occupied by files and directories. However, it doesn’t come with the system. To install it, do the following: sudo apt install ncdu.
- Then simply specify in the parameters the directory whose size you want to view: ncdu ~/Images.
- All files will be sorted by size, and at the very bottom you will see the total size of this folder.
In this article, you have learned how to know the size of the Linux files and how to look up the size of a directory and all the files in it using different utilities.