How to run a file in the Unix?

Hello, I've a question to ask here. For example, I want to run a the file"qrna.c", which commend should I choose?
3 answers Last reply
More about file unix
  1. 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
  2. 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"
  3. 'qrna.c' is a source file. You can usually compile those using a command like:

    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:

    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. ;) )

Ask a new question

Read More