Hot Article
- Centos7 closes and restarts the system firewall and opens firewall ports
- How IID server uses Xshell to connect to Linux (centos) server
- BT panel forgets the background login URL, and the solution to the security entrance verification failure
- The php domain name points to ip, how to use the specified ip address to access a server in the url request domain name in curl mode
- Error connecting to MySQL: Cant connect to MySQL server (10060)
- How to purchase a dedicated server
In Linux, you can use "ls" and "du" commands to view the file size.
1. Use the "ls" command to view the file size.
To view the size of a single file, execute the following command
ls -lh filename
The above command will display the size of the file in an easy-to-read format (e.g. MB, KB, etc.).
To view the size of all files in a directory, execute the following command.
ls -lh directory
The above command will list the size of all files in the directory.
2. Use the "du" command to view the file size.
To view the size of a single file or directory, execute the following command.
du -h filename/directory
The above command will display the size of a file or directory in an easy-to-read format (e.g. MB, KB, etc.). To display the total size of all files in a directory, add the "-s" option, as follows
du -sh directory
The above command will display the sum of the sizes of all files in the directory.
Please note that in Linux, file sizes are usually expressed in bytes. Therefore, when the file size is large, it may be necessary to convert it to a more understandable unit, such as MB or GB.
related topic
- How does CentOS7 open/view ports?
- IDGlobal teaches you how to set up root remote login in Ubuntu SSH
- Merge the /home directory into the / directory under CentOS
- How to solve the Windows 10 prompt "The built-in administrator cannot activate this application"?
- Windows firewall settings only allow specified IPs to access specified ports
- ubuntu 20.04 newbie installation tutorial