Linux Tips – How to check file size in Linux
In this tutorial, you will learn how to check the file size in linux terminal using five different tips with help of linux commands.
5 Different Ways
- using stat command
- using du command
- using ls command
- Using dir command
- Using wc command
1. Displaying File Size using stat Command
- This command is used to provide a detailed report about file including file size.
- This command will show the file size in bytes.
Syntax
stat filename
Example
2. Displaying File Size using du Command
- This command is also used to display the file size in terms of KB
- This command will take only one argument with special option -s which is the file name
Syntax
du -s filename
Example
3. Displaying File Size using ls Command
- This command is also used to display the file size in terms of KB
- This command will display the file size with special option -s
Syntax
ls -s filename
Example
4. Displaying File Size using dir Command
- Like ls command, this command is also used to display the file size in terms of KB with special option -s
Syntax
dir -s filename
Example
5. Displaying File Size using wc Command
- Wc command is also used to display the file size in terms of bytes
- This command will display the file size with special option -m
Syntax
wc -m filename
Example