Appendix P.  Answers to all the exercises
 
 
 
Chapter 1 (14) Chapter 5 (26) Chapter 9 (30)
Chapter 2 (23) Chapter 6 (35) Chapter 10 (10)
Chapter 3 (65) Chapter 7 (20) Chapter 11 (20)
Chapter 4 (12) Chapter 8 (15) Chapter 12 (31)
There are 301 questions with answer.
Chapter 1

1.What are the difference between interpreted and compiled programs?.

A compiled program is a binary with its symbolic data. An interpreted is "compiled" on run time (interpreted).

2.Where are located system binaries?

In various places: "/sbin".

3.The "vi" is a system binary (/sbin), a basic binary (/bin) or a user binary (/usr/bin) ?

Is a user binary.

4.Where is located the "chmod" binary program is a system binary (/sbin), a basic binary (/bin) or a user binary (/usr/bin) ?

Is a system binary.

5.What is the word in C syntax to represent the principal procedure?

main()

6.What is the word in C syntax to represent the arguments (or parameters) that the user add in the command line when run the program ?. What variable contains the number of arguments?

argv and argc. The second contains the number.

7.What is the word in C syntax to add and get the environment?

env

8.What is the C function to transform strings to numbers?

strtol

9.Why is necessary to use strcpy before to transform argv[1] to an integer?

Because is not allocated.

10.What is the content of argv[0] ?

the program name

11.What is the C operator for the rest in an integer division?

/

12.What is the C++ operator to print output? and to read ?

cout to print and cin to read.

13.What is the flow chart element for a cycle ?

A rectangle + two triangles for each side.

14.Write a program to print a table of sinus and cosines from 0 to 100.

main ()
{
    int i;

    for (i=0; i<=100; i++){
       x = atof(i);
        printf ("%f %f\n", sin(x), cos(x));
    }

}

Chapter 2

1.What is a pointer ?.

The Pointer is a variable that contains the address of another variable

2.Is possible to have a pointer to an integer variable: 'int * p"?

Yes.

3.Is possible to define in C data type called 'address' including company name, address and other similar data ?

Yes. To define it we need to write a structure.

4.What returns the sizeof () ?

The size of the C type or of a user defined type.

5.The int data type is a long or a short ?

Is a long

6.When happens a Segmentation fault (SEGV)?

This happens when we try to use or write or an illegal place that does not exist.

7.What is a core file ?

The core file is a file that represent the symbolic information.

8.When is created a core file?

In the local directory.

9.When happens a Bus error ?

A Bus error happens when we try to use a library in an illegal mode.

10.What is the command to build a library ?

ar

11.What is the command to list the objects inside an object ?

nm

12.What is a shared library ?

A shared library is loaded in memory and available to any user.

13.What users can use the shared library ?

All users.

14.What is the command to run after the shared library compilation ?

libtool

15.What file resume the shared libraries present in the system?

/etc/ld.so.cache

16.What command create this file ?

ldconfig

17.Describe unsigned int and signed int variables ? What is the difference ?

Are C types. signed means that must be also negative.

18.Describe unsigned char ?

An unsigned char is the most short char.

19.Is possible to alloc an entire structure ?

Of course.

20.Is possible copy or duplicate an entire structure ?

Of course using

21.Is possible to print a entire structure with a single command ?

No.

22.How you can print a "30% of 12 is 3.6", using printf ?

printf ("%3.6f", 0.3*12);

23. Are there some GNU High Precision Mathematical library?

Yes, it is called GMP.

Chapter 3

1.What package includes the libc.a (C Lib) ?

glbc

2.What are the three necessary components to develop programs in C and C++ in Linux systems ?

The GNU GCC, The GLIBC and the libstdc++

3.Why GNU GCC 3.1 compiler is so important ?

GNU GCC 3.1 open the development to be 100% complaint with ABI C++, for the first time implemented in full.

4.What is the company that have the role to certify and test the GNU GCC ?

Codesourcey

5.What languages supports the GNU GCC 3.1 tarball ?

