⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rhl07.htm

📁 linux的初学电子书
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>The Linux Man Pages</B></FONT></CENTER></H3>

<BR>

<P>The &quot;man&quot; in &quot;man pages&quot; stands for &quot;manual.&quot; (As usual, the creators of UNIX shortened a long but descriptive word to a shorter, cryptic one!) Typing man &lt;command&gt; lets you view the manual pages dealing with a 
particular command.

<BR>

<P>Try typing man passwd to see what the Linux manual has to say about the passwd command.

<BR>

<P>The general layout of a man page is as follows:

<BR>

<PRE>

<FONT COLOR="#000080">COMMAND(1) Linux Programmer's Manual COMMAND(1)

NAME

command - summary of what command does

SYNOPSIS

&lt;complete syntax of command in the standard Linux form&gt;

DESCRIPTION

More verbose explanation of what &quot;command&quot; does.

OPTIONS

Lists each available option with description of what it does

FILES

lists files used by, or related to, command

SEE ALSO

command_cousin(1), command_spouse(1), etc.

BUGS

There are bugs in Linux commands??

AUTHOR

J. S. Goobly (goobly@hurdly-gurdly.boondocks)

Linux 1.0 22 June 1994 1</FONT></PRE>

<P>The man page for passwd is actually quite understandable. Be warned, however, that man pages are often written in a very formal and stylized way that sometimes bears little resemblance to English. This is done not to baffle people, but to cram a great 
deal of information into as short a description as possible.

<BR>

<P>For example, try man ls. Notice how many options are available for ls and how long it takes to explain them!

<BR>

<P>Although it can take practice (and careful reading!) to understand man pages, once you get used to them, the first thing you'll do when you encounter a strange command is call up the man page for that command.

<BR>

<BR>

<A NAME="E69E43"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Finding Keywords in Man Pages</B></FONT></CENTER></H4>

<BR>

<P>Sometimes you know what you want to do, but you don't know which command you should use to do it. You can use the keyword option by typing man -k &lt;keyword&gt;. The man program will return the name of every command whose name entry (which includes a 
very brief description) contains that keyword.

<BR>

<P>For instance, you can search on manual:

<BR>

<PRE>

<FONT COLOR="#000080">darkstar:~$ man -k manual

man (1) - Format and display the on-line manual pages

whereis (1) - Locate binary, manual, and or source for program

xman (1) - Manual page display program for the X Window System</FONT></PRE>

<P>You have to be careful to specify your keyword well, though! Using directory as your keyword isn't too bad, but using file will give you many more entries than you will want to wade through.

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE>You might have noticed that commands seem to be followed by numbers in brackets, usually (1). This refers to the manual section. Back in the days when UNIX manuals came in printed, bound volumes, normal commands were in Section 1, files used by 
administrators were in Section 5, programming routines were described in Section 3, and so on.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE>Therefore, some man pages are not about commands at all, but rather about files or system calls used in Linux!

<BR>If a particular entry shows up in more than one section, man will show you the lowest-numbered entry by default. You can see higher-numbered entries by specifying the section number. For instance, Section 5 has a manual entry on the passwd file. To see 
this rather than the manual entry for the passwd command type man 5 passwd.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<BR>

<A NAME="E69E44"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>The bash Shell help Facility</B></FONT></CENTER></H4>

<BR>

<P>When you type a command at the prompt, the shell program takes what you've written, interprets it as necessary, and passes the result to the Linux operating system. Linux then performs the actions requested of it. Many Linux commands require Linux to 
find and start up a new program. However, the shell itself can perform a number of functions. These functions can be simple, often-used commands, so that the overhead of starting up separate programs is eliminated, or they can be facilities that make the 
shell environment friendlier and more useful. One of these facilities is the help command, which provides information on the bash shell's built-in functions.

<BR>

<P>Type help at the prompt. You will see at least some of the following:

<BR>

<PRE>

<FONT COLOR="#000080">GNU bash, version 1.14.6(1)

Shell commands that are defined internally. Type 'help' to see this list.

Type 'help name' to find out more about the function 'name'.

Use 'info bash' to find out more about the shell in general.

A star (*) next to a name means that the command is disabled.

%[DIGITS | WORD] [&amp;] . [filename]

: [ arg... ]

alias [ name[=value] ... ] bg [job_spec]

