In Linux or Unix, you can use the ls
command with the -l
option to see the file size of a file or directory. The file size is listed in the fifth column of the output. For example:
ls -l <file_name>
Replace <file_name>
with the name of the file you want to check the size of.
For example, to see the size of a file named “example.txt”, you would run:
ls -l example.txt
This will produce output that looks similar to this:
-rw-rw-r-- 1 user user 1234567 Feb 10 14:32 example.txt
In this example, the file size is 1234567 bytes.
You can also use the du
command to see the disk usage of a file or directory, including its size. For example:
du -h <file_name>
Replace <file_name>
with the name of the file you want to check the size of. The -h
option makes the output human-readable, meaning it uses a more intuitive format such as “K”, “M”, or “G” for kilobytes, megabytes, and gigabytes, respectively.
For example, to see the disk usage of the file “example.txt”, you would run:
du -h example.txt
This will produce output that looks similar to this:
1.2M example.txt
In this example, the file size is 1.2 megabytes.