Webhosting Blog

Creating a file with specific size


Sometimes you need to add a file with specific file size for testing the download speed, uploading file of particular size etc..

For this you can create a file  with required specific size. Follow following command to create a file of specific size.

Lets create a test file with specified size 100Kb.

[root@server ~] # dd if=/dev/zero of=Testfile bs=1024 count=100

Where,

dd – dd is a common UNIX program whose primary purpose is convert and copy a file.

if – Input File. Read from FILE instead of stdin

of – Output File. write to FILE instead of stdout.(The name of the file to be created)

bs – Block Size, mostly in bytes.(Default value is 512bytes)

count – the size of the file to be created  in KB

Now lets see if the file size is as specified

[root@server ~]# ls -l Testfile

-rw-r–r–  1 root     root     102400 Jul  6 07:31 Testfile

You should see the file of specific size will be created for you.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s