The amount of space a file takes on the secondary storage is called the size of that particular file. The size of a file is measured in Bytes(B), Kilo Bytes(KB), MegaBytes(MB), Giga Bytes(GB), and Tera Bytes(TB). The size of files is used to manage the disk space. In Ubuntu 22.04, there are different ways to display the sizes of different files.
In this article, we’ll learn how you can display file size in Bytes, KB, or GB.
How to Display File Size in MB, KB, or GB in Ubuntu Linux?
The sizes of files play an important role in determining how your disk drives are populated with files having different sizes. Ubuntu 22.04, provides different ways to list down the sizes of files stored on your disk drives. Two popular ways are:
- Use Terminal.
- Use the Properties Option.
Follow these methods to determine the sizes of files.
Method 1: Using the Terminal
Open your terminal by pressing “Ctrl + ALT + T”, the shortcut key will open the terminal. Now you can execute different commands for listing down the files with corresponding sizes. Let’s start with the command “ls -l”, execute the command in the terminal
$ ls -l
The command executes and displays the files with the corresponding size in Bytes
Now use the command “ls -lh”, the command displays the files with the proper suffix like KB, MB, or GB
$ ls -lh
The command shows the following output
You can display the file sizes in KBs. Use the following command to display file size in KB
$ ls -l -block-size=K
The command will display the size of files in KBs
Use the following command to display the file size in MBs
$ ls -l -block-size=M
The command will display the size of files in MBs
The commands mentioned above do not provide a concise or convenient way to display sizes, to show the files in a more understandable form use the following command
$ ls -sh
The command displays the following output
You can also check the “stats” of the files by executing the following command
$ stat "<file name>"
The command will show the output in the following manner
Now we will discuss the GUI method using the properties option.
Method 2: Using the Properties Option
During the last couple of decades, the Linux distributions have been working great in terms of improving GUIs. Ubuntu 22.04 has also improved GUI. In the following method, we use the Properties option to show the file size that the Ubuntu 22.04 GUI provides. Follow the given steps to determine the file size:
- Right-click on the file you want to show the file size and select the Properties option from the dropdown menu
- That’s it you can display the properties of files along with their size
That’s how you can display the file size in different ways. I hope the article will be a great help if you follow along.
Conclusion
To display file size in KB, MB, or GB in Ubuntu 22.04 can be done by using the terminal as well and you can use the Properties option in GUI. By using different commands in the terminal you can display the file sizes. In this article, we have learned how you can display the size of files in Ubuntu 22.04.