How to display the file system block size using the ls command in Linux?

Published on Aug. 22, 2023, 12:17 p.m.

The ls command in Linux does not display the file system block size by default, but you can use the lsblk command to display the block size of a particular disk or partition. Here is an example command to display the block size of the root file system:

lsblk -o NAME,SIZE,PHY-SEC

This will display a list of block devices (disks or partitions) on the system, along with their names, sizes, and physical sector sizes (in bytes).

To display the block size in bytes, you can divide the physical sector size by the block size (usually 512 bytes or 4096 bytes on modern Linux systems).

Alternatively, you can use the stat command to display information about a particular file, including its block size. Here is an example command to display the block size of a file called “example.txt”:

stat -c '%n %o' example.txt

This will display the name of the file and its block size in bytes.

Note that the file system block size is generally fixed for a given file system, and is determined by the block size of the underlying hardware or the configuration of the file system itself. The block size is used to allocate space on the disk for each file or directory, and can affect performance in certain scenarios.

Tags: