I am using SSH to connect to a CentOS server and I want to get the file in mb of some files and folders, how can I do it?
3 Answers
use the du command
du -m filename
-
31If you use
du -h
instead, it'll chose (and print) the appropriate units.– DentrasiCommented Jun 22, 2010 at 21:28 -
11If you use du -ms folder, it will report the size of the folder contents.– KeithBCommented Jun 22, 2010 at 21:35
-
1Is there a way where we can see the units - example mb, kb or any other information? Commented Mar 25, 2013 at 9:58
-
1
du -msh FolderName
will get the size with units. Unlike using -h, this will show a single size, while -h shows all the individual files within the folder.
e.g.
349M FolderName
-
2
-
du -sh /yourpath/* to list all directories in a given path and summarized sizes of their contents– FankyCommented Oct 7, 2019 at 8:31
du
is the primary tool for this, but if you're looking for something more interactive, I quite like ncdu