Can someone explain to me the following command in linux? (I know that with that command you can find the total space taken by each of the directories)
du -h --max-depth=1
Can you suggest a good way to understand in depth these commands?
thanks.
Best Answer
I assume that you want to know about this command in brief so, I'll just break it up for you:
- du: this command is used to estimate file space usage
- -h: this parameter is short for --human-readable to print sizes in human readable format
- --max-depth=1: this parameter defines how deep in terms of folder structure level you want to see the output like is its level 1 then,output will show the size for all the files and folders in currentdirectory but not for the content inside the folders the currentdirectory has
You can use this website to learn more about linux commands: https://explainshell.com/explain?cmd=du+-h+--max-depth%3D1
I recommend you to use du --help
or man du
to get help, and try these command yourself. You can remove or change any arguments and find out the differences between them.
-h
means human readable, it will display the size like 1K
or 3.5G
, rather than only a number.
--max-depth=1
means it will only count the files and directories in current directory, sub-directories and sub-files will not display.