Linux Administration Howto
Linux Administration
Linux Administration

par Jean-Christophe


go straight : Compil an application Desktop    gcc / glibc kernel   mount (& Burning)   |   Traduire 7 page



Building Files From Source

RPMs are an easy way to install, query and uninstall programs in Linux. But, given that they're tougher for the author to create than a .tar.gz file, you won't always find the file you'd like to install in the .rpm format. Given that, it's useful to have some background on building and installing files from the source code.
You'll remember from an earlier issue of Penguin Shell that .tar files are really just a collection of files all stuck together. That's why it's commonly called a tarball. .tar.gz files are a cleaned up and lightly compressed version of .tar files. In the form we're discussing today, these files contain all the source code you'll need compile and install a program on your Linux system.

It's useful to choose or create a directory on your system to store all the source files you may download. On my system, this directory is the /usr/local/src directory. It's easy to remember and recognize as a directory that contains all the source I compile. So, first download the file to your /home/$USER directory, then do the following:

[tony@server tony]# su
Password: [your root password]
[root@server tony]# cd /usr/local/src
[root@server /usr/local/src]# tar zxvf /home/tony/downloaded_file.tar.gz
What you've done here is pretty simple. You logged in as the root user, changed directories to the /usr/local/src directory, and untarred/unzipped the downloaded_file.tar.gz file into the current directory. If things have happened as they should, you'll have seen files scrolling by as they were untarred. That's a function of the -v option to the tar command - "do this in a verbose fashion."

Now, you'll need to change to the directory you just created, looking for a configuration file:

[root@server /usr/local/src]# cd downloaded_file
[root@server /usr/local/src/downloaded_file]# ls
The ls command instructs the system to display a listing of all the files in the current directory in short format - that is, without file type, permissions, file size, etc. Most programs now include a configure file that checks you system environment for sanity prior to installing the program and creates the make file. This file should be executed first:
You can watch as various environment checks scroll past on the screen. In the end, a make file will be created. This is really just a shell script that instructs the compiler in your system on how to compile the program. Once you're returned to the shell prompt (without error messages, of course), execute the make file as follows:
Again, you'll see your system in action, calling various functions of the compiler (usually gcc) to "build" the source into an executable program. At the end of this process, you'll be returned to a shell script and should:
The make_install script places the proper executable files in the path, allowing you to execute the program from the command line simply by typing keying in the name, without including the full path.

Though the "configure, make, make_install" routine is by far the most common, there are some variances. Additionally, make can be used in conjunction with options to customize your install. The make man page outlines these options and provides a thorough view of make.
Between rpms and .tar.gz files, you're now completely armed to install most programs on your Linux system.


KDE Desktop Links

source: lockergnome Penguin

KDE utilizes a pretty simple scheme for adding shortcuts to the desktop. Consistent with the hypertext model, these shortcuts are more properly called links in KDE. In any event, it's nearly a trivial task to add them to your customized KDE desktop.

Right click on the desktop background.
Select the "New" submenu from the pop-up.
Select the type of link you'd like to create; Folder, File System Device, FTP URL, Mime Type, Application, Internet Address, or WWW URL.
Specify a name for the link in the General tab of the Properties window. The convention for this name is [application name].kdelnk.
Enter the executable command or file location in the Execute tab of the Properties window. You can either enter this command or file location by hand, or Browse to the location.
Select an appropriate icon for the link by clicking on the icon button and selecting from the choices in the resulting window.
As necessary, set the permissions for the link file. As you've created the link for the file, you own it and will be able to utilize it. You can grant others permission, as well from the Permissions tab.
Click the OK button, and you're set.

Now that you know how to create these links, you have to promise me that you'll be frugal in their use. I'd hate to contribute to "desktop littering."


gcc / glibc

gcc 3.04 built fine on mandrake 8.2 beta 2 (even for a one-week n00bie like me :>). i just put in all the default command-lines from the installation instructions, using a separate build dir as recommended.

Mandrake's default version of gcc (2.9.6) isn't installed in the same place gcc 3.0.4 installs itself, so even though 3.0.4 builds and installs fine, unless you force 3.0.4 to run with the -V parameter, 2.9.6 will run when you use 'gcc'.
to fix this I went to /usr/bin and changed the symlink named 'gcc' there to point to the newly installed gcc 3.0.4 (in /usr/local/bin) instead of the old one (which is in /usr/bin, called gcc-2.96). you could presumably alternatively tell configure to install gcc in /usr/lib instead of /usr/local/lib, too. hmm, i feel all l33t now. :).

More feedbacks @ Build status for GCC 3.0, a list that summarizes build reports for GCC 3.0.x 'page


install & compilation

