Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

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

2 Answers 2

up vote 7 down vote accepted

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).

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.