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

📄 rhl07.htm

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

<HEAD>

<TITLE>Red Hat Linux Unleashed rhl07.htm </TITLE>

<LINK REL="ToC" HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm">

<LINK REL="Index" HREF="htindex.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/htindex.htm">

<LINK REL="Next" HREF="rhl08.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl08.htm">

<LINK REL="Previous" HREF="rhl06.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl06.htm"></HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">

<A NAME="I0"></A>

<H2>Red Hat Linux Unleashed rhl07.htm</H2>

<P ALIGN=LEFT>

<A HREF="rhl06.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl06.htm" TARGET="_self"><IMG SRC="purprev.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>

<A HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm" TARGET="_self"><IMG SRC="purtoc.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>

<A HREF="rhl08.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl08.htm" TARGET="_self"><IMG SRC="purnext.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>


<HR ALIGN=CENTER>

<P>

<UL>

<UL>

<UL>

<LI>

<A HREF="#E68E42" >How Linux Commands Work</A>

<UL>

<LI>

<A HREF="#E69E40" >Command Options</A>

<LI>

<A HREF="#E69E41" >Other Parameters</A>

<LI>

<A HREF="#E69E42" >Input and Output Redirection</A></UL>

<LI>

<A HREF="#E68E43" >Notational Conventions Used to Describe Linux Commands</A>

<LI>

<A HREF="#E68E44" >Online Help Available in Linux</A>

<LI>

<A HREF="#E68E45" >The Linux Man Pages</A>

<UL>

<LI>

<A HREF="#E69E43" >Finding Keywords in Man Pages</A>

<LI>

<A HREF="#E69E44" >The bash Shell help Facility</A></UL>

<LI>

<A HREF="#E68E46" >Wildcards * and ?</A>

<LI>

<A HREF="#E68E47" >Environment Variables</A>

<LI>

<A HREF="#E68E48" >Processes and How to Terminate Them</A>

<UL>

<LI>

<A HREF="#E69E45" >The Process Status Command ps</A>

<LI>

<A HREF="#E69E46" >The Process Termination Command kill</A></UL>

<LI>

<A HREF="#E68E49" >Becoming Someone Else The su Command</A>

<LI>

<A HREF="#E68E50" >The grep Command</A>

<LI>

<A HREF="#E68E51" >Summary</A></UL></UL></UL>

<HR ALIGN=CENTER>

<A NAME="E66E7"></A>

<H1 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>7</B></FONT></CENTER></H1>

<BR>

<A NAME="E67E7"></A>

<H2 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>Basic Linux Commands and Utilities</B></FONT></CENTER></H2>

<BR>

<P>In this chapter, we will discover the following:

<BR>

<UL>

<LI>How to modify the basic function of Linux commands by using command options

<BR>

<BR>

<LI>How to run two or more Linux commands in tandem by using input and output re-direction

<BR>

<BR>

<LI>How to use parameters, such as filenames, with Linux commands

<BR>

<BR>

<LI>How to read and understand the notational shorthand used in Linux and UNIX documentation

<BR>

<BR>

<LI>How to use Linux online man pages and help facilities

<BR>

<BR>

<LI>How to use wildcards that fill in for one or more filenames

<BR>

<BR>

<LI>How to check your environment variables

<BR>

<BR>

<LI>How to list processes running on the Linux system

<BR>

<BR>

<LI>How to kill processes

<BR>

<BR>

<LI>How to temporarily become another user

<BR>

<BR>

<LI>How to use grep (and understand what grep means!)

<BR>

<BR>

</UL>

<BR>

<A NAME="E68E42"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>How Linux Commands Work</B></FONT></CENTER></H3>

<BR>

<P>Most Linux commands are very flexible. When you enter a Linux command, there are several ways to tailor the basic command to your specific needs. We will look at the two main ways used to modify the effect of a command:

<BR>

<UL>

<LI>Specifying or redirecting a command's input and output

<BR>

<BR>

<LI>Using command options

<BR>

<BR>

</UL>

<P>A simple way to picture what a Linux command does is to imagine that it's a black box that is part of an assembly line. Items come down a conveyor belt, enter the black box, get processed in some way, come out of the black box, and are taken away on 
another conveyor belt. Command options let you fine-tune the basic process happening inside the black box. Command redirection lets you specify which conveyor belt will supply the black box with items and which conveyor belt will take away the resulting 
products.

<BR>

<P>Once you understand how redirection and command options work, you will be able to (at least in principle) use any Linux or UNIX command. This is because UNIX was based on a few simple design principles. Commands, therefore, should work in consistent 
ways. Of course, UNIX has grown and changed over the years, and the design principles can sometimes get buried under all the changes. But they still make up the foundation, so that UNIX-based systems such as Linux are quite coherent and consistent in how 
they work.

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE>Pressing Ctrl-U at any point, right up to before you press Enter, lets you clear everything you've typed on the command line. You can use this whenever you spot an error at the very beginning of your typing, or when you decide you don't want to run a 
particular command after all. You can also use the Backspace key to &quot;back up&quot; by erasing characters (in fact, it can be almost a reflex action), but it's usually faster to just erase the whole command line and start again.

<BR>Perhaps the most powerful keys to use at the command prompt are the arrow keys. The left and right arrows move the cursor non-destructively. If you make a typo early in the line, you can left-arrow your way to the character and type in a correction. 
Additionally, the up and down arrows enable you to jump through a list of the last several commands used (similar to DOS's DOSKEY utility).</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<BR>

<A NAME="E69E40"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Command Options</B></FONT></CENTER></H4>

<BR>

<P>You can use command options to fine-tune the actions of a Linux command. Quite often, a Linux command will do almost&#151;but not quite&#151;what you want it to do. Instead of making you learn a second command, Linux lets you modify the basic, or 
default, actions of the command by using options.

<BR>

<P>The ls command is an excellent, and useful, example of a command that has a great many options. The ls command lists the files found on the Linux system's hard drive. This sounds simple enough, doesn't it? Try entering the command

<BR>

<PRE>

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

darkstar:~$</FONT></PRE>

<P>Well, nothing much seemed to happen.

<BR>

<P>Now try typing ls -a. Type it exactly as listed. The space between ls and -a is necessary, and there must be no space between the - and the a.

<BR>

<PRE>

<FONT COLOR="#000080">darkstar:~$ ls -a

./ .bash_history .less .term/

../ .kermrc .lessrc</FONT></PRE>

<P>What you have done is modified what ls does by adding a command option&#151;in this case, -a. By default, ls lists only files whose names don't begin with a period. However, -a tells ls to list all files, even ones that begin with a period. (These are 
usually special files created for you by Linux.) At present, all the files in your directory start with a period, so ls by itself does not list any files; you must add -a to see the files you have at present.

<BR>

<P>The ls command has many more options. You can use more than one option at a time. For example, try typing ls -al:

<BR>

<PRE>

<FONT COLOR="#000080">darkstar:~$ ls -al

total 10

drwxr-xr-x 3 fido users 1024 Dec 21 22:11 ./

drwxr-xr-x 6 root root 1024 Dec 14 01:39 ../

-rw-r&#151;r&#151; 1 fido users 333 Dec 21 22:11 .bash_history

-rw-r&#151;r&#151; 1 fido users 163 Dec 7 14:31 .kermrc

-rw-r&#151;r&#151; 1 fido users 34 Jun 6 1993 .less

-rw-r&#151;r&#151; 1 fido users 114 Nov 23 1993 .lessrc

drwxr-xr-x 2 fido users 1024 Dec 7 13:36 .term/</FONT></PRE>

<P>You now get a listing with many more details about the files. (These will be explained in <A HREF="rhl08.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl08.htm">Chapter 8</A>, &quot;The Linux File System.&quot;) The l option can be used by itself; ls -l will give detailed descriptions of files that 
don't begin with a period. Sometimes filenames are so long they don't fit on a single line. Linux simply wraps the remainder to the next line.

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE>Strictly speaking, the dash (-) is not part of the command option. The dash simply tells Linux to understand each letter immediately following it as a command option. There must be a space before the dash, and there must not be a space between the 
dash and the letter or letters making up the command option. There must be a space after the command option if anything else is to be entered on the command line after it.

<BR>You can type more than one command option after the dash, as we did with ls -al. In this case, we are specifying both the a and the l options. The order you specify options in usually doesn't matter; ls -al will give the same results as ls -la. 
Combining options doesn't work with all Linux commands, and then only with those that use a single letter to specify each option.

<BR>Multiple options can also be specified individually, with each option preceded by a dash and separated from other options by spaces&#151;for example, ls -a -l. This is usually done only when a particular option requires a further parameter.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<P>By default, ls lists files in alphabetical order. Sometimes you might be more interested in when a file was created or last modified. The t option tells ls to sort files by date instead of alphabetically by filename, showing the newest files first. 
Therefore, typing ls -alt gives

<BR>

<PRE>

<FONT COLOR="#000080">darkstar:~$ ls -alt

total 10

drwxr-xr-x 3 fido users 1024 Jan 2 13:48 ./

-rw-r&#151;r&#151; 1 fido users 333 Dec 21 22:11 .bash_history

drwxr-xr-x 6 root root 1024 Dec 14 01:39 ../

-rw-r&#151;r&#151; 1 fido users 163 Dec 7 14:31 .kermrc

drwxr-xr-x 2 fido users 1024 Dec 7 13:36 .term/

-rw-r&#151;r&#151; 1 fido users 114 Nov 23 1993 .lessrc

-rw-r&#151;r&#151; 1 fido users 34 Jun 6 1993 .less</FONT></PRE>

<P>The r option tells ls to produce a reverse output. This is often used with the t option. The following is an example of what you might get if you entered ls -altr:

<BR>

<PRE>

<FONT COLOR="#000080">darkstar:~$ ls -altr

total 10

⌨️ 快捷键说明

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