How to Check File Size on Ubuntu
Table of Contents
This tutorial explains how to show the size of individual files on Ubuntu.
To find out how much disk space an entire directory uses (including all of its subdirectories), see this tutorial.
To find out the total disk space usage by an entire disk volume, see this tutorial.
Step 1. Open a Terminal Session
If you're using an Ubuntu laptop or desktop, you can press
Ctrl + Alt + T on your keyboard to open a new terminal window. If you're using a remote Ubuntu server, you can connect using SSH to open a new terminal session.
If you want to see the file sizes of every file in the current directory:
You should see output like:
The fifth column of the output shows the file size (e.g.,
286K in the output above).
-l option tells
ls to show various metadata about the file, including file size. Without this option,
ls only shows filenames.
-h option tells
ls to show human-friendly units such as
M for megabytes,
G for gigabytes, etc.
As usual, you can combine the options and get the same output:
To include hidden files (files whose filenames start with
. such as
.gitignore), add the
To show the file size of a specific file called
page1.html in the current directory, you can run:
You can also list multiple specific files:
If you want to show output for directories other than the current directory, you can include their paths at the end of the command. For example, to show the file size of all files (including hidden) in the directory
website inside the home directory, you can run: