If I do gcc filename.c
, I get a.out
After performing gcc -o output_name filename.c
we get the executable file output_name
.
What is the extension of this file?
Unlike windows, Linux does not depend upon extension of a file to determine what type of file it is. Instead, it will check first few bytes of the file and determine what type of file it is.
Hence the output file given by gcc
requires no extension. You may add whatever extension you want(by changing -o output_name
to say -o output_name.abcd
), but it is not going to mke any difference.
You can have a look at the output of the command
file ./filename
for example
:~$ file output_file
output_file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=9bc9fabf05a3d2e58c7780c48cd873cb2955b2ec, not stripped
:~$
It does not have one. You can do gcc -o myprog.exe filename.c
and it will be called myprog.exe
. Unlike Windows there is no default extension for executable files on Linux. If you want to mark a file as executable do chmod +x file
.
ls -l
shows you if the x
(executable) flag is set for your file:
user@host# ls -l filename
-rwxr-x--x 1 ubu users 42 Mai 10 08:16 filename
- means its a file (d would be directory,see below)
r means readable
w means writeable
x means executable
The first triple is for the owner (ubu
in this case),
the second triple is for the owning group (users) and the
last triple is for everyone else.
For directories the x
means "can enter directory", so if x
is not set you cannot do cd directory
.
On Linux File Extensions are not special, the are just part of the files name.
ls
has anything to do with this. It just shows file permissions. – Registered User May 10 '15 at 06:30