C, C++, Java, Fortran and Ada. Also Objc is supported while Chill was removed.

6.Why is important to have a C-Preprocessor ?

Is fundamental to explode the defines.

7.What program may be used to investigate what are the functions included in the libc.a ?

nm

8.The vi uses the libc.a ?

Of course.

9.What UNIX/Linux utilitiy may list objects inside a library ? Is this utility inolved in the Linux kernel generation ?

nm. Yes, nm is involved in the kernel generation.

10.What packages includes the C Lib "/usr/lib/libc.a" ?

glibc

11.Suppose that we want to compile a C source that includes the file "stdio.h". What will be the command to compile it ?

gcc file.c -o file

12.What will be the command to run this "just compiled" program ?

./file

13.What is the flag to add new include files ?

-Inewinclude

14.What is the flag to add new libraries in the compilation time ?

-L/usr/lib libXmyhouse.a

15.What is the GNU GCC option to create the binary ?

-o (No object, just binary).

16.What is the GCC Enviroment variable ?

CFLAG

17.What is the Enviroment variable for Libraries ?

LD_LIBRARY_PATH

18.We use a variable called BUFSIZ to read file, as a normal or maximal buffer size. Are there a similar variable for DIRSIZ ? What means ?

Not in all UNIX systems. Linux OS, have a similar variable but only inside the kernel hierarchy.

19.What is the character to terminate a string ?

'\0'.

20.Is there available a function to generate RANDOM number ? What includes file we must includes ?

Yes, rand()

21.What is FILE ... speaking in C language ? How long is (bytes) ? What C function print it size ?

FILE is a structure defined using a typedef from IO_FILE. Is 4 bytes long. The C function to print the size is sizeof.

22.What system is handled by the file "pwd.h" ? Working dir ?

The "/etc/passwd" file.

23.What you suppose is the size for a character ? What is the correct size for a character ?

1 byte and is that.

24.List three elements for the FILE type.

25.What is the FILENAME_MAX value ?

stdio_lim.h:# define FILENAME_MAX 4095

26.What C structure handle the file properties, owner,group and other ? What includes file define this type ?

Is the stat structure. The include file is: bits/stat

27.Would be possible that an include file includes another include file ? If so, Why happens this ?

Yes, this is the normal method. This happens to simplify the work to programmers that will includes a simple include.

28.What is the difference between #include <stdio.h> and #include "stdio.h" ?

The first file is located in "/usr/include", while the second is local.

29.Would we need to include the "libc.a" in the compilation, like "gcc myfile.c -l lc" or something similar ?

No, is implicit linked.

30.Where are defined the stderr, stdin and stdout ?

In stdio.h

31.What are the minimum RPM packages to develop C programs ?

gcc and glibc

32.The program "rpm" needs the libc to run ?

Yes.

33.Suppose that someone removes the libc.a ... how is possible to copy the lib in the original place?

Is necessary to copy libc.a to the right place.

34.What include file list the fopen function ?

stdio.h

35.What does the function "strtok" ?

This function split a string in tokens.

36. Are there some function in the C Library to get the hyperbolic sine ?

Yes.

37.Are there a function to print the BASIC function INT(X) ?

Yes.

38.Is clear to suppose that C lib includes a define for mathematical constants as PI, E, and others. What is the number of decimals on PI?

Logically, in math.h

39.What include file includes the "malloc" and "calloc" functions? What is the difference between these functions ?

stdlib.h. The difference is that the "calloc" format the elements, the malloc don't.

40.Are there some special functions to integer arithmetic (without to touch floats and doubles) ?

Yes, the ldiv in stdlib.

41.Are there some function to transform numbers likes "1234" in their relative string "1234" ?

Yes, atoi.

42.How we can transform strings like "1234" in numbers ?

strtol may be used.

43.Would be possible to duplicate an entire struct using a single C library function ?

Yes, it is possible with memcpy.

44. Are the signal functions connected in some way to the program "kill" ?

Of course. The kill program uses signal to stop and remove the program from the process table.

