Happy Hacker Digest -- Unix edition
November 9, 1999
_______________________________________________________________________
See the Happy Hacker web site at http://www.happyhacker.org
URL of the Week: http://micq.chatzone.org - Micq-the original
(and smallest) ICQ clone for
Linux
_______________________________________________________________________
Editor's Comments
Readers' Questions
Feature: Compiling Programs, Part 1
Next Issue
***********************************************************************
*** Editor's Comments
***********************************************************************
We're back! After a temporary pause in publication, the Happy
Hacker Unix Digest is back in print! My name is Mike Miller,
and as the new Editor, I hope to publish this digest at least
once per week, perhaps more, depending on incoming mail volume
and/or my schedule. I look forward to editing this
digest, and I hope to hear from many of you (not including flames...
don't waste your time or mine) soon.
A little bit about me. I'm a college sophomore, currently
working on my BS degree in Computer Engineering in New York City.
I am a hacker; I am not a criminal. I've worked for both private
companies and the US Government, including two military research
labs. At last count, I am tridecalingual (say
that ten times fast) in computers (i.e., I can program in 13
languages). I currently administer my own Unix box in my apartment;
it's an AMD K6/III-450 running Debian GNU/Linux 2.1. Hopefully,
sometime in the _very_ near future I'll write some more about
that... put in my plug for Debian as the Linux system of choice.
As I'm sure you know, this Digest is for all flavors of Unix.
Linux (all distribution), FreeBSD, OpenBSD, Solaris, whatever...
you questions are welcome. If you want to write up a little mini-article
about a feature of Unix you find really useful/cool, please send
it in. If you're unsure about how to accomplish a certain goal,
ask. If you want me to tell you how to break into other machines,
go away.
Needless to say, this first issue is, of course, short. I
plan on keeping up all the columns from previous issues, but
in the interest of letting everyone know we're alive again, and
doing it ASAP, I'm going to skip URL's, News, and just answer
two emails I got and write a quick article about compiling programs
in general. I'm awaiting your email to fill up the next Digest...
until then, happy hacking, and stay legal.
One final thing... if you send in a question, please give
as much info as possible about your system: type of Unix, version,
weird software running, etc.
***********************************************************************
*** Readers' Submissions
***********************************************************************
CoLdsLiMe@aol.com asks,
when ever i use the netstat command i get this:
input (1e0) output input
(Total) output
packets errs packets errs coll packets errs packets
errs colls
then after that there are all these numbers with 0 & also
sometimes 41 at the
the #'s and then it keeps on putting out #'s that end worth
0 under the
#'s that are
under packets. What is this and what does it mean
[Editor: I'm not exactly sure what you're asking... are you
wondering what the output means, or why there are so many 0's,
or why some numbers end in 41...? I'll summarize briefly what
the output means, but I can say right now that I've never seen
this 41 thing before. On my machine (at least one of them, which
happens to be running AIX), the command 'netstat -i 1' gives
the following output
$ netstat -i 1
input (en0) output input (Total) output
packets errs packets errs colls packets errs packets errs colls
52920114 0 43417975 0 0 59250956 0 49759326 0 0
after 1 second (the final parameter), it displays
96 0 74 0 0 194 0 172 0 0
and then,
92 0 81 0 0 140 0 129 0 0
and so on. I presume this was approximately what you typed
(although you typed -i <some other number> probably). I
assume you're basically familiar with what netstat -i does, namely,
reports input and output for your interface 1e0 (the default
interface) on your machine (en0 in my example). I'm guessing
1e0 is an Ethernet interface, but that's just a guess. The next
set is the total for _all_ interfaces. For each 'category', there
are several data items shown, namely, input packets, input errors,
output packets, output errors, and output collisions. The packet
column lists the total number of packets being sent in or out
on that connections; errs is the number of errors that occur.
The colls column indicates how many collisions occurred. A collision,
(parenthetically, this is not an issue with a point-to-point
connection like SLIP, PPP, or ATM), occurs when too many packets
are being sent out on the network. As a rule of thumb, if the
number of collisions is less than 5% of your total traffic, you're
probably OK. Anyway, I think that should explain it... if anyone
has anything to add, or if I missed something, please send it
in.]
-----------------------------------------------------------------------
Fox Curry (curry7_98@yahoo.com) asks,
Dear sir,
I have a ncr machine in my office but I forgot the root passwd.
I think there is no method except I can crash it, so, I searched
some URLs, but no way is found to help me. would you like to
help me to do it or give me some suggestions to crash it?
the following is needed, if you have interest to
>uname -a
UNIX_SV virgo 4.0 3.0 3435 Pentium(TM)-MCA
the OS version is: MP-RAS 3.0.1
[Editor: Well, the simplest way I know to crash a machine
is to push the reset button... if it really is in your office,
that is. If it's not, and you can't physically get to the console...
well... maybe you shouldn't really be messing with it, eh?]
***********************************************************************
*** Compiling Programs, Part 1
***********************************************************************
One of the most important things a Unix user needs to be able
to do is compile new programs. Yes, you can often download a
precompiled binary, but often you'll need the source code, either
because your flavor of Unix isn't compiled, or perhaps you have
a different processor-whatever. First I'll define a few terms.
All programs are written in what's called "source code."
This is programming language code (usually C or C++), and contains
statements such as:
#include <stdio.h>
main ()
{
printf("Hello World");
}
Note that the computer can't understand this. The above code,
written in C, instructs the computer to print the message "Hello
World" (w/o the quotes), and then exit. But in order to
run, two things need to be done. First, it needs to be 'compiled'.
That means it'll be converted by the compiler (usually gcc) to
what's known as an object file, which ends in .o (source code
usually ends in .c or .cpp). Then a linker (usually ld) connects
the functions mentioned in the object file to their sources in
libraries, producing a file that can be run. If this seems complicated,
don't worry-you don't need to remember all that to compile your
own programs.
Most (well, all well packaged programs, at least) packages
include what's known as a Makefile. This file tells the computer
how to compile the program, and any other commands needed (e.g.,
where to copy the compiled binary to). If a program doesn't include
a Makefile, it will usually come with a script called 'configure',
which automatically tests your environment, and creates the appropriate
Makefile. To run configure, you just type ./configure in the
source directory (parenthetically, see Carolyn Meinel's QuickTip
in the AntiOnline archive for why users, specifically root, should
not have the current directory in their path). Configure has
many options... type configure --help to see many of them. I'll
just single out one here. The --prefix=/installdir is very useful
if you're compiling programs on a shell account. By default,
most programs want to install themselves to /usr/bin, /usr/local/bin,
or somewhere else public, usually in the /usr subdirectory. This
is good if you're an admin installing code for all your users.
But what if you are on a shell account, and only want this code
for yourself, and/or you can't 'su root' to gain write access
to /usr? What you would do is type './configure --prefix=/mydir'
(w/o the quotes, of course), and then it would install to your
directory. If your program doesn't include configure (and most
simple packages don't), then look for a line in the Makefile
that says something like:
INSTALL_DIR=/usr/local
and change it as appropriate.
Now that you're ready to compile, type 'make' (or gmake to
use the GNU make, if it's available). Hopefully, you won't get
an errors (there are almost always a few warnings, but you can
usually ignore them). If it works, there should be a binary now
located somewhere. By typing 'make install', you can (usually)
have make execute the required commands to install the program
in the appropriate binary directory. A few other useful "targets",
as they are known, are:
make clean - deletes the object files, preparing the source
directory for a fresh compilation
make uninstall - removes the program file
To see what targets are available, browse through the Makefile
for lines that say things like:
all :
<whatever>
clean :
<something>
uninstall :
<mode code>
The colon indicates a target (very similar to the goto statement
or switch / switch case (if there are any programmers reading
this)).
Hopefully, you now know enough to compile basic programs.
Future digests will cover more advance Makefile usages, and how
to debug a Makefile. Until then... get out on the 'net, and try
a compilation or two! Micq (mentioned as the URL of the week)
is a great starting program... it requires almost nothing (except
GNU make, which most systems have), and is a very simple program
to run. It's also remarkably useful! So try it out, and send
matt (the author of the program) a message saying the happyhacker
editor likes his software.
***********************************************************************
*** Next Issue
***********************************************************************
*Readers Comments
*Questions
*More Compiling Stuff
*Whatever else I can think of
_______________________________________________________________________
To subscribe to the Happy Hacker Digest, email mailman@mailout.antionline.net
with the message "subscribe happyhacker." Unsubscribe
with message unsubscribe happyhacker.
This is a list devoted to *legal* hacking! If anyone plans
to use any information in this Digest or at our Web site to commit
crime, go away! We like to put computer criminals behind bars
where they belong!
Hacker Wargame Directors, Vincent Larsen vincent@sage-inc.com
and John Vranesevich <jp@antionline.com>;
Clown Princess: Carolyn Meinel <>
Happy Hacker is a projecy of a 501 (c) (3) tax deductible
organization
_______________________________________________________________________