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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Sorry if this is a wierd question. Suppose if I am writing a script called
myscript.sh and if I put it to /bin directory and if I just type:
it works. So, if i open it via
[ ]#vi /bin/myscript
....I can see its contents... my question is why it is not possible to open an executable command, say, /bin/ls like this?. Is there any other way to see the source code of it?...
You script has not been compiled, binaires have been. You can look at the source code of the binaires. In Rpm based systems you do this by looking at the src rpm of the package that the binary came from.
lazlow, thanks for the quick reply...
I got the point related to compilation of the script, but the second one, that is, viewing the source code...
suppose if i want to look at the source code of /bin/ls. Its rpm package is coreutils. So how to go about with that src rpm thing. Could u pls eloborate...?
To extend what lazlow already said, there's a difference between scripts and binary object files. Or more correctly, there's a different between interpreted languages and compiled ones.
Technically you could write an interpreter or a compiler for any language, but tipically some languages are compiled, and some others are interpreted. An interpreter takes a file that's written in the language and translates it to a language that the machine can understand in the same moment that you run the file. A compiler, on the contrary, takes the source file and translates it to machine object code permanently, producing a binary file (in windows this is tipically a .exe, .dll, .vbx or whatever suits the occasion). Then you run that file which doesn't need to be translated anymore.
Compiled programs are usually faster since they don't need to be translated to machine code when you run them. They can also be optimized in lots of ways since the compilation time is not really important. On the contrary, an interpreter can't spend a whole life to interpret a program, otherwise the user might think that his core7 is an amstrad loading from a tape.
Binary files are not human readable, you can always see the bytes with an hex editor though, and you could always use a dissassembler to read the instructions in an easier way.
If you want to get the source code for a program, visit their website. It's the logical place to start looking. However this is only true for open source stuff. Closed source programs do not make their sources available to the public.
If I download the coreutils src.rpm and then extract it, I will find the file coreutils-5.97.tar.bz2. If I extract that file(coreutils-5.97.tar.bz2) I will find the ls.c and ls.h files(in the src directory of the extracted portion).