45.List one function included in the file "stdlib.h".

malloc()

46.Are the strcpy, strtok function that belong to the libc?

Of course.

47.Fix in your mind the printf, that prints any quantity of arguments. How or what is possible? Using what function or declaration ?

These functions uses va_arg.

48.What language compiles the g77 compiler ?

FORTRAN.

49.What command or parameter is used to create a shared library?

libtool

50.What is the difference between libc.a and libc.so ?

One is static and the last is shared.

51.Is libc.a stripped? Have sense this question?

Of course. Yes, have sense.

52.The Linux kernel is stripped? Have sense this question?

Yes, in the sense that does not contains symbols. Only in this sense because is not a binary.

53.What is the C function to read and set the file permissions ?

This is made using the stat structures.

54.What is an API ?

API stand for Application Program Interface.

55.What is an ABI ?

ABI stand for Application Binary Interface.

56.How we can solve the C error:
              procquery.c: In function `display_link':
           procquery.c:120: dereferencing pointer to incomplete type
           procquery.c:120: dereferencing pointer to incomplete type

Need a cast.

57.What does the tool "size" ?

Prints the size for the symbolic data: text and data.

58.What does the tool "strip" ?

Removes all the symbolic information.

59.What is the package that includes these tools ?

binutils.

60.What is GNU BFD ?

Is the GNU specification format to copy object files each others.

61.Is possible to copy data between objects ?

Yes.

62.Would the size for symbolic info changes after the stripping process ?

No.

63.Is GNU GCC included in LSB (Linux Standard Specifications) 1.2 ?

No. But will be included in 1.3 Specification.

64.Are there some C function that prints the number of occurence of a string in another ?

Yes. It is called "index".

65.What is the version of the RedHat GCC gaffe compiler ?

2.96

Chapter 4

1.What is the C function allocate memory ?

malloc. However, also the calloc is used.

2. List three C functions to allocate memory.

malloc, calloc, memcpy.

3. What is the C function to free the allocated space ?

free

4. What is the C function to copy two structures ?

memcpy.

5. Is possible that some development libraries includes its own Malloc/Calloc functions ?

Of course. The X Window System uses its own Malloc and Calloc functions.

6. What is the "memcpy" role ?

The role of this function is to copy/reproduce a memory allocation, like a string or an entire structure.

7. What does the "bcopy" function ?

Is a function to copy data.

8. What is wrong in the examples for malloc and memcpy ?

The memory must be released when the program finish with a free call.

9. List the most three important advanced programming techniques.

Sorting, Search and Queues.

10. List four possible method of sorting.

Selection, Insertion, Bubble and Quicksort.

11.Describe the method of sort called "selection".

This method locate the smallest element and exchange with the first element. Then, second smallest with the second, etc.

12. Are there a C function for sorting data ?

Yes, the C Library uses the qsort.

13.List three method of searching.

Binary, sequential and List.

14.Why is necessary to insert data in search algorithms ?

Because sometimes a data may content a duplicate key and must be deleted and re-inserted.

15.What is FIFO ? What is LILO ?

FIFO stand for First-In-First-Out. LILO stand for Last-In-Last-Out.

Chapter 5

1.What is a debugger ?

A debugger is a program to locate misfunctions inside code. Basically any programming language includes its debugger. However, "gdb" debug, C, C++, Fortran, Java and Ada.

2.Why was invented ?

For bad programmers :). Opps. Was invented because sometimes may be necessary to locate errors inside program coding.

3.Any compiled program would be debuggable ?

No. Must be compiled with "-g".

4.Would be necessary to add some special flag at compilation time to debug the program ?

Yes, "-g" is the necessary flag.

5.Would be possible to install themes with "ddd" ?

Yes.

6.What are "ddd" and "xxgdb" program about the gdb ?

These programs are front-end to the gdb.

7.Would be possible to restart the debugging process after we start ?

Yes. Simply hit run again.

8.Is possible to print a structure using a debugger ?

Yes. Should be necessary to use "print *"
 

9.What is the core file ?

A core file is a dumped information when a program fails.

10.List seven common buttons or instructions in debugger ?

continue, stack, up, down, run, display, next.

11.Describe a common debugging session.

12.What is the difference between "step" and "next" ?

Step is a single instruction. Next execute the function if any. If no function is under the line step is equivalent to next.

13.What does "down" and "up" commands ?

"down" back to the previous level in the created stack. "up" back up.

14.What does the "display" debugger command ?

Add a variable in the display stack, visualizing at any change.

15.Where we get the program output ?

Inside the the same tracing code window.

16.How we can add arguments when we debug a program ?

The command will be: run programname arg1 arg2 arg3.

17.Is possible to know the data type from the debugger ?

Yes, execute: "what is db[i]"

18.What does the "stack" command, inside a debugger session ?

Prints the stack of functions: main, func1, ... until actual function.

19.Is possible to edit the source from the debugger ?

Yes.

20.Is possible to modify and recompile the source from the debugger ?

Yes. Also externally.

21.What results we will get ... if we are compiling a binary and debuggin the same binary? It is possible ?

Yes, is possible. If the source is unchanged we will not get differences or troubles. If the source changes we need to reload the source, otherwise
will be different the code position inside the execution.

22.What is the Linux command that set the filesize for a core ?

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

inside /etc/profile.

23.What company or organization develop the "gdb" ?

The Free Software Foundation.

24.What happens if we built a binary with a "i386-redhat-linux" compiler and try to debug with a "i386-ftosx-linux" debugger ? What is the relevant element in the discussion ?

If is a question of name, nothing will happens. The question is important because the debugger is "gdb", and this must stable and must represent the distro.

25.How is the normal mode to debug a graphical application ?

The best mode is to add a messageBox if necessary. Generally on C++ is the more frequent that normal debugging.

26.Is possible to debug a Tcl source ?

Yes, the Tcl inventor and maintainer invent a Tcl debugger. However, is possible to use and develop also large Tcl programs, without debugging.
 

Chapter 6

1.Who was the C++ inventor ?

Dr. Bjarne Stroustrup

2.How is the correct mode to includes files in C++ programs ?

From version 3, is used only the <X> instead the <X.h>, like in C.

3.What means "namespace" ?

namespace is a new convention to use the standard C++ library ("using namespace std"), or other.

4.What means "using namespace std" ? Why is important ?

Please, use (or apply) the std convention to each component in this source. Is important because we can mix C and C++ includes, and automatically will be used
the right component in the source.

5.Is possible to write C++ code that includes C include files ?

Yes.

6.What is a Class?

A class is the C++ base mode to define objects, like strings, numbers or any type of data.

7.Is necessary that C++ programs have a "cpp" extension is also "c" extension will work ?

No.

8.What means operator overloading ?

Is the "normal" mode to overload an operator re-defining its use.

9.How we add comments in C++ source ? Would be possible to use it also in C code ?

With the "//" at the end of the comment, in any position. It be used also in C code.

10.Is possible to use structures in C++ ?

Of course.

11.Is possible to "add" strings as numbers in C++?  Why now is possible ?

Yes. It is possible now because the "+" operator between string had been changed or re-defined.

12.What is this pointer ?

A pointer is a variable that point to a memory position.

13.What is the name of the GNU C++ compiler ?

g++ (also c++)

14.When you compile a C++ program and use a normal C function like "isalpha" or "fopen" ... are you using C #includes or C++ #includes ?

Anything is possible if you know what you do.

15.Where are located the includes files for the C++ compiler ?

/usr/include/g++-v3 (also v2) is included.

16.What is a constructor ?

A constructor is the first class member that define it (haves the same class name) and is used to add (or allocate) data following the class definition.

17.What is a destructor ?

Is a class member that deallocate, free or destroy the allocated class info.

18.The C++ operator cout is used with << or with >> ?

With "<<".

19.What is a template ?

A template is a normal mode to be adopted to define a class.

20.What means inline ?

"inline" is used to simply a class member definition, defined in-class.

21.What is the C++ Standard Library ?

libstdc++

22.List five include files that end with "stream" ?

iostream, fstream, istream, ostream and sstream.

23.Would be possible to use Complex numbers (a+ib) with the standard library ?

Yes, but generally need to be overloaded.

24.Would be possible to work with Complex number in C++ problems ... or we will need to re-implement ?

We need to re-implement (or overload).

25.Is possible that a derived class become a base class ?

No.

26.What is the heap ?

The heap is whrere virtual classes are allocated.

27.Would be possible to debug C++ programs ?

Of course.

28.What means "book:book" ?

Is a constructor main declaration in the class called "book".

29.List four C++ Compilers ?

Microsoft, Borland, GNU GCC and Apple.

30.What is the language used by OpenOffice (FTOffice) ?

Generally, C++.

31.In what language was developed the Troll Qt libraries ?

In C++.

32.In what language was developed Motif ?

In C.

33.Why C++ is a better language for the development of graphical interfaces ?

Because is object oriented.

34.When was invented C++ ?

In 1987.

35.What means "this" in the following expression ?
         template<typename _Tp>
           inline complex<double>&
           complex<double>::operator+=(const complex<_Tp>& __z)
           {
             __real__ _M_value += __z.real();
             __imag__ _M_value += __z.imag();
             return *this;
           }

Is the return pointer, the result.

Chapter 7

1.What is make ?

"make" is a tool to simply development and project handling.

2.What is make a command or a program?

"make" is a program.

3.What file must be present to run "make" ?

Basically, the necessary file is "Makefile".

4.Is necessary that the "Makefile" exist ... or it is possible in some cases to run "make" without it ?

Is not necessary that exist. It is also possible to run Makefile, in "implicit" mode.

5.What is the main goal make ?

To handle projects running a single command "make".

6.Is possible to control TeX source with make ?

Yes.

7.What is the command to create the Makefile, when we note an "Imakefile" in the dir ?

"xmkmf"
 

8.What is the makefile command (or option) to generate Makefile in a X11 Directory tree ?

"make Makefiles"

9.Is possible to use "define" inside Makefiles ?

Yes.

10.Is possible to touch a file with a specific date, for example: Fri, Sep 21 2001, instead of the current time ?

Yes.

11.What is the make parameter to execute make in "test" mode ?

make -n

12.Suppose the Makefile is called: "MySpecialMakefile". What is the command to use this file instead another Makefile ?

"make -f MySpecialMakefile"

13.What is the command to run Makefile in "silent" mode, without to print messages/errors, if any ?

"make -s"

14.Would be possible to pack the current hierarchy (tar cvfz) from the makefile ?

Yes. The Linux Kernel Makefile uses this feature.

15.Would makefile works with C++ files ?

Of course.

16.Are there available some tool to generate a Makefile ?

Yes, "automake"

17.Are there some tool to generate a "configure" file ?

Yes, "autoconf"

18.List one project where both "autoconf" and "automake" commands are used ?

The RPM project uses both. There are different projects that uses both tools.

19.What does "autoconf" ?

Create a "configure" file.

20.What is aclocal and what package includes it ?

"aclocal" create a M4 configuration. It is included in "automake".

Chapter 8

1. What is the fork() ? What does ?

The fork is the system call that create a new task on the processor.

2. What is the system () ?

The system, is the most simple mode to launch a new function.

3. What is the popen () ?

The popen, opens a pipe, and allows to handle process.

4. What means the "p" in the "popen" system call ?

pipe.

5. What signal () and popen () are ?

system calls.

6. List three functions used to execute programs.

execv, execvp, execl.

7. Some programs written in this chapter may be written also BASH Shell programming. What programs will be faster C binaries or shell scripts ?

Binaries developed in C are faster than Shell scripts. To understand why, think that the binary will be a single command, while the shell need to call different commands.

8. Describe the mode to use a fork () ?

9. What does getpid () ?

Is the system call that returns the PID (Process ID).

10. What is the command to visualize the "kill" manual entry for programmers (so the manul entry for users) ?

man 2 kill

11. What does the "unlink"  system call ?

removes a file.

12. Are there a "pclose" ?

Yes. Is normal that after we close and process the popen output we close the pipe.

13.What is the role "ioctl" function ?

This function handle the device parameter.

14.Would be possible to set the process group? Using what function ?

Yes, using the setpgpid().

15.What returns the getpid () ?

Returns the process id of the programs that call it.

Chapter 9

1. What is a socket ?

A socket is a Network API that creat a socket file to share information.

2. What does listen ?

listen opens the socket and get the info.

3. Are these structures also used in Internet ?

Basically, yes.

4. List three functions call relative a Network API.

connect, send, listen.

5. What is AF_UNIX ?

Is a socket type.

6. Are created some file in the socket implementation? If so what is the name and what is the file type ?

Yes. Is a socket file.

7. List one project where these files are present.

KDE.

8. Are there one structure to define a socket, or there are various ?

There are differen structures.

9. List one Linux programs that uses "sockets".

arp.

10. What is the shared memory ?

The shared memory is a Inter-process technique capable to use the system memory and to share info between users.

11. What may be an usage for the message queue?

send message between applications, like a client/server.

12. List the two types of message queue.

POSIX and SySV.

13. What is a semaphore ?

A semaphore is a IPC technique that enable/disable transit using the appropriate system calls that uses this name.

14. Are there a maximum number of possible semaphores ?

Yes.

15. List two functions used by a semaphore.

semget, semop.

16. List two functions used in share memory.

shmat, shmid.

17. What's a message queue ?

A message queue is a message that transit between client/server.

18. List a simple example for shared memory implementation.

Control the number of users that may run a program, enabling only a maximum number.

19. Would be possible to write a personal C structure in the shared memory ?

Yes.

20. List five "Inter-process Communications technique".

21. Are these techniques available only under Linux, or on any UNIX flavor ?

On any UNIX are available these techniques.

22. Is necessary to add some particular library to compile "Inter-process Communications technique" files ?. If so, what library in what case.

No.

23. What is the sense of use "lock()".

To avoid or control access to files.

24. List an example of using "lock".

The RCS.

25. What is a RPC ?

RPC stand for Remote Procedure Calls.

26. List two RPC procedures.

doors and Sun RPC

27. What is CORBA ?

CORBA is an innovative approach to integrate networks in an object oriented form using OMG tecnhiques.

28. What is the role of CORBA programming ?

Introduce an object programming mode to integrate networks and to IPC.

29. What are the standard books for "Network Programming" ?

UNIX Network Programming by Richard Stevens.

30. Where are defined these techniques or network protocols ?

In RFC, Request for Comments documents.

Chapter 10

1. What means FORTRAN ?

FORTRAN stan FORmula TRANslation.

2. What is FORTRAN ?

FORTRAN is a general purpose programming language, mainly intended for mathematical computations in e.g. engineering.

3. What is the name of GNU Fortran compiler ?

g77

4. What is the normal FORTRAN extension on UNIX system ?

Generally is used "f" (one letter as C). However, the compiler does not play attention to extensions.

5. What means "WRITE (*,*)" ?

Read for any unit in any format.

6. Are present in FORTRAN labels for instructions, like in old BASIC ?

Yes.

7. Would be available a GOTO instruction in FORTRAN ?

Yes.

8. What means "5" in the FORTRAN instruction "READ (5,10) N"

"5" stand for the the unit number where the program will get the data. Originally, in old IBM systems, the "5" is the standard reader of cards, while "6" is the standard printer.

9. Would be possible to mix C++ and Fortran libraries ?

Of course.

10. List a reason because FORTRAN continues to be used today.

Basically the major scientific and engineer software was written in FORTRAN. The fact, that a C or C++ compiler will be up to 30 faster, is really
not important, to get a fast result. If the organization must re-write the FORTRAN programs in C, this will takes years, so just a little more slow, but great results ... all the time.

At the same time these old programs may be linked to C/C++ modern routines to graphical output or similar, and in this mode re-use the old source
without programs.
 

Chapter 11

1. Who's the Python inventor?

Guido van Rossum

2. What is Python ?

Python is an innovative scripting and powerfull programming language capable to generate output and results in any format.

3. What are the two most important python releases ? What is the latest ?

Python 1.5 and Python 2.2

4. Is possible to write shell script programs in Python ?

yes.

5. What is a ".py" file ? A ".pyc" and a ".pyo" file ?

A .py is a python source file. ".pyc" is a byte compiled version while ".pyo" is a compiled version.

6. Are an equivalent to C++ classes supported in Python ?

Yes, python support classes.

7. Would be possible to make arithmetic with complex numbers in python ?

Yes, including sqrt of complex numbers.

8. Would be possible to generate HTML files using Python ?

Yes. Better is a third module is included.

9. Would python supports "external packages" written by third parts ?

Yes.

10. Would be possible to write graphical applications using Qt libraries with Python ?

Yes.

11. List three components for the Python Library.

cmath, os and sys.

12. Setup a python list.

a = ['spam', 'eggs', 100, 1234]

13. Setup a python dictionary.

 tel = {'jack': 4098, 'sape': 4139}

14. How we can found the right mode to use the square root, in Python  ?

We can check the Library reference, or simply knows that "cmath" module is necessary. How to use is another fact, however easy.

15. Is possible to play music with python ?

Yes.

16. What are the modules that python load by default ?

[root@ftosx1 examples]# python
Python 1.5.2 (#1, Jul  5 2001, 03:02:19)  [GCC 2.96 20000731 (Red Hat Linux 7.1 2 on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> dir()
['__builtins__', '__doc__', '__name__']
>>>
 

17. What is Tkinter ?

Tkinter is a python module to generate Tcl/Tk code.

18. What is ZOPE ?

ZOPE is a Python module to generate and control websites.

19. What is the latest ZOPE release ?

2.X

20. Why we get errors in the following source ?
     [root@ftosx1 examples]# python
       Python 1.5.2 (#1, Jul  5 2001, 03:02:19)  [GCC 2.96 20000731 (Red Hat Linux 7.1 2 on linux-i386
       Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
       >>> import cmath
       >>> a=1+1j
       >>> b=sqrt(a)
       Traceback (innermost last):
         File "<stdin>", line 1, in ?
       NameError: sqrt
       >>>

The correct to implement "sqrt" is the following:

[root@ftosx1 examples]# python
Python 1.5.2 (#1, Jul  5 2001, 03:02:19)  [GCC 2.96 20000731 (Red Hat Linux 7.1 2 on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import cmath
>>> a=1+1j
>>> b=cmath.sqrt(a)
>>> b.real
1.09868411347
>>> b.imag
0.455089860562
>>>
[root@ftosx1 examples]#
 

Chapter 12

1. What means RPM ?

RPM stand for RedHat Package Manager.

2. What are the directories connected with RPM ?

/usr/src/ftosx/SRPMS/
                    /RPMS/i386
                               /noarch
                               /i686
                               /i586
                               /athlon
                               /i486
                     /SPECS/
                     /BUILD
                     /SOURCES

3. Are involved some PGP key in RPM package ?

Yes.

4. If there are a Security why, if Linux is for free ?

It is necessary to know the original place for RPM package.

5. If so, how we can get this PGP key ?

Following the normal producedure. See Chapter W20

6. What rpm command list all installed packages ?

rpm -qa

7. How we can know is a RPM package is installed or not ?

rpm -qi packagename

8. Where will be installed the source and the compiled ... to create the RPM package ?

In /usr/src/ftosx/BUILD

9.How we can know what is the RPM package which includes a determinated Linux file ?

rpm -qf `which filename`

10. What is the program to remove all the installed RPM Packages?

rpm -e --allmatches Mesa

11. Is possible to generate packages from different groups starting from a single spec file.

Of course, is the normal situation.

12. What is the command to list the files included in a rpm file?

rpm -ql packname

13. What is the command to remove a package from the system without to respect dependencies ?

rpm -e --nodeps packname

14. Is possible to list the files inside a package before to install it? If possible, What is the command ?

Yes. Simply run the command:     rpm2cpio jdk-1.3.1_01.i386.rpm | cpio -t

15. Suppose that you rebuild a package using the same software but change the Group. Would the groups will be changed if you run the "rpm -U" command?

No.

16. Suppose that you build an important packages like glibc. After the build you remove the glibc ... and now ls, make does not work? What rpm command you need to run to install your new glib?

rpm works without problems and is possible to install the glib in the normal mode running: "rpm -i"

17. The program rpm depends on some file or lib included on glibc ?

No.

18. What is lilo-doc-21.7-10.i386 of lilo-21.7-10.i386.rpm ?

The documentation entry.

19. Suppose that your system includes the package: libogg-devel-1.0rc1-2. Running the command "rpm -e --nodeps --allmatches libogg", will the libogg-devel-1.0rc1-2 removed?

No.

20. What is the command to print a  formatted output of the installed RPM packages?

rpm -q --queryformat '%{NAME}\n'

21. What is the command to install a Linux distribution ?

rpm -i --justdb --nodeps --noorder --ignorearch --noscripts --notriggers --ignoresize --force *{%{_arch},noarch}.rpm"

22. Is possible to install two different packages at the same time?

Of course, simple run: rpm -i filename1.rpm filename2.rpm

23. The last version rpm-4.03 continues to support the Berkeley DB1?

No. Only DB1.

24. What is a SPEC file ?

A SPEC file is a RPM file equivalent to a batch that compile and create the packages.

25. What fix a SPEC file, a set of binary packages or set of source packages or both ?

Both. A Spec file create the binaries and re-create the source package.

26. Can the "vim" 6.X help to complete

Yes, because recognize the SPEC entries.

27. Is included some "Changelog" inside SPEC files ?

Yes, generally is at the end of the SPEC file where programmers or maintainers add its comments.

28. Suppose we want to count the number of packages inside a SPEC file. What is the SPEC entry to check for ?

Easy.

fgrep %package XFree86.spec | wc -l

29. What means Requires in the SPEC file. The files necessary to build or to install ?

To install.

30. What is the SPEC entry to create a package dependence ?

Requires

31. What command can generate the following output :

       Name        : maximum-rpm                  Relocations: (not relocateable)
       Version     : 1.0                               Vendor: Red Hat, Inc.
       Release     : 0.20010723                    Build Date: Mon 23 Jul 2001 10:08:56 AM EDT
       Install date: Wed 15 Aug 2001 09:09:34 AM EDT      Build Host: george.devel.redhat.com
       Group       : Documentation                 Source RPM: maximum-rpm-1.0-0.20010723.src.rpm
       Size        : 2127779                          License: OPL
       Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
       Summary     : The "Maximum RPM" book
       Description :
       "Maximum RPM" is a book about the RPM Package Manager or, as it is known
       to its friends, RPM.

       The book is divided into two major sections. The first section is for
       anyone who needs to use RPM on his/her system. The second section covers
       all there is to know about build packages using RPM.
       Name        : maximum-rpm                  Relocations: (not relocateable)
       Version     : 1.0                               Vendor: Red Hat, Inc.
       Release     : 0.20010806                    Build Date: Mon 06 Aug 2001 06:50:04 PM EDT
       Install date: Fri 17 Aug 2001 09:40:59 AM EDT      Build Host: george.devel.redhat.com
       Group       : Documentation                 Source RPM: maximum-rpm-1.0-0.20010806.src.rpm
       Size        : 2127779                          License: OPL
       Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
       Summary     : The "Maximum RPM" book
       Description :
       "Maximum RPM" is a book about the RPM Package Manager or, as it is known
       to its friends, RPM.

       The book is divided into two major sections. The first section is for
       anyone who needs to use RPM on his/her system. The second section covers
       all there is to know about build packages using RPM.

The command is: rpm -qi maximum-rpm