2

Correct me if I'm wrong, but one of the directories in which commands are stored in Ubuntu is /usr/bin. I tried viewing one of the ELF 64-bit LSB executable files (synergy) with nano but all I see is a mix of random symbols/letters. Can I view these files? If so, how do I go about it?

3
  • 3
    these are binary files and you can not open it in any editor.
    – g_p
    Mar 7, 2014 at 19:41
  • 2
    Why you want to edit them?
    – Braiam
    Mar 7, 2014 at 22:13
  • To understand how they function.
    – user253122
    Mar 9, 2014 at 21:01

2 Answers 2

8

The most files (if not all) from /usr/bin are binary executable files. Now, a binary file is a computer file that is not a text file; it may contain any type of data, encoded in binary form for computer storage and processing purposes (more about: Binary file).

So, if a binary file is not a text file, you can't use nano (or another text editor) to edit it (well, you can, but for sure you will not know what you are doing).

In Ubuntu (and Linux like operating systems in general) there are some applications called hexeditors, like GHex which can be used to view and edit files in two ways, hex or ascii:

enter image description here

Furthermore, you can transform vim in a hexeditor by typing :%!xxd inside of it (:%!xxd -r to go back to normal mode).

2

Files under /usr/bin that are not shell scripts are normally "real" executables, i.e. they contain machine code that is executed directly by the CPU (intermixed with some headers/structures used by the loader and dynamic linker to do their job)

You can open them with a hexadecimal editor, but normally you cannot do much with it; if you know about the ELF format the classic tool to check out properties of executables is objdump; objdump -x filename will print a lot of information about ELF headers, while the -d option will produce the disassembly of all the executable segments of the given executable. But again, either you are really expert and you are doing very specific things, or this is really useless. Executables are meant to be run by a computer, not read by a human.

What is more interesting, if you are programmer, is to get the source code (i.e. the code actually written by a human and then compiled to a binary executable) of a program you have installed, to check it out, apply patches, modify it, ... If your sources.list is configured appropriately and the source package is available (this is normally the case for all the packages provided in repos from "main" to "universe"), you can get the sources using the command apt-get source name_of_the_package.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .