LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-17-2019, 09:15 AM   #1
Agaar
LQ Newbie
 
Registered: Feb 2019
Location: I think am living on earth!!
Distribution: Kali Fedora Ubuntu, mostly fedora
Posts: 8

Rep: Reputation: Disabled
Question How to find the file type after compiling a .C file?


Hi, Can anyone tell what is the type of the file that we get after compiling a .C file and how do we find that ?
I used the gcc command to compile.
Ex:
gcc ex.c -o ex

And I new to linux so I don't know what is the extension. I am sure that is not .exe.
I used the following commands to find the type..

file *
file ex
ls
ls -l
ls -la

And I have another question. Can I encrypt a compiled c file? I know we can encrypt. But how do we decrypt that?
I encrypt that "ex" file. But I don't know how to decrypt.
We can decrypt the .txt file easily. But how to do that for a compiled file?

Thanks!!!
 
Old 02-17-2019, 09:25 AM   #2
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
If you used the -o option with gcc, then it will be an ELF executable file you will get, if it compiled properly. Otherwise it will be an a.out file instead.

You would use the file command to see what type of any file is.
 
2 members found this post helpful.
Old 02-17-2019, 09:30 AM   #3
Agaar
LQ Newbie
 
Registered: Feb 2019
Location: I think am living on earth!!
Distribution: Kali Fedora Ubuntu, mostly fedora
Posts: 8

Original Poster
Rep: Reputation: Disabled
Ok, But Why it showing ELF for a .TXT file?

Last edited by Agaar; 02-17-2019 at 09:31 AM.
 
Old 02-17-2019, 09:32 AM   #4
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
A .exe file is a Windows executable file - Linux uses ELF executables. Executable files in Linux don't have any file extension on the end of them.
 
1 members found this post helpful.
Old 02-17-2019, 09:34 AM   #5
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
Quote:
Originally Posted by Agaar View Post
Ok, But Why it showing ELF for a .TXT file?
Probably because you compiled it with the .txt file extension.
 
1 members found this post helpful.
Old 02-17-2019, 09:36 AM   #6
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,376
Blog Entries: 3

Rep: Reputation: 3772Reputation: 3772Reputation: 3772Reputation: 3772Reputation: 3772Reputation: 3772Reputation: 3772Reputation: 3772Reputation: 3772Reputation: 3772Reputation: 3772
Quote:
Originally Posted by Agaar View Post
Ok, But Why it showing ELF for a .TXT file?
Do you mean to say that the file includes .TXT at the end of its name? The name of the file has no relevance to the actual content. You can see the actual type using file as mentioned already and that you've listed yourself. Try:

Code:
file --mime ex
Where "ex" is the name of the file in question.
 
1 members found this post helpful.
Old 02-17-2019, 09:36 AM   #7
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by Agaar View Post
Hi, Can anyone tell what is the type of the file that we get after compiling a .C file and how do we find that ?
I used the gcc command to compile.
Ex:
gcc ex.c -o ex

And I new to linux so I don't know what is the extension. I am sure that is not .exe.
If you use the -o option that way the result does NOT have an extension, it will just plainly be called ex.
And it will be an ELF LSB executable, either 32-bit (if you're using a 32-bit distro) or 64-bit.

Last edited by ehartman; 02-17-2019 at 09:38 AM.
 
1 members found this post helpful.
Old 02-17-2019, 09:46 AM   #8
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by jsbjsb001 View Post
Executable files in Linux don't have any file extension on the end of them.
They could have, but normally they don't, indeed.
But, i.e. scripts that are executable often have a .sh (shell script), .pl (perl script) or .py (Python) extension and sometime, when the binary is not meant to be used directly it could have a .bin extension (or -bin, see for instance firefox). The actual call is then through a script (like /usr/bin/firefox).
 
1 members found this post helpful.
Old 02-17-2019, 09:51 AM   #9
Agaar
LQ Newbie
 
Registered: Feb 2019
Location: I think am living on earth!!
Distribution: Kali Fedora Ubuntu, mostly fedora
Posts: 8

Original Poster
Rep: Reputation: Disabled
Thnx brothers, I made a mistake, I said that the "file" command showing ELF Extension for a TXT file. It is showing, but that TXT file is a output of encrypted ELF file after decryption. So, sorry for that question. And tell me how to decrypt an encrypted ELF file using GnuPG?

Last edited by Agaar; 02-17-2019 at 09:53 AM.
 
Old 02-17-2019, 09:58 AM   #10
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by Agaar View Post
And tell me how to decrypt an encrypted ELF file using GnuPG?
You decrypt it by the opposite operation from the encrypt.
For instance if you used GnuPG with your PUBLIC key to encrypt, you use GnuPG again with your PRIVATE key to decrypt (as GPG is not symmetric, you always need "the other key" to do the opposite operation).
BTW: as you probably already discovered, encrypted executables can NOT be executed anymore.
 
1 members found this post helpful.
Old 02-17-2019, 10:00 AM   #11
Agaar
LQ Newbie
 
Registered: Feb 2019
Location: I think am living on earth!!
Distribution: Kali Fedora Ubuntu, mostly fedora
Posts: 8

Original Poster
Rep: Reputation: Disabled
Thanks brother!!! I expected this reply "encrypted executables can NOT be executed anymore"

Last edited by Agaar; 02-17-2019 at 10:13 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting Content-type/Mime type of the file using shellscript swathikumar Linux - Newbie 9 05-24-2011 11:48 PM
changing file system type to another filesystem type,does it effect on data? janakiramulu Ubuntu 1 02-04-2011 01:58 AM
Get file icon from extension, file type, or mime-type Guitarist88 Programming 3 04-21-2008 10:58 AM
"array type has incomplete element type" compiling 2.4.32 kernel Akabaka Linux - General 1 01-08-2006 12:48 PM
where I can find user type Access gorup type and access satishpatel Linux - General 0 04-07-2004 05:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration