Linux administrator Manual

Source: Internet
Author: User
Tags syslog

Linux administrator Manual (1)-Linux System Overview
This chapter provides an overview of Linux. First, describe the main services provided by the operating system. Then describe the program implementing these services with a considerable lack of detail. This chapter aims to understand the system as a whole and further details each part.
Different parts of an operating system
A unix operating system includes a core program kernel and some system programs. There are also some applications that do something: application programs. The core is the heart of the operating system. It tracks files on the disk, starts programs and runs them, allocates memory and other resources to different processes, receives and sends packets to and from the network, and so on. The core rarely works on its own, but it provides tools that can be used to build all services. It also prevents anyone from directly accessing the hardware and forces everyone to use the tools it provides. In this way, the core provides protection between each user and other users. The tool provided by the core is used by calling system CILS through the system. To learn more about this, refer to the second part of the manual page.
System programs use the tools provided by the core to implement different services required by the operating system. System programs and all other programs run on the core, called the user mode. The difference between a system program and an application is the purpose: the application intends to do some useful work (or game), while a system program is required for system work. The word processor is an application, and telnet is a system program. The difference is often vague, maybe, just to force classification.
Although programming languages do not have to be part of the operating system, the operating system can also include compilers and their related libraries (gcc and C libraries in Linux ). Documents, and sometimes even games can be part of the operating system. Traditionally, the operating system is defined as the content on the installation tape or disk. It is not clear about Linux because it is distributed on FTP sites around the world.
Key components
Linux core includes several important parts: process management, memory management, hardware device driver, file system driver, network management and other different parts. Figure 2.1 shows some of them.
Memory Management and process management are the most important parts of the core (nothing or work. Memory Management is responsible for allocating the memory areas of processes and swap space areas, Core Components and buffer cache. Process Management generates processes, and multiple tasks are implemented by switching active processes on the processor.
At the lowest level, the core includes a hardware device driver for each type of hardware it supports. Because there are a large number of different hardware in the world, the number of hardware device drivers is huge. There are many different hardware, so the software control method is different. However, similarity may be classification-driven and supports similar operations. Each member of each type has the same interface as other core components, but the specific implementation is different. For example, all hard drive interfaces are the same as those of other core interfaces, that is, they all have initialization drive, read n sectors, and write n sectors.
Some software services provided by the core itself have similar abstract attributes, so they can be abstracted and classified. For example, different network protocols have been abstracted as a programming interface: BSD socket library. Another example is the virtual filesystem (VFS) layer, which abstracts file system operations from the file system operation implementation. Each file system type provides the implementation of each file system operation. When some entities attempt to use a file system, the request is sent through VFS, which sends the request to the appropriate file system driver.

Main services of UNIX systems
This section describes some of the most important UNIX services, but it is not very detailed. More details will be given in subsequent chapters.
Init
The most important service in UNIX systems is provided by init. Init is the first process that every UNIX system starts at the end of core boot. After init is started, it performs different startup work to continue the boot process (check and mount the file system, start the waken program, etc)
The list of specific tasks performed by init depends on the user's wishes. init has multiple startup options. The single user mode is usually provided. At this time, no user can log on. the root user uses a shell in the console. The common mode is multiuser mode. Generally, this is called run levels. The single-user and multi-user modes can be understood as two run-level instances, and there can be other run-level instances, such as running X on the console.
In normal operations, init confirms that getty runs normally (allows users to log on) and adopts orphan processes (the parent process is dead; in UNIX, all processes must be in a tree, therefore, the orphan process must be adopted ).
When the system is disabled, init is responsible for killing all other processes, unmount all file systems, and stop the processor.
Log on from the terminal
Log on from the terminal (via the serial line) and the console (when X is not run) are provided by the getty program. Init starts a separate getty instance getty read username for each terminal that allows logon and runs the login program to read the password. If the username and password are correct, login runs the shell. When the shell is terminated, that is, the user logs out, or the login is terminated because the user name and password are incorrect, init knows and starts a new getty instance. The core does not have the concept of logon, which is handled by system programs.
Syslog
Core and many system programs generate errors, warnings, and other information. This information will often be important in the future. Even a long time later, they should be written to a file. This program is syslog. It can be set to sort the information to different files according to the program or importance of the output information. For example, the core information is often separated from other information and directed to a separate file, because the core information is often more important and needs to be read regularly to determine the problem.
Scheduled command execution: cron and
Users and System Administrators often need to regularly run commands. For example, the system administrator may want to run a program to clear the directory (/tmp and/var/tmp) of the temporary files from the old files to avoid the disk being full, because not all programs correctly clear their temporary files.
The cron service does this. Each user has a crontab, which lists the commands to be executed and the time to be executed. The cron daemon process is responsible for starting the command at a specific time.
The at service is similar to cron, but it only runs once: The command is executed at a given time, but cannot be repeated automatically.
GUI
UNIX and Linux use user-level programs instead of integrating user interfaces into the core. User Interfaces provide both text and graphic environments.
This arrangement makes the system more flexible, but it is easy to implement different user interfaces for each program, making the system more difficult to learn.
The main graphic environment Used in Linux is the X Window System (X ). X does not implement user interfaces. It only implements one window system, that is, a tool that can implement graphical user interfaces. The three most popular user interface styles based on X are Athena, Motif, and Open Look.
Network
The network connects two or more computers so that they can communicate with each other. The actual connection and communication methods are somewhat complicated, but the results are very useful.
UNIX operating systems have many network features. Basic services: file systems, printing, and backup can all be completed over the network. This makes system management easier because it allows centralized management while gaining the advantages of minicomputers and distributed computing, such as cost reduction and better fault tolerance capabilities.
However, this book only outlines the network. For more information, see the Linux Network Administrator Guide, which includes a basic description of how to operate a network.
Network logon
Network logon is a little different from normal logon. Each terminal that can be logged on has a separate physical serial line. Each user who logs on from the network has a separate virtual network connection and can have any number. Therefore, it is impossible to run separate getty for each possible virtual connection. Network logon involves several different methods. telnet and rlogin are the main methods in TCP/IP networks.
Network logon provides a separate daemon program for each logon method (telnet and rlogin use different daemon programs), instead of using a group of getty programs to listen for all input login attempts. When a logon attempt is detected, a new instance is started to process the attempt. The original Instance continues to listen for other attempts. The work of the new instance is similar to that of the getty instance.
Network File System
The most useful thing about network services is to share files through the network file system of the network file system. This service generally uses Network File System or NFS, a Network File System developed by Sun.
Through the network file system, any file operation can be sent by a program on one machine to any other machine over the network. This fooled the program into thinking that all the files on other machines are on the machine where the program is running. This greatly simplifies information sharing because it does not require any modifications to the program.
Email
Email is usually the most important method for communication through a computer. An email is stored in a file in a specific format and sent and received using a specific email program.
Each user has an incoming mailbox (a file in a specific format), where all new emails exist. When a recipient sends an email, the email program locates the recipient's email address and adds a letter to the email address file. If the recipient's mailbox is on another machine, the mail will be sent to that machine, and it will use it to deliver the mailbox in the most appropriate way.
The email system includes many programs. Use a program (mail transfer agent or MTA, for example, sendmail or smail) to deliver a mail to a local or remote mailbox ), the user uses many different programs (mail user agent or MUA, such as pine or elm ). The email address is usually stored in/var/spool/mail.
Print
At the same time, only one person can use a printer, but it is not economical for all users to share the printer. Therefore, the printer is managed by the software to implement a print queue: all the print tasks are put into one queue. After the printer completes a task, it will automatically print the next one. This removes the need for users to organize print queues and avoids direct control of printers.
The print queue software also prints the output spools to the disk. That is, when the task is in the queue, the print output is stored in a file. This allows the application to quickly complete a print task to the print queue program. The application can continue without waiting until the print task is completed. This is really convenient because it allows you to print out a version, and you do not need to print it, you can continue to modify a new version.
File System layout
The file system is divided into many parts, usually from the root file system:/bin,/lib,/etc,/dev, and some others; /usr file system contains programs and unchanged data;/var file system contains changed data (such as log files);/Home file system contains the personal files of each user. Depending on the hardware configuration and System Administrator's decision, the method is different, and even everything may be in a file system.
Chapter 3 describes the file system layout in more detail.
Linux administrator Manual (2) -- directory tree Overview
This chapter describes the important part of the standard Linux directory tree, which is based on the fsstnd File System Standard. This section describes how to divide a directory tree into several separated file systems based on different purposes and given requirements. Other methods are also described.
Background
This chapter is loosely based on the Linux File System Standard fsstnd version 1.2 (see [qui95]) and intends to establish a standard for how to organize the Linux directory tree. Such a standard is easy to write or port (port ?) The advantages of Linux software and Management of Linux systems, because everything will be in their ordinary place. This standard does not have the authority to force everyone to follow, but it has the most support for Linux distributions. If there is no special reason, it is not a good idea to follow fsstnd. Fsstnd is intended to comply with Unix traditions and current trends, making it easier for people familiar with other UNIX systems to accept Linux systems (and vice versa ).
This chapter is not as detailed as fsstnd. A system administrator should read fsstnd for full understanding.
This chapter does not detail all documents. The intention is not to describe each file, but to give an overview of the system from the perspective of the file system. More information about each file is stored in this manual or elsewhere on the man page.
The full directory tree can be divided into small parts. Each part can be stored on its own disk or partition to accommodate the disk capacity and be easily backed up and managed by other systems. The main parts are the root,/usr,/var, And/Home file systems. Each part has a different purpose. The directory tree has been designed to work well on the network of Linux machines. Some parts of the file system can be shared through read-only devices (such as CDROM) or NFS networks.
The following describes the tasks in different parts of the directory tree.
Each machine has a root file system (usually on a local disk, or on a ramdisk or network disk), which contains the necessary files for system guidance and enabling other file systems to mount, the root file system should have enough content in a single user State. Tools such as repair of damaged systems and Backup Recovery should also be included.
The/usr file system contains all commands, libraries, man pages, and other unchanged files required in general operations. /Usr should have no specific files for the given machine, and should not have files to be modified in general use. This allows the files in the file system to be shared over the network, which is more effective because it saves disk space (/usr can easily be several hundred megabytes ), and easy to manage (only the master/usr needs to be changed when upgrading the application, without changing each machine). Even if the file system is on a local disk, it can be read-only mounted, to reduce the damage to the file system when the system crashes.
The/var file system contains changed files, such as spool directories (for mail, news, printers, etc.), log files, formatted manual pages, and temporary files. Traditionally, everything in/var was stored somewhere in/usr, but it is impossible for/usr to be read-only.
/Home file system contains the user's home directory, that is, all the actual data on the system. Assigning home directories to your own directory tree or file system is easy to back up. Other parts often do not have to be backed up, at least do not have to be backed up frequently (they are rarely changed ). A large/home may be divided into several file systems. You need to add a level-1 name under/home, such as/home/students and/home/staff.
Although different parts are called file systems above, they do not have to be truly separated file systems. If the system is a small single-user system and users want to simplify it, they can easily put it in a file system. The directory tree can also be distributed to different file systems based on the disk capacity and the space to be allocated for different purposes. It is important to use the standard name, even if/Var and/usr are in the same partition, the name/usr/lib/libc. A And/var/adm/messages must work. For example, move the file under/var to/usr/Var and connect/VaR as the symbol of/usr/var.
The UNIX file structure groups files based on the purpose, that is, all commands are in one place, all data is in another place, and all documents are in another place. Another method is to group files according to the program, that is, all Emacs files are in one directory, all Tex files are in another directory, and so on. The problem with the latter method is that files are difficult to share (program directories often contain static and dynamic files that can be shared at the same time ), sometimes it is difficult to find (for example, it is extremely difficult for man programs to find man pages in a large number ).

