How to see the size of a file
How to see the size of a file on Linux?
Run the ls or stat command to see file size information.
ls -l /path/to/fileThe ls command is the default command to see basic file properties, such as its name, ownership, file permissions, and file size. When using the -l the long listing format is used to see the details.
Showing file properties
# ls -l /etc/passwd
-rw-r--r-- 1 root root 1993 Feb 2 2024 /etc/passwd
When a file is more than a megabyte, it may help to use the --human-readable option. It show the size with a corresponding character (k=kilobyte, m=megabyte, g=gigabyte).
An alternative option is using the stat command. It will provide additional details in its default output, such as the initial creation date and inode.
# stat /etc/passwd
File: /etc/passwd
Size: 1993 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 132674 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2024-11-10 19:17:01.327124248 +0000
Modify: 2024-02-02 19:14:45.316650111 +0000
Change: 2024-02-02 19:14:45.320650046 +0000
Birth: 2024-02-02 19:14:45.316650111 +0000