Get Total size of hard drive in Linux without root permissions

Though there are different ways and different commands like du to find out the size of hard drives in Linux, sometimes without root permissions it’s difficult to execute these commands to find the hard drive sizes. To bypass those restrictions we can use some other commands like dmseg to find the total size which doesn’t require any root permissions

##Prints the size of different drives and the partition as shown in bytes

#In human readable bytes format
lsblk -b

#In raw format
lsblk -b -r

##You can execute the below command even if you don't have root permissions

dmesg | grep blocks

Here the dmesg prints the kernel ring buffer. It’s basically a log that says how many blocks are present in the system and how many blocks are free as of now. The grep filters out the blocks and get the details what we need. This may just display the logical drives and the free spaces but it might not be ideal way to find out the size of drives

You may also like...