Question

After about a year of working with Ubuntu, this is a first for me. I took over a project that from car service that tracks repairs. I can see the entire source of every file, but there is a file that has no extension but in Ubuntu the properties say executable (application/x-executable). There is no extension in the file like .sh, if I try to open the file with Geany it says it does not look like a text file. If I open the file with Visual Studio on my VM it looks like a binary file. How does Ubuntu know it is an executable (application/x-executable)" file without no extension and how can I view the source to see what this file is doing?

Was it helpful?

Solution

There are a few concepts you need to know.

In Linux and other *nix a file is executable for a user if the user have execution privileges over the file.

Examples can be shell scripts, python scripts, compiled programs and any other file, you can give execution privileges to a image if you want (although it may not be very useful):

chmod +x image.jpg

An application or program is a sequence of instructions encoded in some language, it may be in a scripting language so it doesn't need compilation and you can open it with any text editor as geany, or it may be machine code (result of writing the program in a compiled language). In the last case the program is a binary file (ie a file which is not encoded in ASCII or any other codification meaningful to a normal text editor).

You can see the bytes of a binary programs encoded in hexadecimal with commands like hexdump or try to disassemble the program with objdump, but you can't see the original source code.

If the software you want to analyze is open source and you downloaded it from the Ubuntu repositories you can download its source code with:

apt-get source name_of_the_package

You can get the name of the package with:

dpkg -S /path/to/the/binary

The tools in Linux and many other O.S. can detect the type of a file either by their file extension or by reading a few special bytes from the file (many times the first two or three bytes are enough), those are called a magic number.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top