18.01.2020 Views

Working with Linux

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

"df -h": This shows the disk usage in a human-readable format

"| grep /home": This shows only the home directory

'| tr -s " "': This substitutes multiple spaces for just one space

'| cut -f 2 -d " "': This selects the second column using a space as the delimiter

As you can see, the command printed out 173G, the size of the /home partition. This is a common use

case when chaining multiple commands, each command reducing the output until we get the desired

information and nothing else. In our case, this is the used disk space.

To count all the directories in a folder, use the following command:

ls -p | grep / | wc -l

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!