Copyright (c) 2003 LinuxIT.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with the Invariant Sections being History, Acknowledgements, with the
Front-Cover Texts being “released under the GFDL by LinuxIT”.
Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
0. PREAMBLEThe purpose of this License is to make a manual, textbook, or other functional and useful document "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.
This License is a kind of "copyleft", which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.
1. APPLICABILITY AND DEFINITIONSThis License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The "Document", below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you". You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.
A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.
The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.
The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.
A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not "Transparent" is called "Opaque".
Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.
The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text.
A section "Entitled XYZ" means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as "Acknowledgements", "Dedications", "Endorsements", or "History".) To "Preserve the Title" of such a section when you modify the Document means that it remains a section "Entitled XYZ" according to this definition.
The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.
2. VERBATIM COPYINGYou may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and you may publicly display copies. 3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computernetwork location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.
It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document. 4. MODIFICATIONSYou may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:
•
A. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of
previous versions (which should, if there were any, be listed in the History section of the Document). You may
use the same title as a previous version if the original publisher of that version gives permission.
• B. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the
modifications in the Modified Version, together with at least five of the principal authors of the Document (all
of its principal authors, if it has fewer than five), unless they release you from this requirement.
• C. State on the Title page the name of the publisher of the Modified Version, as the publisher.
• D. Preserve all the copyright notices of the Document.
• E. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.
• F. Include, immediately after the copyright notices, a license notice giving the public permission to use the
Modified Version under the terms of this License, in the form shown in the Addendum below.
• G. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the
Document's license notice.
• H. Include an unaltered copy of this License.
• I. Preserve the section Entitled "History", Preserve its Title, and add to it an item stating at least the title, year,
new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled
"History" in the Document, create one stating the title, year, authors, and publisher of the Document as given
on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.
• J. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the
Document, and likewise the network locations given in the Document for previous versions it was based on.
These may be placed in the "History" section. You may omit a network location for a work that was published
at least four years before the Document itself, or if the original publisher of the version it refers to gives
permission.
• K. For any section Entitled "Acknowledgements" or "Dedications", Preserve the Title of the section, and
preserve in the section all the substance and tone of each of the contributor acknowledgements and/or
dedications given therein.
• L. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section
numbers or the equivalent are not considered part of the section titles.
• M. Delete any section Entitled "Endorsements". Such a section may not be included in the Modified Version.
• N. Do not retitle any existing section to be Entitled "Endorsements" or to conflict in title with any Invariant
Section.
• O. Preserve any Warranty Disclaimers.
If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles.
You may add a section Entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties--for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.
You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.You may combine the Document with other documents released under this License, under the terms defined in section 4
above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the
original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and
that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be
replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the
title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of
that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant
Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled "History" in the various original documents, forming one section Entitled "History"; likewise combine any sections Entitled "Acknowledgements", and any sections Entitled "Dedications". You must delete all sections Entitled "Endorsements."
6. COLLECTIONS OF DOCUMENTSYou may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.
7. AGGREGATION WITH INDEPENDENT WORKSA compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an "aggregate" if the copyright resulting from the compilation is not used to limit the legal rights of the compilation's users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document's Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.
8. TRANSLATIONTranslation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.
If a section in the Document is Entitled "Acknowledgements", "Dedications", or "History", the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
10. FUTURE REVISIONS OF THIS LICENSEThe Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation.

