Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Ubuntu 12.04 LTS and I am stuck at creating a simple .bin file which can print a message "hi" or anything else. My objective is to create a binary file.I have searched but didn't found anything helpful to me. So may I know how can I create a .bin file.

share|improve this question
the extension .bin usually indicates a binary file - more than likely compiled - so if you intend to have a binary file you should pick a programming language, write a program, test it then compile it to get an executable file. – pfeiffep Mar 16 '13 at 21:04
up vote 3 down vote accepted

Extensions are irrelevant, you can name a file dead.letter and it can still print "hi".

The following terminal commands will create a file named hello.bin, make it executable and print "hello" when executed:

cat > hello.bin <<EOF
echo Hello World
chmod +x hello.bin

Executing ./hello.bin gives:

Hello World

This is a shell script, interpreted by the /bin/sh program (which is actually the /bin/dash program on Ubuntu).

The following writes source code to hello.c, the following command creates a binary program from this code:

cat > hello.c <<EOF
#include <stdio.h>
int main(void) {
    puts("Hello World");
    return 0;
gcc hello.c -o hello.bin

Executing ./hello.bin gives you Hello World too.

share|improve this answer
Thank you for the answer. I will let you know after trying it. – Raja Mar 17 '13 at 4:13

I am new to ubuntu community but had this as a bookmark on my browser. You can see if this helps.

share|improve this answer
Thanks for the information. – Raja Mar 17 '13 at 4:11
@prohank When you have a link to a page that you believe answers teh question, it's considered best to include the essential parts of the answer here, and provide the link for reference. If you wish to do that, you can edit your post to add your summary of the information. – Eliah Kagan Jan 11 '14 at 11:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.