The source code and other machine-readable formats of this book can be found on the Internet via anonymous FTP at the Linux Documentation Project home page http://www.linuxdoc.org/, or at the home page of this book at http://people.debian .org/~ba gpuss/.
Introduction
Only the purpose of the program and as much of its use as is necessary for the purposes of this manual are described. Normally all documentation mentioned is part of the complete Linux documentation set.
About This Book
Acknowledgements
- Joanna's acknowledgements
- Stephen's acknowledgements
Typographical Conventions
Overview of a Linux System
Various parts of an operating system
Important parts of the kernel
Probably the most important parts of the kernel (nothing else works without them) are memory management and process management. For example, all disk drivers look the same to the rest of the kernel, ie. they all have operations like.
Major services in a UNIX system
- init
- Logins from terminals
- Syslog
- Periodic command execution: cron and at
- Graphical user interface
- Networking
- Network logins
- Network file systems
- Printing
- The filesystem layout
There is a separate physical serial line for each terminal through which it is possible to log in. The print queue software also rotates the prints to disk, that is, the text is held in a file while the job is queued.
Overview of the Directory Tree
- Background
- The root filesystem
- The /etc directory
- The /dev directory
- The /usr filesystem
- The /var filesystem
- The /proc filesystem
Each different spool has its own subdirectory under /var/spool, e.g. the news spool is in /var/spool/news. It is used to provide information about the system (originally about processes, hence the name).
Device Files
The MAKEDEV Script
The mknod command
Device List
The loopback devices are block devices on the main node 7 and with minor nodes starting at 0 and numbered sequentially. Metadisk units are block units on major node 9 with minor nodes starting at 0 and numbered sequentially.
Using Disks and Other Storage Media
Two kinds of devices
In the output of ls −l, the first column contains the file's type and its permissions. The first character in the first column, i.e. The `c' in crw−rw−rw− above tells an informed user the type of the file, in this case a character unit.
Hard disks
To overcome this, the hard drive controller lies about the geometry and translates the addresses given by the computer into something that matches reality. SCSI drives use a sequential sector number (that is, the controller translates a sequential sector number into a head, cylinder, and sector triplet) and an entirely different method for the CPU to talk to the controller, so they are isolated from the problem.
Floppies
Note, however, that the computer may not even know the true geometry of a SCSI drive. Note that device files for hard drives give access to the entire drive, regardless of partitions (which will be discussed below), and it is easy to corrupt it.
CD−ROMs
Tapes
Formatting
The badblocks command can be used to search any disk or partition for bad blocks (including a floppy). The initial check for bad blocks can be done by the mkfs command (which initializes the file system), but later bad block checks must be done and the new blocks added with fsck.
Partitions
- The MBR, boot sectors and partition table
- Extended and logical partitions
- Partition types
- Partitioning a hard disk
- Device files and partitions
In reality, however, operating systems don't really care about the byte of the partition type; Linux, for example, doesn't care at all what it is. Sometimes it is possible to use a boot partition that is only partially within the first 1024 cylinders.
Filesystems
- What are filesystems?
- Filesystems galore
- Which filesystem should be used?
- Creating a filesystem
- Mounting and unmounting
- Checking filesystem integrity with fsck
- Checking for disk errors with badblocks
- Fighting fragmentation
- Other tools for all filesystems
- Other tools for the ext2 filesystem
It is designed to be easily upwardly compatible, so that new versions of the file system code do not require conversion of the existing file systems. Note that although it is called a file system, no part of the proc file system touches any disk.
Disks without filesystems
It allows direct access to the file system data structures stored on disk and can therefore be used to repair a disk that is so broken that fsck cannot automatically fix it.
Allocating disk space
- Partitioning schemes
- Space requirements
- Examples of hard disk allocation
- Adding more disk space for Linux
- Tips for saving disk space
A "Secondary Section" is a named appendix or a front matter section of the Document which deals solely with the relationship of the publishers or authors of the Document to the document's overall subject matter (or to related matters) and contains nothing which cannot directly fall within that overall subject. For example, if the Document is partly a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship may be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them. A very small program (usually in ROM) that reads a fixed location on a disk (eg the MBR) and transfers control to it.
Memory Management
What is virtual memory?
The kernel will write the contents of a currently unused block of memory to the hard disk so that the memory can be used for another purpose. A swap partition is faster, but it's easier to resize a swap file (no need to repartition the entire hard drive, and possibly reinstall everything from scratch).
Creating a swap space
Since a hole in the file means that there are no disk sectors allocated (for that location in the file), it is not a good idea for the kernel to try to use them. It is best if the size is a multiple of 4 because the kernel writes memory pages that are 4 kilobytes in size.
Using a swap space
All swap spaces that are automatically used with swapon −a can be removed from use with swapoff −a;. Sometimes too much swap space can be used even though there is plenty of free physical memory.
Sharing swap spaces with other operating systems
Allocating swap space
This can sometimes improve performance depending on the relative speed of the disks and the access patterns of the disks.
The buffer cache
Make the same adjustment to the section headings in the Invariant Sections list in the license notice for the combined work. It is also sometimes (erroneously) a term used to mean the act of writing a file system to a disk (especially in the MS Windows/MS DOS world).
Boots And Shutdowns
An overview of boots and shutdowns
During startup, the computer first loads a small piece of code, the bootstrap loader, which in turn loads and starts the operating system. It loads the operating system from elsewhere on the disk (or from another place).
The boot process in closer look
However, it is possible to boot from a diskette with a file system, using LILO, the LInux loader. With LILO, it is also possible to provide a kernel command-line argument, after the name of the kernel or operating system.
More about shutdowns
This allows the file system to be checked while it is mounted; it is not a good idea to check a. The exact things it does depend on how it is configured; see Chapter 9 (not yet written) for more information.
Rebooting
For example, if the kernel panics and crashes and burns and generally misbehaves, it may be completely impossible to issue any new commands, so shutting down properly is somewhat difficult, and pretty much all you can do is hope nothing is too badly damaged and turn off the power. Some people like to shutdown three times with the command sync[33], wait for the disk I/O to stop, and then turn off the power.
Single user mode
Most Linux systems disable −r now when pressing ctrl−alt−del on the keyboard. Systems that are physically accessible to anyone can even be configured to do nothing when ctrl−alt−del is pressed.
Emergency boot floppies
However, the action on ctrl-alt-del is configurable, and it might be better to allow for some delay before the reboot on a multi-user machine.
- init comes first
- Configuring init to start getty: the /etc/inittab file
- Run levels
- Special configuration in /etc/inittab
- Booting in single user mode
The assignment in the fourth field does all the hard work of setting up a run level. A running system can be taken to single user mode by using telinit to request runlevel 1.
Logging In And Out
- Logins via terminals
- Logins via the network
- What login does
- X and xdm
- Access control
- Shell startup
This license is a copyleft type, which means that derivative works of the document must themselves be free in the same sense. Enter on the Title page the name of the publisher of the Modified Version as the publisher.
Managing user accounts
What's an account?
When a computer is used by many people, it is usually necessary to distinguish between users, for example, so that their private files can be kept private. 39] Thus, each user is given a unique username and that username is used to log in.
Creating a user
- Picking numeric user and group ids
- Initial environment: /etc/skel
- Creating a user by hand
You must make the password field `*' so that it is impossible to log in. In such cases, it is usually not necessary to set the password (last step above).
Changing user properties
Similarly, edit /etc/group with vigr if you also need to create a new group. For example, to set up an anonymous FTP server (so anyone can download files from it without having to create an account first), you need to create an account called ftp.
Removing a user
Similarly, if you want to add or remove a user to multiple groups, you need to edit /etc/group (with vigr).
Disabling a user temporarily
Tail scripts should be kept in a separate folder so that their names do not interfere with normal user commands.
Backups
- On the importance of being backed up
- Selecting the backup medium
- Selecting the backup tool
- Simple backups
- Making backups with tar
- Restoring files with tar
- Multilevel backups
- What to back up
- Compressed backups
The battery ensures that the clock will work even if the rest of the computer is without electricity. Translation is considered a type of modification, so you may distribute translations of the Document under the terms of section 4.
Keeping Time
Time zones
Linux has a timezone package that knows all existing timezones and can be easily updated when the rules change. Apart from setting the system time zone and upgrading the time zone data files, there is not much need to worry about time.
The hardware and software clocks
Showing and setting time
It is used when the system boots to read the hardware clock and set the program clock. If you need to set both clocks, first set the software clock with the date and then the hardware clock with the −w clock.
When the clock is wrong
If you change the clock, it may be unclear whether the commands should be executed or not. On an early Unix system, someone set the clock twenty years into the future, and cron wanted to run all the periodic commands for twenty years at once.
Finding Help
- Newsgroups and Mailing Lists
- Finding The Right Forum
- Before You Post
- Writing Your Post
- Formatting Your Post
- Follow Up
- More Information
- IRC
- Colours
- Be Polite
- Type Properly, in English
- Port scanning
- Keep it in the Channel
- Stay On Topic
- CTCPs
- Hacking, Cracking, Phreaking, Warezing
- Round Up
- Further Reading
- PREAMBLE
- APPLICABILITY AND DEFINITIONS
- VERBATIM COPYING
- COPYING IN QUANTITY
- MODIFICATIONS
- COMBINING DOCUMENTS
- COLLECTIONS OF DOCUMENTS
- AGGREGATION WITH INDEPENDENT WORKS
- TRANSLATION
- TERMINATION
- FUTURE REVISIONS OF THIS LICENSE
Preserve all the invariant sections of the document, unchanged in their text and in their titles. The author(s) and publisher(s) of the Document do not grant permission by this License to use their names for publicity for or to assert or imply endorsement of any Modified Version.