[SOLVED] How to find the file type after compiling a .C file?
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881
Rep:
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.
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:
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.
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).
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.