Root file system
Generally, the root file system should be relatively small, because including strict files and a small, infrequently changed file system is not prone to damage. A corrupted root file system generally means that this risk should not be taken unless the system cannot be booted using a specific method (such as from a floppy disk.
The root directory generally does not contain any files, except for possible standard system boot images, which are usually called/vmlinuz. All other files are in the subdirectory of the root file system.
/Bin
Commands required for boot or commands that may be used by common users (possibly after boot ).
/Sbin
Similar to/bin, but not for common users, although it can be used if necessary and allowed.
/Etc
Configuration file of a specific machine.
/Root
Root user's home directory.
/Lib
Shared libraries required by programs on the root file system.
/Lib/modules
The core can load modules, especially those needed to boot when restoring damaged systems (such as network and file system drivers ).
/Dev
Device File.
/Tmp
Temporary File. Programs running after boot should use/var/tmp instead of/tmp, because the former may be on a disk with more space.
/Boot
The file used by the bootstrap loader, such as LILO. The core image is often here, not in the root directory. If there are many core images, this directory may become very large and it may be better to use a separate file system. Another reason is to ensure that the core image must be in the first 1024 cylinder of the IDE hard disk.
/Mnt
System Administrator temporary mount Installation Point. The program does not automatically support installation to/mnt. /Mnt can be divided into sub-directories (for example,/mnt/dosa may be a soft drive using the MSDOS file system, while/mnt/exta may be a soft drive using the ext2 File System ).
/Proc,/usr,/var,/home
Other File System installation points.
/Etc directory
The/etc directory contains many files. The following describes some of them. Others you should know which program they belong to and read the man page of the program. Many network configuration files are also in/etc, which are described in the network management guide.
/Etc/rc or/etc/rc. d or/etc/rc. d
Start or change the scripts or scripts directory that runs at the running level. For more information, see the init chapter.
/Etc/passwd
User database, where the domain provides the user name, real name, Home Directory, encrypted password, and other user information. For the format, see the man page of passwd.
/Etc/fdprm
Floppy Disk parameter table. Different floppy disk formats are described. Set with setfdprm. For more information, see the man page of setfdprm.
/Etc/fstab
The mount-a command (in/etc/rc or equivalent Startup File) automatically mounts the list of file systems at startup. In Linux, information about the swap zone enabled with swapon-a is also included. See section 4.8.5 and the mount man page.
/Etc/group
Similar to/etc/passwd, but it does not indicate the user but the group. See the man page of the group.
/Etc/inittab
Init configuration file.
/Etc/issue
Getty output before the logon prompt. It usually includes a short description or welcome information of the system. The content is determined by the system administrator.
/Etc/magic
File configuration file. It contains descriptions of different file formats. Based on this, the file guesses the file type. See the man pages of magic and file.
/Etc/motd
Message Of The Day, which is automatically output after successful logon. The content is determined by the system administrator. It is often used for notification information, such as warning about the scheduled shutdown time.
/Etc/mtab
List of currently installed file systems. It is initialized by scripts and automatically updated by the mount command. This command is used when you need a list of currently installed file systems, such as the df command.
/Etc/shadow
The shadow password file on the system where the shadow password software is installed. The shadow password file moves the encrypted password in the/etc/passwd file to the/etc/shadow file, which is only readable to the root user. This makes password cracking more difficult.
/Etc/login. defs
The configuration file of the login command.
/Etc/printcap
Similar to/etc/termcap, but for printers. Different syntaxes.
/Etc/profile,/etc/csh. login,/etc/csh. cshrc
Files executed by Bourne or C shells at login or startup. This allows the system administrator to create a global default environment for all users. For various shells, see the man page.
/Etc/securetty
Confirm the security terminal, that is, the terminal that allows root login. Generally, only the virtual console is listed. In this way, it is impossible (at least difficult) to break into the system through a modem or network and obtain super user privileges.
/Etc/shells
List trusted shells. The chsh command allows you to change the logon shell within the range specified in this file. The ftpd service process that provides an FTP service on a machine checks whether the user's shell is listed in the/etc/shells file. If not, the user is not allowed to log on.
/Etc/termcap
Terminal performance database. Describes the "Escape Sequence" control used by different terminals. When writing a program, the escape sequence is not output directly (this can only work on terminals of a specific brand), but the correct sequence of the work to be done is searched from/etc/termcap. In this way, most programs can run on most terminals. See the man pages of termcap, curs_termcap, and terminfo.
/Dev directory
The/dev directory contains the device files of all devices. Device Files are named according to specific conventions, which are described in the device list (see [Anv]). The device file is generated during installation and can be described in/dev/MAKEDEV later. /Dev/MAKEDEV. local is the description document written by the system administrator for the local device file (or connection) (for example, some non-standard device drivers are not part of the standard MAKEDEV ).
/Usr File System
The/usr file system is often large because all programs are installed here. All files in/usr are generally from Linux distribution. Locally installed programs and other things are under/usr/local. In this way, you do not need to re-install all programs when upgrading the new system or the new distribution. Some subdirectories of/usr are listed below (some less important directories are omitted. For more information, see fsstnd ).
/Usr/x11r6
All files in the X Window System. To simplify the development and installation of X, X files are not integrated into the system. X is similar to/usr in/usr/x11r6.
/Usr/x386
Similar to/usr/x11r6, but for X11 Release 5.
/Usr/bin
Almost all user commands. Some commands are in/bin or/usr/local/bin.
/Usr/sbin
Unnecessary system management commands for the root file system, such as most service programs.
/Usr/man,/usr/info,/usr/doc
The manual page, the GNU information document, and various other documents.
/Usr/include
C Programming Language header file. For consistency, this should be in/usr/lib, but this name is traditionally supported.
/Usr/lib
Unchanged data files of programs or subsystems, including some site-wide configuration files. The name lib comes from the library. The original programming inventory is in/usr/lib.
/Usr/local
Install the software and other files locally.
/Var file system
/Var includes the data to be changed during normal system running. Each system is specific, that is, it is not shared with other computers through the network.
/Var/catman
The cache of man pages when formatting is required. The source file of the man page usually exists in/usr/man *. Some man pages may have pre-formatted versions and are stored in/usr/man/cat. Other man pages need to be formatted when they are viewed for the first time. The formatted version exists in/var/man, so that other people do not have to wait for formatting when looking at the same page. (/Var/catman is often cleared, just like clearing a temporary directory .)
/Var/lib
The file to be changed when the system is running normally.
/Var/local
Variable data of programs installed in/usr/local (that is, programs installed by the system administrator ). Note: if necessary, other/var directories, such as/var/lock, will be used even for locally installed programs.
/Var/lock
Lock the file. Many programs follow the Convention of generating a locked file in/var/lock to support their use of a specific device or file. Other programs will not try to use this device or file when they notice this locked file.
/Var/log
Log Files of various programs, especially login (/var/log/wtmp log all logon and logout to the system) and syslog (/var/log/messages stores all core and system program information. Files in/var/log often grow uncertain and should be cleared regularly.
/Var/run
The system information file that is valid before the next boot. For example,/var/run/utmp contains the information of the user currently logged on.
/Var/spool
Mail, news, print the working directory of the queue and other queues. Each different spool has its own sub-directories under/var/spool. For example, the user's email address is in/var/spool/mail.
/Var/tmp
Larger than/tmp, or temporary files that require a long period of time. (Although the system administrator may not allow/var/tmp to have very old files .)
/Proc file system
The/proc file system is a false file system. It does not exist on a disk. Instead, the core is generated in the memory. Used to provide information about the system (originally about processes, hence the name ). The following describes some of the most important files and directories. The/proc file system is described in more detail on the proc man page.
/Proc/1
The information directory of process 1. Each process has a directory named process number under/proc.
/Proc/cpuinfo
Processor information, such as type, manufacturer, model, and performance.
/Proc/devices
List of device drivers of the core configurations currently running.
/Proc/dma
Displays the currently used DMA channel.
/Proc/filesystems
Core configuration file system.
/Proc/interrupts
Displays the interruption of use, and how to handle the each there have been.
/Proc/ioports
The currently used I/O port.
/Proc/kcore
System physical memory image. It is identical to the physical memory size, but does not actually occupy so much memory; it is generated on the fly as programs access it. (Remember: Unless you copy it to somewhere, nothing in/proc occupies any disk space .)
/Proc/kmsg
Core Output Message. Also sent to syslog.
/Proc/ksyms
Core symbol table.
/Proc/loadavg
System "average load"; three meaningless indicators indicate the current workload of the system.
/Proc/meminfo
Memory usage information, including physical memory and swap.
/Proc/modules
Which core modules are currently loaded.
/Proc/net
Network Protocol status information.
/Proc/self
Symbolic connection to the process directory of the program to view/proc. When two processes view/proc, the connection is different. This allows the program to obtain its own process directory.
/Proc/stat
Different States of the system, such as the number of page faults since the system was booted.
/Proc/uptime
The duration of system startup.
/Proc/version
Core version.
Note that all the above files provide readable text files, which may sometimes be difficult to read. Many commands have been formatted to make it easier to read. For example, the free program reads/proc/meminfo and converts the number of bytes to kilobytes (and adds some information ).

 

For the original article, see:

Http://linux.chinaunix.net/techdoc/system/2008/02/15/978355.shtml

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.