bind [-lvd] [-m keymap] [-f filena break [n]

builtin [shell-builtin [arg ...]] case WORD in [PATTERN [| PATTERN].

cd [dir] command [-pVv] [command [arg ...]]

continue [n] declare [-[frxi]] name[=value] ...

dirs [-l] echo [-neE] [arg ...]

enable [-n] [name ...] eval [arg ...]

exec [ [-] file [redirection ...]] exit [n]

export [-n] [-f] [name ...] or exp fc [-e name] [-nlr] [first] [last

fg [job_spec] for NAME [in WORDS ... ;] do COMMA

function NAME { COMMANDS ; } or NA getopts optstring name [arg]

hash [-r] [name ...] help [pattern ...]

history [n] [ [-awrn] [filename]] if COMMANDS; then COMMANDS; [elif

jobs [-lnp] [jobspec ...] | jobs - kill [-s sigspec | -sigspec] [pid

let arg [arg ...] local name[=value] ...

logout popd [+n | -n]

pushd [dir | +n | -n] pwd

read [-r] [name ...] readonly [-n] [-f] [name ...] or r

return [n] select NAME [in WORDS ... ;] do CO

set [&#151;abefhknotuvxldHCP] [-o opti shift [n]

source filename suspend [-f]

test [expr] times

trap [arg] [signal_spec] type [-all] [-type | -path] [name

typeset [-[frxi]] name[=value] ... ulimit [-SHacdmstfpnuv [limit]]

umask [-S] [mode] unalias [-a] [name ...]

unset [-f] [-v] [name ...] until COMMANDS; do COMMANDS; done

variables - Some variable names an wait [n]

while COMMANDS; do COMMANDS; done { COMMANDS }</FONT></PRE>

<P>You will have to pipe the output of help to more (help | more) to keep the first part from scrolling off your screen.

<BR>

<BR>

<A NAME="E68E46"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Wildcards * and ?</B></FONT></CENTER></H3>

<BR>

<P>In many a late-night card game, jokers are shuffled into the deck. The jokers are wildcards that can become any card of your choice. This is obviously very useful! Linux has wildcards also. They are, if anything, more useful than jokers in a card game.

<BR>

<P>Linux has several wildcards. Wildcards are used as a convenient and powerful shortcut when specifying files (or directories) that a command is to operate on. We will briefly look at the two most popular wildcards: * and ?.

<BR>

<P>The most commonly used wildcard is *, which stands in for any combination of one or more characters. For example, c* will match all filenames that begin with c. You can see this for yourself by typing ls /bin/c*.

<BR>

<P>What happens if you type ls /bin/c*t? How about ls /bin/*t?

<BR>

<P>The ? wildcard is more restrictive than *. It only stands in for any one character. You can see this by comparing ls/bin/d* with ls/bin/d?.

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE>Wildcards can only be used to match filenames and directory names. You can't, for example, type pass* at the Linux prompt and expect Linux to run the passwd program for you.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE>Be very careful when using wildcards with dangerous commands, such as the ones used to permanently delete files! A good check is to run ls with the wildcards you plan to use and examine the resulting list of files to see if the wildcard combination 
did what you expected it to do. Also double-check that you typed everything correctly before pressing the Enter key!</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<BR>

<A NAME="E68E47"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Environment Variables</B></FONT></CENTER></H3>

<BR>

<P>When you log in, Linux keeps a number of useful data items in the background ready for the system to use. The actual data is held in something called an environment variable, whose name is often descriptive or mnemonic. In fact, this is no different 
from the way you and I remember things. We know that there always is a piece of information called &quot;day of the week&quot; (the environment variable); however, we change the data in this variable, from Monday to Tuesday to Wednesday, and so on, as days 
go by.

<BR>

<P>To see the list of exported environment variables, type env. The environment variable's name is on the left, and the value held by the variable is on the right.

<BR>

<P>The most important variable to note is the PATH, whose value is your search path. As we will see in the next chapter, when you type a command, Linux will search every place listed in your search path for that command.

<BR>

<P>A longer list of environment variables, consisting of several new variables in addition to the ones you saw earlier, is displayed by the command set. The new variables are local: they have not been marked for export. For more information on exporting 
variables, see <A HREF="rhl10.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl10.htm">Chapter 10</A>. You can think of local variables as items of information you need for only a certain time or location. For instance, remembering the variable &quot;what-floor-am-I-on&quot; becomes an unnecessary piece of 
information once you leave the building!

<BR>

<BR>

<A NAME="E68E48"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Processes and How to Terminate Them</B></FONT></CENTER></H3>

<BR>

<P>In the previous chapter, we learned about the who command, which shows you the usernames of everyone who is logged into the system. The who program actually gets its information from the Linux system, which maintains and updates the list of the system's 
current users.

<BR>

<P>In fact, Linux keeps much more detailed records about what is happening on the system than just who is logged in. Because Linux is a multitasking system, in which many programs or program threads may be running simultaneously, Linux keeps track of 
individual tasks or processes.

<BR>

<P>Although these processes are usually well-behaved and well-managed by Linux, sometimes they might go out of control. This can happen if a program hits a bug or a flaw in its internal code or supplied data, or if you accidentally enter the wrong command 
or command option.

<BR>

<P>Being able to identify these misbehaving processes, and then being able to terminate or kill them, is an essential piece of knowledge for all Linux/UNIX users. (Obviously the world was a less kind and gentle place when the kill command was developed and 
named.) When you are your own system administrator, as in our case, it's doubly important!

<BR>

<BR>

<A NAME="E69E45"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>The Process Status Command ps</B></FONT></CENTER></H4>

<BR>

<P>To find out what processes are running, we use the ps command. ps stands for &quot;process status,&quot; not the &quot;post script&quot; you would write at the end of a letter.

<BR>

<P>Typing ps by itself gives you a concise listing of your own processes:

<BR>

<PRE>

<FONT COLOR="#000080">darkstar:~$ ps

PID TTY STAT TIME COMMAND

41 v01 S&lt; 0:00 -bash

134 v01 R&lt; 0:00 ps</FONT></PRE>

<P>The information in the first column, headed PID, is important. This is the Process ID number, which is unique, and which Linux uses to identify that particular process. You must know a process's PID to be able to kill it.

<BR>

<P>The TTY column shows you which terminal the process was started from.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -