/ Sign-up
Your question

How to run a file in the Unix?

  • Unix
Last response: in Open Source Software
December 23, 2010 12:54:45 AM

Hello, I've a question to ask here. For example, I want to run a the file"qrna.c", which commend should I choose?

More about : run file unix

December 23, 2010 3:31:52 AM

that is a source code file. You do not run (execute it) you have to compile it first.

But to answer your question, to execute something simply do ./executable_file
December 23, 2010 6:31:17 AM

skittle said:
But to answer your question, to execute something simply do ./executable_file

Assuming of course the file is executable already. If it's not then you need to run "chmod +x filename"
December 24, 2010 4:42:46 PM

'qrna.c' is a source file. You can usually compile those using a command like:

  1. cc -o qrna qrna.c
(Ignore the numbering that gets added to the 'code' block.)

The '-o' option tells it to name the executable 'qrna'. (Otherwise it will probably be named 'a.out'.)

To run it from that directory, use the command:

  1. ./qrna
The './' tells the shell to look for 'qrna' in the current directory. By default (unlike Windows) it will not look there as that is a security risk.

If you will be running the command often, create a $HOME/bin directory and move the executable there. The login scripts on most distros (Ubuntu anyway) will add $HOME/bin to your path so yu can leave the './' part off.

if 'qrna.c' uses any any but the default libraries, you need to add additional options to the 'cc' command line yo link them.

If this sort of thing interests you, try to locate a copy of "The Unix Programming Environment" by Kernighan and Pike. (But you have to be pretty geeky to enjoy that. ;)  )