Question:
Run a program in LinuxOS ?
2009-01-19 05:36:34 UTC
as we know EXE file runs in Windows what file run in linux os.
and how to make that file i mean i which language
Suse linux 9.1
Three answers:
Fred W
2009-01-19 17:34:36 UTC
The default executable format in Linux is "elf". This is generated by "ld". Normally, though, ld is not directly executed -- gcc is used.



# create source file x.c

cat >x.c

/* source file */

#include

int main(void) { printf("hello\n"); return 0; }

Control+D

# compile the file into file a.out

gcc x.c

# execute a.out

./a.out



prints out "hello"



However, Linux can run shell scripts, or other processes (#! or "shebang" mechanism). This mechanism assumes that the first

two characters of the file are #!, followed by the filename of the

processor. This is a simple example using perl:



#!/usr/bin/perl

print "Hello\n";



The perl processor is located at /usr/bin/perl. This can run shell

scripts (/usr/bash), perl, python, ruby, etc.



Also, Linux can run foreign binaries (including Windows ".exe"):



# -- this is normally done at BOOT time

# Load in the binary miscellaneous format kernel module

sudo /sbin/modprobe binfmt_misc

# Register DOS (MZ) and Windows PE formats with wine handler

echo ':windows:M::MZ::/usr/bin/wine:' >/proc/sys/fs/binfmt_misc/register

echo ':windowsPE:M::PE::/usr/bin/wine:' >/proc/sys/fs/binfmt_misc/register

# Now, Linux is capable of running Windows programs from the

# command line

# run a Windows program (if you have it) directly...

./notepad.exe



This feature can be used to run Windows, JAVA, or other formats

(SYSV Unix, and other) directly.



Files in Linux have to set executable, before they can be run. ld and gcc does this automatically, but for foreign or shebang you may have to do it manually:



chmod +x filename



and ls -l filename to check.



Hope this helps...
Nitin
2009-01-19 05:51:07 UTC
exe wont run in Linux. You can use any of the shell to run a program. If you are making your own program then make sure first line of the file starts with

#!/bin/sh

and make sure you run the command

chmod +x



+x will make it executable.



most of the unix scripts will have .sh in the end which means they are executable. also the files that have x in the permission fields are executables.



you can write scripts in perl, c, c++ on linux.
Captain Penguin
2009-01-19 05:44:13 UTC
Any file can be made executable in linux - we don't rely on 'extensions'



There are many different languages you can use to write software. I heard that Perl is easy to learn and very good.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...