[ version v. française ]

  • If you install the full sources,
  • do a
    cd /usr/src
    gzip -cd linux-2.0.XX.tar.gz | tar xfv -
    to get it all put in place. Replace "XX" with the version number of the latest kernel.

  • You can also upgrade between 2.0.xx releases by patching
  • Each patch that is released for 2.0.xx contains only bugfixes. No new features will be added to the Linux kernel until the 2.1.xx development effort begins. To install by patching, get all the newer patch files and do:
    cd /usr/src
    gzip -cd patchXX.gz | patch -p0
    (repeat xx for all versions bigger than the version of your current source tree, _in_order_) and you should be ok.
    You may want to remove the backup files (xxx~ or xxx.orig), and make sure that there are no failed patches (xxx# or xxx.rej). If there are, either you or me has made a mistake.

    Alternatively, the script patch-kernel can be used to automate this process. It determines the current kernel version and applies any patches found.

    cd /usr/src

    The default directory for the kernel source is /usr/src/linux, but can be specified as the first argument. Patches are applied from the current directory, but an alternative directory can be specified as the second argument.

    - make sure your /usr/include/asm, /usr/include/linux, and /usr/include/scsi directories are just symlinks to the kernel sources:
    cd /usr/include

    rm -rf asm linux scsi
    ln -s /usr/src/linux/include/asm-i386 asm
    ln -s /usr/src/linux/include/linux linux
    ln -s /usr/src/linux/include/scsi scsi

    - make sure you have no stale .o files and dependencies lying around: cd /usr/src/linux

    make mrproper
    You should now have the sources correctly installed.

    CONFIGURING the kernel:

    - do a "make config" to configure the basic kernel. "make config" needs bash to work: it will search for bash in $BASH, /bin/bash and /bin/sh (in that order), so hopefully one of those is correct.

    - Alternate configuration commands are:
    "make menuconfig" Text based color menus, radiolists & dialogs.
    "make xconfig" X windows based configuration tool.

    NOTES on "make config":
    - having unnecessary drivers will make the kernel bigger, and can under some circumstances lead to problems: probing for a nonexistent controller card may confuse your other controllers
    - compiling the kernel with "Processor type" set higher than 386 will result in a kernel that does NOT work on a 386. The kernel will detect this on bootup, and give up.
    - A kernel with math-emulation compiled in will still use the coprocessor if one is present: the math emulation will just never get used in that case. The kernel will be slightly larger, but will work on different machines regardless of whether they have a math coprocessor or not.
    - the "kernel hacking" configuration details usually result in a bigger or slower kernel (or both), and can even make the kernel less stable by configuring some routines to actively try to break bad code to find kernel problems (kmalloc). Thus you should probably answer 'n' to the questions for a "production" kernel.

    - Check the top Makefile for further site-dependent configuration (default SVGA mode etc).

    - Finally, do a "make dep" to set up all the dependencies correctly.

    COMPILING the kernel:

    - make sure you have gcc-2.6.3 or newer available. It seems older gcc versions can have problems compiling newer versions of linux. If you upgrade your compiler, remember to get the new binutils package too (for as/ld/nm and company).

    - do a "make zImage" to create a compressed kernel image. If you want to make a bootdisk (without root filesystem or lilo), insert a floppy in your A: drive, and do a "make zdisk". It is also possible to do "make zlilo" if you have lilo installed to suit the kernel makefiles, but you may want to check your particular lilo setup first.

    - if your kernel is too large for "make zImage", use "make bzImage" instead.

    - if you configured any of the parts of the kernel as `modules', you will have to do "make modules" followed by "make modules_install".
    Read Documentation/modules.txt for more information. For example, an explanation of how to use the modules is included there.

    - keep a backup kernel handy in case something goes wrong. This is especially true for the development releases, since each new release contains new code which has not been debugged.

    - In order to boot your new kernel, you'll need to copy the kernel image (found in
    /usr/src/linux/arch/i386/boot/zImage after compilation) to the place where your regular bootable kernel is found.

    For some, this is on a floppy disk, in which case you can type
    cp /usr/src/linux/arch/i386/boot/zImage /dev/fd0 to make a bootable floppy. Note that as of Linux 2.0.0, a kernel copied to a 720k double-density 3.5" floppy disk no longer boots. In this case, it is highly recommended that you install LILO on your double-density bootfloppy or switch to high-density floppies.

    If you boot Linux from the hard drive, chances are you use LILO which uses the kernel image as specified in the file /etc/lilo.conf. The kernel image file is usually /vmlinuz, or /zImage, or /etc/zImage. To use the new kernel, copy the new image over the old one (save a backup of the original!). attention.GIF - 1kb Then, you MUST RERUN LILO to update the loading map!! If you don't, you won't be able to boot the new kernel image.

    Reinstalling LILO is usually a matter of running /sbin/lilo.
    You may wish to edit /etc/lilo.conf to specify an entry for your old kernel image (say, /vmlinux.old) in case the new one does not work. See the LILO docs for more information.

    After reinstalling LILO, you should be all set. Shutdown the system, reboot, and enjoy!

    If you ever need to change the default root device, video mode, ramdisk size, etc. in the kernel image, use the 'rdev' program (or alternatively the LILO boot options when appropriate). No need to recompile the kernel to change these parameters.

    - reboot with the new kernel and enjoy.


    - if you have problems that seem to be due to kernel bugs, please check the file MAINTAINERS to see if there is a particular person associated with the part of the kernel that you are having trouble with. If there isn't anyone listed there, then the second best thing is to mail them to me (Linus.Torvalds@Helsinki.FI), and possibly to any other relevant mailing-list or to the newsgroup. The mailing-lists are useful especially for SCSI and NETworking problems, as I can't test either of those personally anyway.

    - In all bug-reports, *please* tell what kernel you are talking about, how to duplicate the problem, and what your setup is (use your common sense). If the problem is new, tell me so, and if the problem is old, please try to tell me when you first noticed it.

    - if the bug results in a message like
    unable to handle kernel paging request at address C0000010
    Oops: 0002
    EIP:   0010:XXXXXXXX
    eax: xxxxxxxx   ebx: xxxxxxxx   ecx: xxxxxxxx   edx: xxxxxxxx
    esi: xxxxxxxx   edi: xxxxxxxx   ebp: xxxxxxxx
    ds: xxxx  es: xxxx  fs: xxxx  gs: xxxx
    Pid: xx, process nr: xx
    xx xx xx xx xx xx xx xx xx xx
    or similar kernel debugging information on your screen or in your system log, please duplicate it *exactly*. The dump may look incomprehensible to you, but it does contain information that may help debugging the problem. The text above the dump is also important: it tells something about why the kernel dumped code (in the above example it's due to a bad kernel pointer). More information on making sense of the dump is in Documentation/oops-tracing.txt

    - You can use the "ksymoops" program to make sense of the dump. Find the Crel="external" sources under the scripts/directory to avoid having to do the dump lookup by hand:

    - in debugging dumps like the above, it helps enormously if you can look up what the EIP value means. The hex value as such doesn't help me or anybody else very much: it will depend on your particular kernel setup. What you should do is take the hex value from the EIP line (ignore the "0010:"), and look it up in the kernel namelist to see which kernel function contains the offending address.

    To find out the kernel function name, you'll need to find the system binary associated with the kernel that exhibited the symptom. This is the file 'linux/vmlinux'. To extract the namelist and match it against the EIP from the kernel crash, do:

    nm vmlinux | sort | less

    This will give you a list of kernel addresses sorted in ascending order, from which it is simple to find the function that contains the offending address.
    Note that the address given by the kernel debugging messages will not necessarily match exactly with the function addresses (in fact, that is very unlikely), so you can't just 'grep' the list: the list will, however, give you the starting point of each kernel function, so by looking for the function that has a starting address lower than the one you are searching for but is followed by a function with a higher address you will find the one you want. In fact, it may be a good idea to include a bit of "context" in your problem report, giving a few lines around the interesting one.

    If you for some reason cannot do the above (you have a pre-compiled kernel image or similar), telling me as much about your setup as possible will help.

    - alternately, you can use gdb on a running kernel. (read-only; i.e. you cannot change values or set break points.) To do this, first compile the kernel with -g; edit arch/i386/Makefile appropriately, then do a "make clean". You'll also need to enable CONFIG_PROC_FS (via "make config").

    After you've rebooted with the new kernel, do "gdb vmlinux /proc/kcore". You can now use all the usual gdb commands. The command to look up the point where your system crashed is "l *0xXXXXXXXX". (Replace the XXXes with the EIP value.)

    gdb'ing a non-running kernel currently fails because gdb (wrongly) disregards the starting offset for which the kernel is compiled.

    VO article here

    Linux Device List

    the official registry of allocated device numbers and /dev directory nodes for the Linux operating system (Extrait).

    block First MFM, RLL and IDE hard disk/CD-ROM interface

    0 = /dev/hdaMaster: whole disk (or CD-ROM)
    64 = /dev/hdbSlave: whole disk (or CD-ROM)

    For partitions, add to the whole disk device number:

    0. /dev/hd? : Whole disk
    1. /dev/hd?1First partition
    2. /dev/hd?2Second partition
    63. /dev/hd?6363rd partition

    For Linux/i386, partitions 1-4 are the primary partitions, and 5 and above are logical partitions.
    Other versions of Linux use partitioning schemes appropriate to their respective architectures.

    Securing Linux - Part 1

    Contrary to some popularly-held beliefs, there is no such thing as an impenetrable computer system. Given enough time, skill and persistence, a cracker can break any system, be it a Windows box or a Linux machine. At some level, good system security means eliminating or reducing one of these "targets of opportunity."
    If you can make the task of cracking your system too time consuming or difficult overall, you've done a good job of preventing the majority of security risks.

    This tutorial on securing a Linux system takes a micro-level view, intended to slow a cracker to a crawl, eliminating the opportunity of unlimited time.

    It looks to each vulnerable element of your system; file serving, email, web services, ftp, etc., with practical solutions for tightening the bolts that keep your system closed.
    Part 1 serves as a strong introduction into these areas and will introduce new Linux users to some crucial Linux security concepts.

    [Powered by Google]   Translate this page to :       


    Best Viewed With Any Browser Conception & presentation : kozaki