Posts Tagged With: size

Use DD to Create File of any Size

Tagged with: , , , , ,

Use the DD command to create a 10 MB (10*1024*1024=10485760 bytes) size file named testfile_10MB


dd if=/dev/zero of=testfile_10MB bs=10485760 count=1

Original Article

4 Comments »

Package Listing in Debian

Tagged with: , , , , , , , ,

Show space used by deb packages installed sorted by size (ubuntu, debian and like)


dpkg-query -W -f='${Installed-Size;10}t${Package}n' | sort -k1,1n 
No Comments »

Command to Sort Files by Size

Tagged with: , , , , ,

Show size of the files and directories sorted by size


du -sk * | sort -rn
No Comments »

Show Disk Usage – du

Tagged with: , , , , , ,

du shows the ‘disk usage’ – the space taken up by the files and folders in the current directory.


du -bh | more
No Comments »

Python Function for Space Units

Tagged with: , , , ,

A Python function to return readable size using the given size(KB)


# Returns a more readable format of the given data. For example, getReadableSize(1024) returns "1 MB"
	def getReadableSize(size):
		unit = "KB"
		size = float(size)
		final = size

		if(size >= 1024):
			unit = "MB"
			final= "%.02f" % (size / 1024)
			size = (size / 1024)

			if(size >= 1024):
				unit = "GB"
				final= "%.02f" % (size / 1024)
				size = (size / 1024)

		return str(final) + " " + unit

[tags][/tags]

No Comments »