1. The Installation CD ..............................................................................................................................10
2. Local Installations.................................................................................................................................11
3. Network Installation..............................................................................................................................11
4. Rescue disk..........................................................................................................................................11
5. Partitioning Schemes............................................................................................................................13
6. Easy Dual Booting ...............................................................................................................................13
8. Exercises..............................................................................................................................................15
1. Memory Support...................................................................................................................................16
2. Resource Allocation..............................................................................................................................16
3. USB Support.........................................................................................................................................17
4. SCSI Devices........................................................................................................................................18
5. Network cards.......................................................................................................................................18
6. Setting up modems...............................................................................................................................19
7. Printer Configuration.............................................................................................................................20
8. Exercises..............................................................................................................................................22
1. Disks and Partitions..............................................................................................................................23
2. Partitioning Tools:.................................................................................................................................25
3. Bootloaders...........................................................................................................................................27
4. Managed devices..................................................................................................................................28
5. Quotas..................................................................................................................................................29
6. Exercises..............................................................................................................................................31
1. The Filesystem Structure......................................................................................................................32
2. Formatting and File System Consistency.............................................................................................33
3. Monitoring Disk Usage..........................................................................................................................35
4. File Permissions...................................................................................................................................36
5. Exercises..............................................................................................................................................39
1. The interactive shell..............................................................................................................................41
2. Variables...............................................................................................................................................42
3. Input, Output, Redirection.....................................................................................................................43
4. Metacharacters and Quotes................................................................................................................45
5. The Command History..........................................................................................................................47
6. Other Commands.................................................................................................................................47
7. Exercise................................................................................................................................................49
1. Moving around the filesystem...............................................................................................................52
2. Finding Files and Directories................................................................................................................52
3. Handling directories..............................................................................................................................54
4. Using cp and mv...................................................................................................................................54
5. Hard Links and Symbolic Links............................................................................................................55
7. Touching and dd-ing............................................................................................................................56
8. Exercises.............................................................................................................................................58
1. Viewing running processes...................................................................................................................60
2. Modifying Processes.............................................................................................................................61
3. Processes and the shell........................................................................................................................63
4. Exercises..............................................................................................................................................65
1. cat the Swiss Army Knife......................................................................................................................66
2. Simple tools..........................................................................................................................................67
3. Manipulating text...................................................................................................................................68
4. Exercises..............................................................................................................................................70
1. Introduction...........................................................................................................................................71
2. Static and Shared Libraries ................................................................................................................72
3. Source Distribution Installation.............................................................................................................74
4. The RedHat Package Manager RPM ..................................................................................................75
5. The Alien Tool.......................................................................................................................................78
6. Exercises..............................................................................................................................................79
1. Regular Expressions.............................................................................................................................80
2. The grep family.....................................................................................................................................80
3. Working with grep.................................................................................................................................81
4. egrep and fgrep....................................................................................................................................81
5. The Stream Editor - sed.......................................................................................................................81
6. Exercises..............................................................................................................................................84
1. vi Modes................................................................................................................................................85
2. Text Items.............................................................................................................................................85
3. Inserting Text........................................................................................................................................86
4. Deleting Text.........................................................................................................................................86
5. Copy Pasting.........................................................................................................................................86
6. Searching .............................................................................................................................................87
7. Undoing.................................................................................................................................................87
8. Saving...................................................................................................................................................87
9. Exercises..............................................................................................................................................88
1. Introduction...........................................................................................................................................89
3. Configuring X11R6...............................................................................................................................90
4. Controlling X clients..............................................................................................................................92
5. Starting X..............................................................................................................................................92
6. The Display Manager............................................................................................................................93
7. Troubleshooting X Clients.....................................................................................................................96
8. Choosing a Window Manager..............................................................................................................96
9. Exercises..............................................................................................................................................97
packages
: This directory contains the pre-compiled packages. Here are the associated names for the main
distrubutions:
debian: dist
mandrake: Mandrake
redhat: RedHat
suse: suse
images: This directory contains various “images”. These are special flat files often containing directory structures. An initial ramdisk (initrd) is an example of an image file. There are different types of images necessary to:
- boot the installation process
- provide additional kernel modules
- rescue the system
Some of these files can be copied to a floppy disk when the installation is started using floppies rather than the CDROM. The Linux tool used to do this is dd. There is a tool called rawrite which does the same under DOS.
The image is a special file which may contain subdirectories (much like an archive file). Image file structureThe easiest and most common type of installation is a local installation. Most distributions are a CD iso image with an automatic installation script. On machines with no CD-ROM hardware it is still possible to start an installation from a floppy.
CD-ROM installationMaking a bootable installation disk
dd if=/path/to/<image_name> of=/dev/fd0 on a linux box
rawrite.exe
under Windows (not NT)
For RedHat distributions the installation images are in the
images directory. The basic image is boot.img.
Other images are more specialised like bootnet.img or pcmcia.img.
In a Suse distribution the floppy image is in the disks directory and the image is called bootdisk.
dd /mnt/cdrom/images/bootnet.img of=/dev/fdo
The first part of the installation is text based and will allow you to setup the network parameters needed. The rest of the installation can be done via FTP, NFS or HTTP. Protocols that allow a full mount (NFS) allow the install to be done in graphical mode, while file retrieval protocols (FTP HTTP) allow only text mode.
The Linux operating system runs entirely in RAM. The aim is to access the root filesystem on the PC hard
drive
1. Insert the Linux installation disk (Suse, RedHat, Mandrake ...)
2. At the prompt type “linux rescue”
3. Follow the instructions.
chroot /mnt/sysimage
The figure below shows a possible partitioning scheme. The File System layout is a tree of directories and subdirectories. The physical resources with the data are mounted at specific locations on the file system called mount points.
The root of the tree structure is called root and is represented by a forward slash “/”. At boot time, the boot loader is told which device to mount at root. The leaves in this tree structure are subdirectories.
For non-NT systems restart your computer in DOS command mode. If you are installing RedHat then you can run E:\DOSUTILS\AUTOBOOT.BAT. This will start the installation program. Similarly if you are installing Suse you can run E:\setup.exe under DOS.
The hard drive from a Windows' perspective:When running Linux the Windows partition should be called /dev/hda1 (since it's the first partition on the first physical disk). By default this partition is not mounted. You can make a directory /dos or /mnt/dos and mount this partition. The disk partition corresponding to C:\ is then accessible.
This is a suggestion for a partitioning scheme using about 3GB of hard disk space. If you have more space available then make /usr larger and consider installing more packages than those suggested in step (iv)
IMPORTANT: Leave a free partition of at least 100MB. We will need this later!!/boot 20M
/ 250M
/usr 2300M
/home 50M
/tmp 100M
/var
150M
SWAP 128M (Notice that SWAP is a filesystem type and that no mount point is defined)
MBR.
We deliberately don't want the installation to boot properly. The bootloader will be fixed in step 2(i)
in rescue mode.
“Network Support”
“Classic X Window System”
“X Window System”
“Software Development” [This is important, we will need this to compile packages later]
(i)
Reboot with the bootnet.img floppy disk (or the installation CDROM of you have it). This time type
linux rescue
at the prompt.
(iii)
Edit /etc/lilo.conf (use vi). You should have
boot=/dev/fd0
prompt
linear
timeout=50
image=/boot/vmlinuz-<kernel-version>
label=linux
read-only
root=/dev/<root-partition>
The system’s RAM is first detected by the BIOS. All types of RAM (EDO, DRAM and SDRAM) are recognised by the Linux kernel. There can be problems with old hardware when the BIOS cannot detect 64MB of RAM or more. In this case one needs to passe parameters to the kernel at boot time.
When using LILO insert the following into /etc/lilo.conf:To allow peripherals and devices on the PC to communicate directly with system resources, in particular the CPU, the system allocates resources such as lines and channels for each device. These resources are Interrupt Request Lines (IRQ), Input/Output addresses and Direct Memory Access channels (DMA).
IRQs: The Interrupt Request Lines allow devices to request CPU time. The CPU will stop its current activity and process the instructions sent by the device. IRQs range from 0 to 15./proc/dma
/proc/interrupts
/proc/ioports
/proc/pci
lspci : lists chipset information of all attached PCI components. Lists I/O and IRQ settings with the -v flag . Also notice the -b (BUS centric) option which shows allocations assigned by the BIOS rather than the kernel.
dmesg . This displays the kernel messages logged at boot time. The kernel scans all the hardware on the system and can automatically allocate modules (drivers) for given chipsets. These messages are also available in /var/log/dmesg.
Device
I/O port
IRQ
/dev/ttyS0
0x03f8
4
/dev/ttyS1
0x02f8
3
/dev/lp0
0x378
7
/dev/lp1
0x278
5
soundcard
0x220
NOTICE:
This is a very common example, however since kernel modules are only discussed in LPI 102 some may
find it difficult. You may skip this example and go to § 3
1. For statically compiled modules, parameters can be passed to the kernel at boot time. A typical example is when two ethernet cards are present and only the first one is detected. The following line tells the kernel that:
- there is an ethernet card using IRQ 10 and I/O 0x3002. For dynamically compiled modules, IRQ and I/O address settings can be defined using / etc/modules.conf (or /etc/conf.modules). Assuming that in the above example both cards where using thee100.o kernel module, then /etc/modules.conf would contain the following:
alias eth0 e100 alias eth1 e100 options eth0 io=0x300 irq=10 options eth1 io=0x340 irq=9Display Devices
Communication Devices
Audio Devices
Mass Storage Devices
Human Interface Devices (HID)
Host Controler
OHCI (Compaq)
UHCI (Intel)
EHCI (USB v 2.0)
Kernel Module usb-ohci.o usb-uhci.o ehci-hdc.o
- an 8-bit interface with a bus that supports 8 devices, this includes the controller, so there is only space
for 7 block devices (tapes, disks, etc)
- a 16-bit interface (WIDE) with a bus that supports 16 devices including the controller, so there can only
be 15 block devices.
The Logical Unit Number (LUN) is used to differentiate between devices within a SCSI target number. This is used, for example, to indicate a particular partition within a disk drive or a particular tape drive within a multi-drive tape robot. It is not seen so often these days as host adapters are now less costly and can accommodate more targets per bus.
Booting SCSI disks
►
dmesg
Linux Tulip driver cersion 0.9.14 (February 20, 2001)
PCI: Enabled device 00:0f.0 (0004 ->0007)
PCI: Found IRQ 10 for device 00:0f.0
eth0: Lite-On 82cl68 PNIC rev 32 at 0xf800, 00:0A:CC:D3:6E:0F,
IRQ 10
eth0: MII transceiver #1 config 3000 status 7829 advertising
►
cat /proc/interrupts
0: 8729602 XT-PIC timer
1: 4 XT-PIC keyboard
2: 0 XT-PIC cascade
7: 0 XT-PIC parport0
8: 1 XT-PIC rtc
10: 622417 XT-PIC eth0
11: 0 XT-PIC usb-uhci
14: 143040 XT-PIC ide0
15: 180 XT-PIC ide1
►
/sbin/lsmod
Module Size Used by
tulip 37360 1 (autoclean)
From the examples above we see that the Ethernet card’s chipset is Tulip, the i/o address is 0xf800 and the IRQ is 10. This information can be used either if the wrong module is being used or if the resources (i/o or IRQ) are conflicting.
This information can either be used to insert a module with a different i/o address (using the modprobe or insmod utilities) or can be saved in /etc/modules.conf (this will save the settings for the next bootup).DOS
Linux
COM1
/dev/ttyS0
COM2
/dev/ttyS1
COM3
/dev/ttyS2
Most Linux distributions have hardware browser tools (GUIs) which can detect modems. But one can also use setserial to scan the serial devices. With the -g option this utility will tell you which serial devices are in use:
►
ln -s /dev/ttyS1 /dev/modemThe wvdial commandline tool has a setup script called wvdialconf which will scan the system for modems (all serial and USB ports are scanned). Once the script has run a skeleton configuration file is generated as below:
Sample /etc/wvdial.conf file:[Dialer Defaults]
Modem = /dev/ttyS1
Baud = 115200
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 S11=55 +FCLASS=0
; Phone = <Target Phone Number>
; Username = <Your Login Name>
; Password = <Your Password>
wvdial WorldISP
Using printtool
(not examined)If the
printtool fails to detect which parallel port corresponds to the printer device you can use the dmesg
utility to recall the kernel's initial parallel port scan.
Here is an example of a system with a local printer plugged into the first parallel port /dev/lp0
Parallel port scan at the end of dmesg
parport0: PC-style at 0x378 (0x778) [SPP,ECP,ECPEPP,ECPPS2]
parport0: detected irq 7; use procfs to enable interrupt-driven operation.
parport_probe: succeeded
parport0: Printer, HEWLETT-PACKARD DESKJET 610C
lp0: using parport0 (polling)
Sample /etc/printcap file
# This file can be edited with the printtool in the control-panel.
##PRINTTOOL3## LOCAL cdj550 300x300 a4 {} DeskJet550 3 {}
lp:\
:sd=/var/spool/lpd/lp:\
:mx#0:\
:sh:\
:lp=/dev/lp0:\
:if=/var/spool/lpd/lp/filter:
Cups is a newer administration and configuration tool for printers. It's main configuration files are stored in
/etc/cups. The printing process is the same except that cups uses its own filters situated in /
usr/lib/cups.
1.
Use the dmesg command to view the /var/log/dmesg file. Search for keywords such as USB, tty
or ETH0.
- What are the names of the USB controllers used?
- What are the IRQs for the first two serial ports?
2.
Investigate the contents of the following files:
/proc/ioports
/proc/interrupts
/proc/pci
/proc/dma
- Investigate the output of
lspci -v and scanpci –v. What type of ethernet card in
present?
- Verify that there are as many ‘bus ’ entries in /proc/pci. Does this file give as much
information as the commands above?
- Use
lsmod and lsusb to determine which type of host controller is used on your
system, UHCI, OHCI or EHCI (for USB v 2.0).
- Use usbmodules to list the kernel module which can handle the plugged in interface.
On a running Linux system, disks are represented by entries in the /dev directory. The kernel communicates with devices using a unique major/minor pair combination. All major numbers are listed in /proc/devices. For example the first IDE controller‘s major number is 3:
Block devices:
1 ramdisk
2 fd
3 ide0
Hard disk descriptors in /dev begin with hd (IDE) or sd (SCSI), a SCSI tape would be st, and so on. Since a system can have more than one block device, an additional letter is added to the descriptor to indicate which device is considered.
Table 1
Physical block devices
hda
Primary Master
hdb
Primary Slave
hdc
Secondary Master
hdd
Secondary Slave
sda
First SCSI disk
sdb
Second SCSI disk
NB Inserting a new SCSI hard drive with a target number between two existing drives will bump up the device letter of the higher numbered drive. This can cause chaos within a disk system.
Disk Partitions:Table 2
Partitions
hda1
First partition on first hard disk
hda2
Second partition on first hard disk
sdc3
Third partition on third SCSI disk
IDE type disks allow 4 primary partitions, one of which can be extended. The extended partition can further be divided into logical partitions. There can be a maximum of 64 partitions on an IDE disk and 16 on a SCSI disk.
Typical output of fdisk -l
Device Boot Start End Blocks Id System /dev/hda1 * 1 748 6297448+ b Win95 FAT32 /dev/hda2 785 788 32130 83 Linux /dev/hda3 789 2432 13205430 5 Extended /dev/hda5 789 1235 3590496 83 Linux /dev/hda6 1236 1618 3076416 83 Linux /dev/hda7 1619 1720 819283+ 83 Linux /dev/hda8 1721 1784 514048+ 83 Linux /dev/hda9 1785 1835 409626 83 Linux /dev/hda10 1836 1874 313236 83 Linux /dev/hda11 1875 1883 72261 82 Linux swap
On this system the main feature to notice is that there are 3 primary partitions. The third partition is extended (/dev/hda3) and holds 8 logical partitions. The primary partition /dev/hda3 is not used. In fact /dev/hda3 acts as a 'container' and a filesystem exists only on the enclosed logical partitions.
NOTICE
2. During installation: (not for exam purpose)One has the choice to associate a piece of hardware (or resource) to a directory. For example the root directory “/” which is more or less like the C:\ drive for DOS could correspond to the / dev/hda2 partition, and the subdirectory /boot could correspond to the partition /dev/hda3.
“/dev/hda3 is said to be mounted on /boot”. The directory on which a block device is mounted is then called a mount point.
fdisk /dev/hda
2) Type
m for help. Then create a new partition with n.
3) To write the changes to disk type w.
4) REBOOT.
The MBR occupies the first sector of the disk (512 bytes) and contains the partition tables together with a bootloader. At boot time the bootloader reads the partition tables looking for a partition marked “active” and loads the first sector of this partion.
LILO the Linux Bootloaderboot
*
install
prompt
default
timeout
image*
label*
root*
read-only*
append
linear/lba32 these options are mutually exclusive. Both ask LILO to read the disk
using
Linear Block Addressing.
linear is typically used for very large disks.
Lba32
is used to allow boot time access to data beyond the first 1024 cylinders.
where LILO should be installed (/dev/hda is the MBR)
which second stage to install (boot.b is the default)
give the user a chance to choose an OS to boot
name of the image that will be booted by default
used with prompt, causes LILO to pause (units are 1/10 of a sec)
path to the kernel to boot (one can use ‘other’ to chain load)
name of the image. This is the name a user can type at the boot prompt
the name of the disk device which contains the root filesystem /
mount the root filesystem read-only for fsck to work properly
give kernel parameters for modules that are statically compiled.
GRUB the Grand Unified Bootloadertitle
root
kernel
ro
root
name of the image
where the 2nd stage bootloader and kernel are e.g (hd0,0) is /dev/hda
path for the kernel starting from the previous root e.g /vmlinuz
read-only
the filesystem root
Example
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Linux (2.4.18-14)
root (hd0,0)
kernel /vmlinuz-2.4.18-14 ro root=/dev/hda5
initrd /initrd-2.4.18-14.img
LABEL=/
/
ext2 defaults
1 1
LABEL=/boot /boot ext2 defaults
1 2
LABEL=/home
/dev/fd0
LABEL=/usr
LABEL=/var
none
none
none
/dev/hdc9
/home ext3 defaults
1 2
/mnt/floppy auto noauto,owner
0 0
/usr
ext2 defaults
1 2
/var
ext3 defaults
1 2
/proc
proc defaults
0 0
/dev/shm
tmpfs defaults
0 0
/dev/pts
devpts gid=5,mode=620 0 0
swap,pri=-1 swap defaults
0 0
/dev/cdrom /mnt/cdrom iso9660 noauto,owner,kudzu,ro 0 0
mount /dev/cdrom
tune2fs -L /usr/local /dev/hdb12
Option summary for
mount:
rw,ro
read-write and read-only
users
the device can be read and unmounted by all users
user
the device can unmounted only by the user
owner
the device will change it's permission and belong to the user that mounted it
usrquota start user quotas on the device
grpquota start group quotas on the device
mount -o remount <device>
quotacheck -ca
edquota -u <user>
quotaon –aHINT: To create a new partition type
n. The partition type defaults to 83 (Linux)
To write the new partition table type w.
The partition table needs to be read: REBOOT the computer !
In extreme cases it may be easier to reboot and let the init scripts build the aquota.user (or aquota.group) file. If nothing is showing with the quotas, repquota, or quotastats tools make sure you have read-write access for everyone on /data [chmod a+rw /data ]
6.
(OPTIONAL) The instructor computer has a NFS share. Find out which directory is
shared and edit /etc/fstab to mount this share on /mnt/nfs. Use the noauto option fot
the
share not to mount at boot time.
a. Uninstall LILO from the MBR (or the floppy)
lilo –u
b. Modify the grub.conf sample on p. 28 to reflect your system
c. Install GRUB on the floppy with grub-install /dev/fd0
As mentioned earlier, once partitions have been created each partition must be given a mount point. This is typically done at installation time. To help us understand where things are kept, let us look at the Linux file system hierarchy.
The top of a Linux file system hierarchy starts at root (/). This is similar to C:\ under DOS except that C:\ is also the first device, whereas the root directory can be mounted anywhere.
The base directories are the first subdirectories under the root directory. These are installed by an rpm
package usually called filesystem.
rpm -ql filesystem
During the booting process the kernel first mounts the root (/) partition. In order to mount and check any further partitions and filesystems a certain number of programs such as fsck, insmod or mount must be available.
The directories /dev, /bin, /sbin, /etc and /lib must be subdirectories of root (/) and not mounted on separate partitions.• /var Variable data, such as spools and logs. Contains both shareable (eg. /var/spool/mail) and nonshareable (eg. /var/log/) subdirectories.
Many file system types are supported. The ext2 file system type is the default and is also known as “Linux Native”. In some more recent installers, ext3 is the default. This is really only an ext2 filesystem with a journal patched on top.
Contains pointers to data blocks. The first 12 blocks of data are directly accessed. If the data exceeds 12KB,
then indirect inodes act as relays.
Each inode is 256 bytes and contains the user, group, permissions and time stamp of the associated data.
mkfs –t jfs /dev/hda12
mke2fs /dev/hda11 [or mkfs –t ext2 /dev/hda11]
fsck –t reiserfs /dev/sdb10
fsck.reiserfs /dev/sdb10
➔Filesystem Size Used Avail Use% Mounted on /dev/hda9 289M 254M 20M 93% / /dev/hda2 23M 7.5M 14M 35% /boot none 62M 0 61M 0% /dev/shm /dev/hda5 1.4G 181M 1.1G 13% /share /dev/hda7 787M 79M 669M 11% /tmp /dev/hda3 4.3G 3.4G 813M 81% /usr /dev/hda6 787M 121M 627M 17% /var //192.168.123.2/share 12G 8.8G 3.7G 71% /mnt/smb
Changing permissions and ownersu
: a valid user with an entry in /etc/passwd
g: a valid group with an entry in /etc/group
o: other
chmod g=r,o-r libcgic.a
chmod g+w libcgic.a
chown root libcgic.a
chgrp apache libcgic.aSymolic
octal
read
4
write
2
execute
1
user group other rwx r_x r_x 4+2+1=7 4+1=5 4+1=5
The standard permissionEvery user has a defined umask that alters the standard permissions. The umask has an octal value and is subtracted(*) from the octal standard permissions to give the files permission (this permission doesn't have a name and could be called the file's effective permission).
(*) While subtraction works in most cases, it should be noted that technically the standard permissions and the umask are combined as follows:It is possible for root to give users permission to execute programs they would usually be unable to. This permission is the SUID permission with a symbolic value s or a numerical value 4000. For example root can write a C shell script that executes a program and set the SUID of the script with chmod 4777 script or chmod u+s script. (NB Bourne and Bash scripts do not honour SUID bits set on the script files.)
Examples:
chmod 4755 /bin/cat
chmod u+s /bin/grepSetting SGID on a directory changes the group ownership used for files subsequently created in that directory to the directories group ownership. No need to use newgrp to change the effective group of the process prior to file creation.
Examples:
chmod 2755 /home/data
chmod g+s /bin/wc-
Applied to a directory it prevents users from deleting files unless they are the owner (ideal for
directories shared by a group)
chmod 1666 /data/store.txt
chmod o+t /bin/bash
HINT: To create a new partition type
n. The partition type defaults to 83 (Linux)
To write the new partition table type w.
The partition table needs to be read: REBOOT the computer !
2. Format the first partition using the ext2 filesystem type and the second with reiserfs. HINT: The mkfs tool is a front for mkfs.ext2 or mkfs.reiserfs, etc. The syntax is mkfs –t <fstype> <device>
3. Make directories in /mnt and mount the new partitionsAt this stage the system has added a journal to the /dev/hda10 partition, making it an ext3 formated partition. This process is non-destructive and reversible. If you mount an ext3 as an ext2 filesystem, the . journal file will be erased. You can add it again with tune2fs …
File permissionsA basic way to interact with a computer system is to use the command line. The shell interprets the instructions typed in at the keyboard. The shell prompt (ending with $ or # for user root) indicates that it is ready for user input.
The shell is also a programming environment which can be used to perform automated tasks. Shell programs are called scripts.Most Common shells The Bourne shell
The Bourne again shellThe Korn shell
The C shell
Tom's C shell
/bin/sh
/bin/bash
/bin/ksh /bin/csh /bin/tcsh
Since the bash shell is one of the most widely used shells in the Linux world the LPI concentrates mainly on this shell.
Printing text to the screen
Full/Relative path
The shell interprets the first ¨word¨ of any string given on the command line as a command. If the string is a full or relative path to an executable then the executable is started. If the first word has no ¨/¨ characters, thenthe shell will scan directories defined in the PATH variable and attempt to run the first command matching the string.
For example if the PATH variable only contains the directories /bin and /usr/bin then the string xeyes won't be found since it is stored in /usr/X11R6/bin/xeyes so the full path needs to be runShell variables are similar to variables used in any computing language. Variable names are limited to alphanumeric characters. For example CREDIT=300 simply assigns the value 300 to the variable named CREDIT.
1. initialise a variable: Variable-Name=value (no spaces !!) 2. reference a variable: $Variable-NameThe set and env commands
set
Lists all variables
env
Lists all exported variables
PREDEFINED VARIABLES
DISPLAY
HISTFILE
HOME
LOGNAME
PATH
PWD
SHELL
TERM
MEANING
Used by X to identify where to run a client application
Path to the users .bash_history file
The path to the user's home
The name used by the user to log in
The current working directory
The shell used (bash in most Linux distributions)
The current terminal emulation
$!
represents the PID value of the last child process
$$
represents the PID of the running shell
$?
is 0 if the last command was executed successfully and 1 otherwise
UNIX processes normally open three standard file descriptors which enable it to process input and output. These standard descriptors can be redefined for any given process. In most cases the stdin descriptor is the keyboard, and the two output descriptors, stdout and stderr, is the screen.
A process and it’s 3 descriptorsNumerical values for stdin, stderr and stdout
stdin
0
stdout
1
stderr
2
stdout redirection
program > file
This will run the
fdisk utility and output the result to the partitions.txt file. No output is visible. Also notice
that the shell will read this line from the right. As a result, the
partitions.txt file will be created first if it doesn’t exist and overwritten if the ‘>’ operator is used.
stdin redirection
stderr redirection
piped commandsThe input (<), output (>) and pipe (|) characters are also special characters as well as the dollar ($) sign used for variables. We will not list them here but note that these characters are seldom used to name regular files.
WildcardsTIME="Today's date is `date +%a:%d:%b`”
echo $TIME
Today's date is Sun:15:Jul
history
1
ls
2
grep 500 /etc/passwd
Emacs Key Bindings for Editing the Command History
Ctrl+P
Previous line (same as Up-arrow)
Ctrl+n
Next line (same as Down-arrow)
Ctrl+b
Go back one character on the line (same as Left-Arrow)
Ctrl+f
Go forward one character on the line (Same as Right-Arrow)
Ctrl+a
Go to the beginning of the line (Same as <End>)
Ctrl+e
Go to the end of the line (Same as <Home>)
Example
!x
executes the latest command in the history list starting with an 'x'
!2
runs command number 2 from the history output
!-2
runs the command before last
!!
runs the last command
^string1^string2 run previous command and replace string1 by string2
2
. The command xterm has the following options:
-bg <color>
-fg <color>
set background
set foreground
-e <command> execute ‘command’ in terminal
Set a new alias such that the su command opens a new color xterm and prompts for a root
password.
3
. You can encode files using uuencode. The encoded file is redirected to stdout.
For example: uuencode /bin/bash super-shell > uufile encodes /bin/bash and will produce a file called
super-shell when running uudecode against the uufile
.
-
Split the uuencoded file into 5 files:
bash
echo $ALERT
In this new shell, redefine the variable ALERT
Absolute path
: independent of the user's current directory
starts with /
Relative path: depends on where the user is
doesn't start with /

find
Syntax:
find <DIRECTORY> <CRITERIA> [-exec <COMMAND> {} \;]
find /usr/X11R6/bin -name ¨x*¨.
find / -user 502
Matching lines are listed to standard out. This output can be acted upon. For example delete the file, or change the permission. The find tool has the build-in option –exec which allows you to do that. For example, remove all files belonging to user 502:
find / -type f -user 502 –exec rm –f {} \;
xargs
find / -type f -user 502 | xargs rm –fCommon criteria switches for
find
-type
-name
-user
-atime, ctime, mtime
-amin, cmin, mmin
-newer FILE
specify the type of file
name of the file
user owner
access, creation and modified times (multiples of 24 hrs)
access, creation and modified times (multiples of 1 min)
files newer than FILE

locate
Syntax:
locate <STRING>
locate X11R
which
Syntax:
which string

whereis
Syntax
whereis string
Most common options for ls
-I
show inode
-h
print human readable sizes
-n
list UIDs and GIDs
-p
append descriptor (/=@) to list
-R
recursively display content of directories
-S
sort by file size
-t
sort by modification time (similar to -c)
-u
show last access time
Making a directory with mkdir
:
When making a directory you can set the permission mode with the -m option. Another useful option is -p
which creates all subdirectories automatically as needed.
mkdir –p docs/programs/versions
Removing directories
:
To remove a directory use either rmdir or rm -r. If you are root you may have to specify -f to force the
deletion of all files.
cp
Syntax:
cp [options] file1 file2
cp [options] files directory
Most common options for cp
-d
do not follow symbolic link (when used with -R)
-f
force
-I
interactive, prompt before overwrite
-p
preserve file attributes
-R
recursively copy directories
mv
Syntax:
mv [options] oldname newname
mv [options] source destination
mv [options] source directory
ln -s lilo.conf lilo.sym
This is the listing for these files. Notice that the reference count is
1 for both files.
-rw------- 1 root root 223 Nov 9 09:06 lilo.conf
lrwxrwxrwx 1 root root 9 Nov 9 09:06 lilo.sym -> lilo.conf
ln lilo.conf lilo.linkExample:
touch file1.txt file2.txt
creates new files
touch myfile -r /etc/lilo.conf
myfile gets the time attributes of lilo.conf
This command copies a file with a changeable I/O block size. It can also be used to perform conversions
(similar to tr). Main options are if= (input file) of= (output file) conv= (conversion)
The conversion switch can be: lcase ucase ascii
In
/tmp/bin/ create a file called newfile (use touch, cat or vi).
Go to the root directory (cd /). View the content of newfile from there.
Which is the shortest command which will take you back to /tmp/bin ?
Which is the shortest command which will take you to your home directory ?
Is the PWD variable local or global ?
In order to create more space on the device containing the directory /usr/share/doc we need to find a spare device with enough space and copy the contents of /usr/share/doc to that device. Then we create create by deleting the /usr/share/doc directory and creating a symbolic link point from /usr/share/doc to the new location.
Make a directory called /spare on which we will mount suitable spare devices (one of the partitions created in the previous exercises should be suitable.|
|
|
|
|
`-xclock(1138)
|-xfgnome(1109)
|-xfpager(1108)
|-xfsound(1107)
`-xscreensaver(1098)
-soffice.bin(1153)
|-soffice.bin(1154) |-soffice.bin(1155) |-soffice.bin(1156)
`-soffice.bin(1157)ps
-ux
all processes run by the user
ps T
processes run under the current terminal by the user
ps aux
all processes on the system
ps
accommodates UNIX-style and BSD-style arguments
usage: ps -[Unix98 options]
ps [BSD-style options]
ps --[GNU-style long options]
ps –help for a command summary
-a
show all processes for the current user linked to a tty (
except the session leader)
-e or -A show all processes
-f gives the PPID (Parent Process ID) and the STIME (Start Time)
-l is similar to -f and displays a long list
Most Common Signals
1 or SIGHUP hangup or disconnect the process
2 or SIGINT same as Ctrl+C interrupt
3 or SIGQUIT quit
9 or SIGKILL kill the process through a kernel call
15 or SIGTERM terminate a process 'nicely'. This is the DEFAULT signal.
Process priority and nice numbers
renice +1 -p 234 765
nice --5 xclock
After you have started a process from the shell you automatically leave the shell interpreter. You will notice that no commands will respond. The reason for this is that it is possible to run programs in the foreground fg or in the background bg of a shell.
When a program is running in the foreground it is possible to recover the shell prompt but only by interrupting the program for while. The interruption signal is Ctrl Z.[1]+ Stopped
xclock
[mike localhost /bin]$bg
[1]+ xclock &
[mike localhost /bin]$
xclock running in forground, shell prompt lost
xclock received ^Z signal
shell prompt recovered, issue the bg command
Output for jobs
[1]- Stopped
xclock
[2] Running
xman &
[3]+ Stopped
xload
Finally there is a program called nohup which acts as a parent process independently from the user’s session. When a user logs off, the system sends a HUP to all processes owned by that process group. For example, to avoid this HUP signal a script called bigbang which attempts to calculate the age of the Universe should be started like this:
nohup bigbang &
count=0
while (true) do
echo this is iteration number $count
let count+=1
done
cd /tmp
./print-out &
exit
ps ux |grep print-out
tail -f ~/nohup.out
Ctrl+C
killall print-out
ps ux|grep print-out
tail -f ~/nohup.out

cat > short-message
we are curious
to meet
penguins in Prague
Crtl+D
-n
number each line of output
-b number only non-blank output lines
-A show carriage return
►
cat /etc/resolve.conf
search mydomain.org
nameserver 127.0.0.1

tac short-message
► penguins in Prague
to meet
we are curious
head -n 20 /var/log/messages
head -20 /var/log/messages
tail -20 /etc/aliases
tail +25 /etc/log/messagesOptions for
wc
-l
-w
-c or -m
Remarks:
With no argument wc will count what is typed in stdin.
count number of lines
count number of characters or words
count number of bytes or characters
nl -ba /etc/lilo.conf
nl -bt /etc/lilo.conf
cut –c5-10,15- /etc/password
cut -d: -f 1,7 --output-delimiter=" " /etc/passwd
tr ':' ' ' < /etc/passwdcat >> message
line 1
^D
cat >> message << STOP
line 2
STOP
Create a second file
pricing with two fields REFERENCE and PRICE separated by a space
e.g
001
9.99
Use join to display the reference, title and prices fields.
#!/bin/bash
count=0
while [ $count -lt 50 ] do
touch /tmp/files/$count.txt
let count+=1
done
do
FILENAME=$(echo $FILES| cut -d. -f1)
mv $FILES $FILENAME.dat
done
void Hello(){
printf(“Hi ! \n”);
}
Notice that the main.c is incomplete in the sense that the Hello() function is undefined. In the same way Hello.c doesn’t have a “main” declaration. So these files are interdependent. One can however compile object files (.o) which are like non-executable binary files which can be used to ‘build’ an application.
Compiling the object files:
gcc –c main.c
gcc –c Hello.c
gcc –o app main.o Hello.oSHELL = /bin/sh
CC = /usr/bin/gcc
app: main.o Hello.o
$(CC) –o app main.o Hello.o
main.o: main.c
$(CC) –c main.c
Hello.o: Hello.c
$(CC) –c Hello.c
gcc main.c Hello.o
ar rcs libfoo.a file1.o file2.o
gcc –c –fPIC Hello.c creates the object file
gcc main.c libfoo.so.1.0
Figure 1: The Shared Library Names
►
ldd a.out
libfoo.so.1.0 => not found
libc.so.6 => /lib/libc.so.6 (0x40028000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
export LD_LIBRARY_PATH=$(pwd)The GNU specification advises libraries to be stored in /usr/local/lib. These guidelines are followed by developers and most tarballed code will install libraries in that directory and the binaries in/usr/local/bin. Installing and removing this code from the system would be done by ¨make install¨ and ¨make uninstall¨.
The FHS (Filesystem Hierarchy Standard) recommends libraries be kept in /usr/lib/and associated binaries in /usr/bin/. This convention standard is adhered to by Linux distributions. In effect mature and stable code is stored in /usr/ rather than /usr/local/ and the two standards do not lead to any contradictions. Installing and removing this code code would be done using the rpm command.
NOTICEMakefile: This acts like a configuration file for the
make utility. The main information provided is:
- The name of the compiler and compiling options
- The path to the shared libraries and header files
- Mapping between code files (.c) and object files (.o)
./configure
make
make install
Fig 1: Package Manager Functions
Short
Long
-i
–install
-U
–update
-F
--freshen
-V
--verify
-q
--query
-e
–erase
Description
Installs the package
Updates or installs a package
Updates only installed package
file size, MD5, permissions, type ...
Queries installed/uninstalled packages, and files
Uninstall package
Short
Description
a
applies to all installed packages
c
together with q lists configuration files
d
together with q lists docomentation files
h
adds hashes while processing
i
together with q lists information about a package
l
together with q lists all files and directories in a package
p
together with q specifies that the query is performed on the package file
v
verbose
rpm –qpl routed-0.17.i386.rpm
rpm –ql routed-0.17
or
rpm –ql routed
rpm –qf /usr/sbin/routedQuery Type Option Package file -qp Installed package -q File -qf
An extra option will allow you to get information on all installed files –l, documentation –d configuration files – c, etc ...--nodeps
--force
--test
--requires
this allows to install without regard to dependencies
force an upgrade
doesn’t actually install or upgrade, just prints to stdout
show package requirement
This is additional information, this paragraph is not an LPI 101 objective. When doing this section you may encounter problems with the –rebuild option, this is due to the fact that the new versions of RPM use rpmbuild instead of rpm when rebuilding packages.
The source code for many RPM packages is also available as an RPM package and will be used to build a binary package. The naming convention is:These packages contain at least two files, the tarball with the code and a spec file. The spec file contains instructions to patch, compile and build the RPM package. If the code needs to be patched before compilation then the patches are included in the source package.
There are three different ways to build a RPM package. We will assume that we have a package called name-version-release.src.rpm.This will copy files to the following directories:
/usr/src/redhat/SPECS
/usr/src/redhat/SOURCES
In the /usr/src/redhat/SPECS directory there is now a file called name.spec (where ‘name’ is the name of the package). To start building the compiled package, that is name-version-release.i386.rpm, we type in the following command:
rpm –ba name.specIf the compilation succeeds then the built binary package will be saved in /usr/src/redhat/RPMS/. There are different subdirectories corresponding to various CPU models/generations. If the compilation didn’t involve specific features from these chips then the package will be saved in the noarchdirectory.
Method 2:- Optional (recommended!): The patches can be applied. Depending on which directory you are in
the syntax will vary.
From/usr/src/redhat/SOURCES:
./configure
make
If you are sure you want to install this package thenmake install but remember that this will not install the
software using the package manager.
The compiled binary package should be in
/usr/src/redhat/RPMS
- Check the package’s contents with the –qpl option
- Install the package(s), and run queries on the installed package
- Uninstall the package
Finding a word or multiple words in a text is achieved using grep, fgrep or egrep. The keywords used during a search are a combination of letters called regular expressions. Regular expressions are recognised by many other applications such as sed, and vi.
x
(or any character)
\<KEY
WORD\>
^
$
[ Range ]
[^c ]
\[
“cat*”
“.”
Search Match
Strings containing an ‘x’
Words beginning with ‘KEY’
Words ending with ‘WORD’
Beginning of a line
End of a line
Range of ASCII characters enclosed
Not the character ‘c’
Interpret character ‘[‘ literally
Strings containing ‘ca’ or ‘cat’ plus anything
Match any single character
“
A1|A2|A3”
“cat+”
“cat?”
Search Match
Strings containing ‘A1’ or ‘A2’ or ‘A3’
Strings containing at least cat plus anything
Strings containing ‘ca’ or ‘cat’ plus anything
grep
Main Options
-c
count the number of lines matching PATTERN
-f
obtain PATTERN from a file
-i
ignore case sensitivity
-n
indicate the input file's line number
-v
output all line except those containing PATTERN
-w
match exact PATTERN
grep –v “^$” /etc/lilo.conf
fgrep ‘cat*’ FILE
egrep “linux|^image” /etc/lilo.conf
sed ‘/^#/ d ’ MODIF
sed ‘s/\/dev\/hda1/\/dev\/sdb3/g’ MODIF
sed ‘ /KEY/ s/:/;/g’ MODIF
sed –e ‘/^$/ d’ -e ‘s/OLD/NEW/g’ MODIFAn example COMMANDS file
1 s/old/new/
/keyword/ s/old/new/g
23,25 d
Commandline flags
-e Execute the following command
-f Read commands from a file
-n Do not printout unedited lines
Command options
d Delete an entire line
r Read a file and append to output
s Substitute
w Write output to a file
Using grep,
fgrep and
egrep
to grep for 99% of the cats
% these are two
% commented lines
2. Regular expressions. Append the following lines to the previous file:
ca
cat
cats
catss
cat+
cat*
cat?
car
carriage
- Investigate the outcome of the following using
grep, egrep and fgrep:
grep ‘cat+’ FILE
grep ‘cat?’ FILE
3. Use
sed to do the following changes in FILE
(use a COMMAND file, then do everything on the commandline)
- in the first line substitute ‘grep,’ with ‘soap’
- delete ‘fgrep’ in the second line
- substitute ‘egrep’ with ‘water’
- in the fourth line replace ‘grep for’ with 'wash'
Save the result to a file using the w option
This is the editing and navigation mode. Commands are often just a letter. For example use
j to jump to
the next line.
As a rule of thumb if you want to perform an operation several times you can precede the command by a
number. For example 10j will jump 10 lines.
You enter this mode from the command mode by typing a colon . The column will appear at the bottom left corner of the screen. In this mode you can perform a simple search operation, save, quit or run a shell command.
● Insert Modee resp. b Move to the end/begining of the current word ( resp. ) Move to the begining/end of the current sentence { resp. } Move to the begining/end of the current paragraph w Similar to e but includes the space after the word
Beginning and End^
Beginning of line
$
End of line
1G
Beginning of file
G
End of file
All these text items can be used to navigate through the text one word ( w) or paragraph ( })at a time, go to the beginning of a line (^) the end of the file (G) etc. One can also use these text items to execute commands such as deleting and copying.
When in command mode typing i will allow you to enter text in the document interactively. As with all other features in vi there are many other ways of doing this. The table below lists all possible inserting modes.
Insert commands
a
Append text with cursor on the last letter of the line
A
Append text with cursor after last letter at the end of the line
i
Insert text at the current position
o
Insert text on a new line below
O
Insert text on a new line above
s
Delete the current letter and insert
S
Delete current line and insert
Remark : Nearly all vi commands can be repeated by specifying a number in front of the command. You can also apply the command to a text item (such as word., sentence, paragraph ...) by placing the entity after the command.
Table4:Words and Characters
w
single word
l
single character
Examples:
Delete a word:
dw
Since searching involves pattern matching we find ourselves once again dealing with regular expressions (regex). As many UNIX text manipulation tools such as grep or sed, vi recognises regular expressions too.
To perform a search one must be in colon mode. The / (forward slash) command searches forward and the ? command searches backwards.Example:
Search for words beginning with ‘comp’ in all the text
/\<comp
The command for saving is w. By default the complete document is saved. One can also specify an alternative name for the file. Portions of the text can be saved to another file while other files can be read and pasted in the current document. Here are the examples which illustrate this.
Examples:
Save the current document as ‘newfile’
:w newfile
Warning
: In the column mode context we have the following
.
is the current line
$
is the end of the document
The X Windows system was developed as the display component of Project Athena at the Massachusetts Institute of Technology. It is the graphical environment for UNIX. The X Window system for Linux is based on the freely distributable port of X Window version 11 release 6 (Commonly referred to as X11R6).
This freely distributable port is commonly known as xfree86 for the 80386/80486 and Pentium processor families. Since its initial port, Xfree86 has been ported to other computing platforms, including System V/386 and 386BSD.
X11R6 Components and Configuration SectionsThe two clients depicted on top of the server are so-called x-applications (e.g xclock or xterm). The window manager is also a client. Window managers add “windowing” facilities around the other xapplication clients, allowing functionalities such as window dragging, focus, iconification, etc.
NOTICE:The X11R6 server is independent from the clients that run on top. Clients are configured using specific configuration files or global files usually called Xdefaults or Xresources. The X server configuration file will only configure components such as the font server and font directories, mouse, keyboard, monitor resolution and color depth.
Xconfigurator
, redhat-config-xfree86 (RedHat)
XFdrake (Mandrake)
sax (Suse)
All the above mentioned configuration utilities will create and edit the XF86Config configuration file. This file is read at start up by the X Server and determines its behaviour. This file is typically found in the / etc/X11 directory, and this is its’ full path: /etc/X11/XF86Config.
There are 11 configuration sections in the config file, they are listed below:ServerFlags
Module
InputDevice
Device
VideoAdapter
Monitor
Modes
Screen
ServerLayout
DRI
Vendor
One of the first sections is the Section “Files”. The FontPath keyword tells whether to get fonts from a local directory or from a font server. TheRgbPath keyword is used to indicate the full path to rgb text file used to map color names to RGB notation:
Section “Files”
FontPath “/path/to/fonts/dir/”
FontPath “trans/hostname:port”
RgbPath "/path/to/rgb"
Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
FontPath
"/usr/X11R6/lib/X11/fonts/misc:unscaled,/usr/X11R6/lib/X11/fonts/75dpi:unsc
aled,/usr/X11R6/lib/X11/fonts/100dpi:unscaled,/usr/X11R6/lib/X11/fonts/misc
/"
EndSection
Section "InputDevice"
Identifier "Keyboard0"
Driver "keyboard"
Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "IMPS/2"
Option "Device" "/dev/psaux"
Option "ZAxisMapping" "4 5"
Section "Monitor"
Identifier "Primary Monitor"
VendorName "Unknown"
ModelName "Unknown"
HorizSync 31.5-37.9
VertRefresh 55-90
Modeline "800x600" 40.00 800 840 968 1056 600 601 605 628 +hsync
Section "Device"
Identifier "Primary Card"
VendorName "Unknown"
BoardName "None"
VideoRam 2048
Section "Screen"
Driver "Accel"
Device "Primary Card"
Monitor "Primary Monitor"
DefaultColorDepth 24
BlankTime 0
SuspendTime 0
OffTime 0
SubSection "Display"
Depth 24
Modes "800x600"
EndSubSection
SubSection "Display"
Depth 32
Modes "800x600"
xterm_color*background: Black
xterm_color*foreground: Wheat
xterm_color*cursorColor: Orchid
xterm_color*reverseVideo: false
xterm_color*scrollBar: true
xterm_color*saveLines: 5000
xterm_color*reverseWrap: true
xterm_color*font: fixed
xterm_color.geometry: 80x25+20+20
xterm_color*fullCursor: true
xterm_color*scrollTtyOutput: off
xterm_color*scrollKey: on
term_color*VT100.Translations: #override\n\
Each of these directives is a system default directive that describes how a client will be displayed. Each line consists of the client name followed by an asterisk and the X Window parameter. Through a carefully configured .Xresources file the user can define the way a client will look each time it is started.
The startx script starts xinit. The xinit script has two main arguments (a) the X server and (b) the xinitrc script. The xinitrc script will source (read) the files Xresourses (controlling the x-applications) and the Xclients (choosing a window manager). So we can symbolise the startup sequence as follows:
startx --> xinit --> X -> xinitrc -> Xclient (wm/desktop)/etc/X11/xdm/ /etc/X11/gdm/ /etc/X11/kdm/
However kdm no longer follows this convention. So we will take a closer look at xdm and gdm.Display Managers are used mainly in run level 5 to allow local users to log onto the system using the graphical interface. However display managers can also be used to provide a graphical login interface over the network. To do this they use a protocol called XDMCP or X Display Manager Control Protocol. By default XDMCP is disabled (we will enable XDMCP as an exercise).
X server and Display Manager/etc/X11/xdm/Xrescources
Since the Display Manager is also an x-application, the fonts, the background colors and xlogin
can be configured with the Xresourses file in /etc/X11/xdm/. When using gdm, the
/etc/X11/gdm/Init/Default script will source Xresources.
This file simply maps the name of a display with an X server. For example display
:0 is
understood
to be the local X server. Remember that X always runs on the first free /dev/tty.
/etc/X11/xdm/Xaccess
This file is used to enable XDMCP, allowing remote hosts to directly connect to the local server
( using -query) or query about other display
The Xaccess file
# $XConsortium: Xaccess,v 1.5 91/08/26 11:52:51 rws Exp $
#
# Access control file for XDMCP connections
# To control Direct and Broadcast access:
#
#
pattern
#
# To control Indirect queries:
#
#
pattern
#
# To use the chooser:
#
#
pattern
#
# or
#
#
pattern
#
# To define macros:
#
# %name
#
# The first form tells xdm which displays to respond to itself.
# The second form tells xdm to forward indirect queries from hosts matching
# the specified pattern to the indicated list of hosts.
# The third form tells xdm to handle indirect queries using the chooser;
# the chooser is directed to send its own queries out via the broadcast
# address and display the results on the terminal.
# The fourth form is similar to the third, except instead of using the
# broadcast address, it sends DirectQuerys to each of the hosts in the list
#
# In all cases, xdm uses the first entry which matches the terminal;
# for IndirectQuery messages only entries with right hand sides can
# match, for Direct and Broadcast Query messages, only entries without
# right hand sides can match.
#
list of hostnames and/or macros ...
#
# To hardwire a specific terminal to a specific host, you can
# leave the terminal sending indirect queries to this host, and
# use an entry of the form:
#
# The nicest way to run the chooser is to just ask it to broadcast
# requests to the network - that way new hosts show up automatically.
# Sometimes, however, the chooser can't figure out how to broadcast,
# so this may not work in all environments.
#
# If you'd prefer to configure the set of hosts each terminal sees,
# then just uncomment these lines (and comment the CHOOSER line above)
# and edit the %hostlist line as appropriate
#
#%hostlist
host-a host-b
#*
CHOOSER %hostlist
#
# $XConsortium: Xserv.ws.cpp,v 1.3 93/09/28 14:30:30 gildea Exp $
#
#
# $XFree86: xc/programs/xdm/config/Xserv.ws.cpp,v 1.1.1.1.12.2 1998/10/04 15:23:14 hohndel Exp $
#
# Xservers file, workstation prototype
#
# This file should contain an entry to start the server on the
# local display; if you have more than one display (not screen),
# you can add entries to the list (one per line). If you also
# have some X terminals connected which do not support XDMCP,
# you can add them here as well. Each X terminal line should
# look like:
#
XTerminalName:0 foreign
#
:0 local /usr/X11R6/bin/X
Sample Xrescources file
! $XConsortium: Xresources /main/8 1996/11/11 09:24:46 swick $
xlogin*borderWidth: 3
xlogin*greeting: CLIENTHOST
xlogin*namePrompt: login:\040
xlogin*fail: Login incorrect
#ifdef COLOR
xlogin*greetColor: CadetBlue
xlogin*failColor: red
*Foreground: black
*Background: #fffff0
#else
xlogin*Foreground: black
xlogin*Background: white
#endif
XConsole.text.geometry:
480x130
XConsole.verbose:
true
XConsole*iconic:
true
XConsole*font:
fixed
Sample xdm-config file
! $XFree86: xc/programs/xdm/config/xdm-conf.cpp,v 1.1.1.2.4.2 1999/10/12 18:33:29 hohndel Exp $
!
DisplayManager.servers:
/etc/X11/xdm/Xservers
DisplayManager.accessFile:
/etc/X11/xdm/Xaccess
! All displays should use authorization, but we cannot be sure
! X terminals will be configured that way, so by default
! use authorization only for local displays :0, :1, etc.
DisplayManager._0.authorize: true
DisplayManager._1.authorize: true
!
DisplayManager*resources:
/etc/X11/xdm/Xresources
DisplayManager*session:
/etc/X11/xdm/Xsession
DisplayManager*authComplain: false
! SECURITY: do not listen for XDMCP or Chooser requests
! Comment out this line if you want to manage X terminals with xdm
DisplayManager.requestPort:
0
Occasionally X Clients wont terminate properly leaving zombie processes. A zombie process in one whose parent processes has terminated, and cannot clear references to the child process. When a child process’ parent exits leaving the child process still running, this is usually visible by running ps which will reveal the child process being owned by PID 1 (init). These processes should be killed because they may be using CPU resources. Killing such a process requires the user to be the user who owns the process, or root. It might be necessary to use the –9 option to actually kill these processes.
The area that is commonly referred to as the desktop is also known in the X Window world as the screen. It covers the entire area of your monitor display. The root window is the background of your screen, typically used to display a colour or picture. The window manager provides an interface between the user and the X server. It is virtually impossible to use X without a window manager, because it provides the title bar and the familiar buttons with which you manipulate the display.
Information on available window managers is available from the Window Managers website at http://www.PliG.org/xwinman. Many of the Linux versions of these window managers are available at ftp://metalab.unc.edu/pub/Linux/X11/window-managers.
In addition to the various window managers there are also various desktop environments, among which the most common are KDE and GNOME.fvwm
icewm
amiWM
mlvwm
dfm
olwm
olvwm
mwm
Window Maker
AfterStep
Enlightenment
2. As root save the existing configuration file
/etc/X11/XF86Config and try out the various configuration
tools:
Redhat: Xconfigurator, redhat-config-xfree86 (8.0)
Mandrake : XFdrake
Suse: sax
XF86Setup
xf86config
X (this is the X11 server itself, use the -configure flag)
twm&
What has happened? Can you kill twm without killing X? Go back to a
virtual terminal (e.g Ctrl+Alt+F2) and type:
X –query 1.2.3.4 :1
or
X -indirect 1.2.3.4 :1