LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 03-24-2015, 10:07 PM   #1
arun natarajan
Member
 
Registered: Jun 2014
Posts: 105

Rep: Reputation: Disabled
Contents fo executable files


Hi All,

Is there a way to look into the contents of cmds under /bin (touch, usermod, cp) which we are executing for administration tasks. If yes, how ?

FYR: Attached the same when i ve tried for the same.


[root@localhost arun]# head -5 /usr/sbin/usermod
ELF>'@2%%k${%* 4*9~El%7 Z,[:`)#@@44Qt/lib64/ld-linux-x86-64.so.2GNU wšADL{~n/t|CE *%T%U
3c)r@BITf%2K%2%QA=l
%~c%F* ] %Iڼ.%7'*%e]nJ[*SJQCBY1!u)%e*7| ~Kl*;\
%%h"@$@:~akxarxah
ti=uiU7=*aaaaaa a(a0a8a@HaaUPaaU7=PU7=x`U7=U7=U7=a8=a7=M'7=7=K'7=7=*G'Xa 7=*P'7=п7=&'7=ii
`a
paxaaaaa*aaaaaaaaaaa a!aa#a$aw a%(a&0a'8a(@a)Ha*Pa+Xa,`a-ha.pa/xa0a1a2a3a4*a5a6a7a8a9a:a;a<a=a>axa?aaAaBaC aD(aE0aF8aG@aHHaIPaJXaK`aLhaMpaNxaOaPaQaRaS*aTaUaVaWaXaYH5 % @% h% h% h% h% h*% h% h% hp%z `%r hTTYavHP%j h
@%b h
0%Z h
%J h%B h%: h%2 h%* h%" h% h*% h%
h% hp% h`% hP% h@% h0% h % h% h% h% h % h!% h"% h#% h$*% h%% h&% h'p%z h(`%r h)P%j h*@%b h+0%Z h, %R h-%J h.%B h/%: h0%2 h1%* h2%" h3% h4*% h5%
PuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTY PuTTYPuTTYPuTTYPuTTY[rYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuT TYPuTTYPuTTYPuTTYPuTT
bash: PuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTY PuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTY: command not found
[root@localhost arun]#
 
Old 03-24-2015, 11:51 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,917

Rep: Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429
why would you expect a ascii TEXT editor to read hex binary data

if you really want to READ the hex code
use a hex editor

"hexedit"
"Ghex"
"wxhexeditor"

one of those should be in your OS's repos

but
this is NOT !!!!
it is NOT human readable data

- there are a few that can program in hex
 
Old 03-25-2015, 01:09 AM   #3
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
In linux you should see the binary sources which provided by your distro.

Hexdump can used to dump the hex code equivalent of binary file.
 
Old 03-25-2015, 07:05 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,638

Rep: Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252
It depends on what you are looking for.

You can always use the debugger (unless you can't read the file).

You can always use the "strings" command to find the ascii text (or what appears to be ascii text) in the file.
 
Old 03-25-2015, 10:18 PM   #5
maples
Member
 
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 811

Rep: Reputation: 264Reputation: 264Reputation: 264
I don't think I've ever seen the user panel on the left compressed so much....

If you want to see the actual code that gets run, it's all open-source. Usually Google is a good place to start.

Some commands, like usermod, are parts of a larger group. From looking at the man page (the very last line on the left), on my system usermod is part of "shadow-utils." It's not the actual package name (at least on my system, Arch) but it's a good place to start searching on Google.
 
Old 03-26-2015, 05:47 PM   #6
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 812

Rep: Reputation: 216Reputation: 216Reputation: 216
It depends what you mean by "contents". If you are actually not interested in source code but only want to look for the presence of certain strings, there is the amazing "strings" command.

Run
Code:
strings /path/to/binary/file
It will look for actual text in the binary and print it to stdout...
 
Old 03-26-2015, 05:58 PM   #7
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: Slackware
Posts: 7,100

Rep: Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600
The file command will tell you what format these *ahem* files are in. Files that aren't in plain text cannot be viewed using tools meant to display plain text.

The file command itself, as you can see, is in binary format and cannot be viewed as plain text.

Code:
bash-4.1$ file $( which file )
/usr/bin/file: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
Whereas startx is a text file and can be viewed:

Code:
bash-4.1$ file $( which startx )
/usr/bin/startx: POSIX shell script text executable
To get the source code for the "cp" command, I'd honestly just google "source code for cp command". Source code, as you know, needs to be compiled to a non-human-readable binary format before it can be run. Compilation is not a reversible process. The "cp" in your installation is in that runnable, binary, non-human-readable format.

The source code for "cp" is here:

http://git.savannah.gnu.org/cgit/cor.../tree/src/cp.c

Last edited by dugan; 03-26-2015 at 06:09 PM.
 
Old 03-26-2015, 06:21 PM   #8
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,387
Blog Entries: 10

Rep: Reputation: 2042Reputation: 2042Reputation: 2042Reputation: 2042Reputation: 2042Reputation: 2042Reputation: 2042Reputation: 2042Reputation: 2042Reputation: 2042Reputation: 2042
Quote:
Originally Posted by arun natarajan View Post
Is there a way to look into the contents of cmds under /bin (touch, usermod, cp) which we are executing for administration tasks. If yes, how ?
Why?
 
Old 03-26-2015, 08:39 PM   #9
maples
Member
 
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 811

Rep: Reputation: 264Reputation: 264Reputation: 264
Quote:
Originally Posted by dugan View Post
Compilation is not a reversible process.
Aren't there programs that can de-compile programs to a certain extent? https://en.wikipedia.org/wiki/Decompiler
 
Old 03-26-2015, 08:47 PM   #10
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: Slackware
Posts: 7,100

Rep: Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600
Quote:
Originally Posted by maples View Post
Aren't there programs that can de-compile programs to a certain extent? https://en.wikipedia.org/wiki/Decompiler
I don't know why people always bring these up. I'm 100 sure that these are not what the OP is looking for.

But if it is, well, now the OP knows about that option.

Last edited by dugan; 03-26-2015 at 08:48 PM.
 
Old 03-26-2015, 09:02 PM   #11
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,638

Rep: Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252Reputation: 1252
Quote:
Originally Posted by maples View Post
Aren't there programs that can de-compile programs to a certain extent? https://en.wikipedia.org/wiki/Decompiler
Again, WHY.

You can GET the source to the utilities if you want.
 
Old 03-26-2015, 09:04 PM   #12
maples
Member
 
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 811

Rep: Reputation: 264Reputation: 264Reputation: 264
Quote:
Originally Posted by dugan View Post
I don't know why people always bring these up. I'm 100 sure that these are not what the OP is looking for.

But if it is, well, now the OP knows about that option.
What is happening with LQ and percent signs?
%
%%
100%
100%%
One hundred %

And why is it working now?
 
Old 03-27-2015, 12:31 AM   #13
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.1
Posts: 7,453
Blog Entries: 55

Rep: Reputation: Disabled
Quote:
Originally Posted by maples View Post
What is happening with LQ and percent signs?

%%
100%
100%%
One hundred %

And why is it working now?
I had the same problem in this thread:
http://www.linuxquestions.org/questi...ml#post5328704

OT:
Isn't insomnia a wonderful thing?
Huh? NO!

Last edited by brianL; 03-27-2015 at 12:35 AM.
 
Old 03-27-2015, 01:54 AM   #14
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
I posted a bug report about this '%' character problem. And Jeremy said he can't reproduce it.

This happens in 'Quick Reply' but not 'Post Reply'.
 
2 members found this post helpful.
Old 03-27-2015, 01:54 PM   #15
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,301
Blog Entries: 10

Rep: Reputation: 1614Reputation: 1614Reputation: 1614Reputation: 1614Reputation: 1614Reputation: 1614Reputation: 1614Reputation: 1614Reputation: 1614Reputation: 1614Reputation: 1614
Quote:
Originally Posted by arun natarajan View Post
Is there a way to look into the contents of cmds under /bin (touch, usermod, cp) which we are executing for administration tasks. If yes, how ?
No, there generally is not. Most of the commands are in binary form, however they started out as source. Search for the source. Why do you want to look at a particular command? To understand the command better? To determine if there is a bug in how that command works? Or something else? There are manual pages on many commands. Also be cautious what commands and the situation under which you wish to know about them. There are versions of commands in binary form and sometimes these very same commands are abstracted under something like Busybox, or they are not actual binaries but links to other files, or short scripts.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Using Expect/TCL to move contents of a text file to an executable file jefsa Linux - Newbie 4 04-20-2012 11:43 AM
Force executable .exe files when creating .iso files? red hat flyfisherman Linux - General 6 12-01-2011 07:10 PM
Executable files @er<> Linux - Newbie 2 03-10-2007 07:35 PM
Converting perl files to executable mac files mrozkan Programming 0 04-16-2002 10:56 AM


All times are GMT -5. The time now is 06:02 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration