📄 0041-0046.html
字号:
<HTML>
<HEAD>
<TITLE>Sams Teach Yourself Linux in 24 Hours:Reading and Navigation Commands:EarthWeb Inc.-</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!-- ISBN=0672311623 //-->
<!-- TITLE=Sams Teach Yourself Linux in 24 Hours//-->
<!-- AUTHOR=Bill Ball//-->
<!-- PUBLISHER=Macmillan Computer Publishing//-->
<!-- IMPRINT=Sams//-->
<!-- CHAPTER=04 //-->
<!-- PAGES=0041-0062 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="../ch03/0038-0040.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0047-0049.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-41"><P>Page 41</P></A>
<H3><A NAME="ch04_ 1">
Part II</A></H3>
<H2>
Learning Linux Basics
</H2>
<P><b>Hour</b>
</P>
<OL START=4>
<LI> Reading and Navigation Commands
<LI> Manipulation and Searching Commands
<LI> Using the Shell
<LI> Using the X Window System
<LI> Exploring Other X11 Window Managers
</OL>
<A NAME="PAGENUM-42"><P>Page 42</P></A>
<A NAME="PAGENUM-43"><P>Page 43</P></A>
<H3><A NAME="ch04_ 2">
Hour 4
</A></H3>
<H2>
<A NAME="ch04_ 3">
Reading and Navigation<BR>
Commands
</A>
</H2>
<P>This hour introduces you to the basic Linux commands you'll use
for navigating, searching, and reading files and directories of your file system
(the directories of your Linux partition). After working through the material,
you should know how to get help on commands, find out where you are in
Linux, and how to find files on your hard drive. The hour starts with navigating
and searching your directory, and moves on to show you how to read
directories and files. But first, you'll learn how to help yourself with the
man command.
</P>
<H3><A NAME="ch04_ 4">
Getting Help with the man Command
</A></H3>
<P>One of the first things to know about Linux is that help is never far away.
Like most implementations of UNIX, your Linux distribution comes with
manual pages for nearly each utility, command, or programming system call. You
can get information about nearly any command, including
man, by typing
</P>
<!-- CODE SNIP //-->
<PRE>
# man man
</PRE>
<!-- END CODE SNIP //-->
<P>Manual pages started out in UNIX as one-page descriptions, available
on-line, usually under the /usr/man directory. The file for each manual page is
named
</P>
<A NAME="PAGENUM-44"><P>Page 44</P></A>
<P>with a single-digit extension, and placed in a subdirectory under
/usr/man. For example, the manual page for man would be named and found as
</P>
<!-- CODE SNIP //-->
<PRE>
/usr/man/man1/man.1
</PRE>
<!-- END CODE SNIP //-->
<P>If you want to understand the format and placement of manual pages, you won't find
this information in man.1, but in man.7 under
/usr/man/man7. If you look at Table 4.1, you'll see
the locations and contents of each manual section.
</P>
<P>Table 4.1. The Linux manual sections.
</P>
<TABLE>
<TR><TD>
Directory
</TD><TD>
Contents
</TD></TR><TR><TD>
/usr/man/man1
</TD><TD>
Commands: commands you run from within a shell
</TD></TR><TR><TD>
/usr/man/man2
</TD><TD>
System calls: documentation for kernel functions
</TD></TR><TR><TD>
/usr/man/man3
</TD><TD>
Library calls: manual pages for
libc functions
</TD></TR><TR><TD>
/usr/man/man4
</TD><TD>
Special files: information about files in the
/dev directory
</TD></TR><TR><TD>
/usr/man/man5
</TD><TD>
File formats: details of formats for
/etc/passwd and other files
</TD></TR><TR><TD>
/usr/man/man6
</TD><TD>
Games
</TD></TR><TR><TD>
/usr/man/man7
</TD><TD>
Macro packages: descriptions of the Linux file system,
man pages, and others
</TD></TR><TR><TD>
/usr/man/man8
</TD><TD>
System management: manual pages for root operator utilities
</TD></TR><TR><TD>
/usr/man/man9
</TD><TD>
Kernel routines: documentation on Linux kernel
source routines
</TD></TR></TABLE>
<P>Each manual page traditionally has a number of sections, with the documentation for
the command broken down into sections. Look at Table 4.2 for the organization of a
manual page.
</P>
<P>Table 4.2. Organization of a manual page.
</P>
<TABLE>
<TR><TD>
Section
</TD><TD>
Description
</TD></TR><TR><TD>
NAME
</TD><TD>
The name of the command and a brief description
</TD></TR><TR><TD>
SYNOPSIS
</TD><TD>
How to use the command and command-line options
</TD></TR><TR><TD>
DESCRIPTION
</TD><TD>
An explanation of the program and its options
</TD></TR><TR><TD>
FILES
</TD><TD>
A list of files used by command, and their location
</TD></TR><TR><TD>
SEE ALSO
</TD><TD>
A list of related man pages
</TD></TR><TR><TD>
DIAGNOSTICS
</TD><TD>
A description of unusual output
</TD></TR><TR><TD>
BUGS
</TD><TD>
Known problems
</TD></TR><TR><TD>
AUTHOR
</TD><TD>
The program's main author and other contributors
</TD></TR></TABLE>
<A NAME="PAGENUM-45"><P>Page 45</P></A>
<P>Online manual pages contain special typesetting codes for the
nroff text formatting program (see Hour 15, "Preparing Documents"), using special macros (as documented in
man.7). This format is critically important for other programs, such as
makewhatis, whatis, and apropos, which you'll learn about later in this chapter.
</P>
<P>You can also find more detailed documentation for Linux commands and other
subjects under the /usr/doc directory, which contains files called Frequently Asked Questions,
or FAQs, and HOWTOs, or How-To documents. Additionally, the Free Software
Foundation, which releases the GNU software packages (many of the commands discussed in
this book are GNU programs), puts much of its documentation in a special hypertext
"info" format.
</P>
<TABLE BGCOLOR=#FFFF99><TR><TD>JUST A MINUTE</TD></TR><TR><TD>
<BLOCKQUOTE>
Much of the software for Linux comes from the Free Software Foundation,
or FSF, founded by Richard Stallman, author of the
emacs editor (see Hour 14, "Text Processing"). The FSF distributes its software under the GNU
General Public License, or GPL. Part of the success and popularity of Linux and
GNU software is because of the terms of the GPL. If you want more
information about the GNU software programs for Linux, the FSF, or the GNU GPL,
you can try the info command, which is a reader for the GNU hypertext
documentation, found under the /usr/info directory.
</BLOCKQUOTE></TD></TR></TABLE>
<P>The man command normally searches for manual pages according to instructions
detailed in the man.config file under the /etc directory. These instructions define the default
directories in which to look for manual pages, and they match the directories to
the $MANPATH environment variable, an abbreviated string of characters defined when you first start
Linux and log in. Environment variables are discussed in Hour 6, "Using the Shell." The
default places to look for these pages are
</P>
<!-- CODE SNIP //-->
<PRE>
MANPATH /usr/man
MANPATH /usr/local/man
MANPATH /usr/X11R6/man
MANPATH /usr/lib/perl5/man
</PRE>
<!-- END CODE SNIP //-->
<TABLE BGCOLOR=#FFFF99><TR><TD>Just a Minute</TD></TR><TR><TD>
<BLOCKQUOTE>
A graphic version of the man command, called xman, is available for the
X Window System. You can use xman not only to read manual pages, but to
see directories of manual page entries. The xman program is handy and many
users keep its small menu window active on their desktops.
</BLOCKQUOTE></TD></TR></TABLE>
<A NAME="PAGENUM-46"><P>Page 46</P></A>
<H3><A NAME="ch04_ 5">
Navigating and Searching the File System
</A></H3>
<P>This section introduces you to the basic navigation commands, and shows you how to
move around your Linux file system, find files, and build file information databases, such as
those for use with the whatis command. You'll also learn about alternative approaches
and programs, and how to speed up searches to find files quickly.
</P>
<H4><A NAME="ch04_ 6">
Moving to Different Directories with the cd Command
</A></H4>
<P>The cd (change directory) command is the basic navigation tool for moving your
current location to different parts of the Linux file system. You can move directly to a
directory by typing the command, followed by a pathname or directory. For example, the
following command will move you to the /usr/bin directory:
</P>
<!-- CODE SNIP //-->
<PRE>
# cd /usr/bin
</PRE>
<!-- END CODE SNIP //-->
<P>When you're in that directory, you can move up to the
/usr directory with the following command:
</P>
<!-- CODE SNIP //-->
<PRE>
# cd ..
</PRE>
<!-- END CODE SNIP //-->
<P>You could also move to the root directory, or /, while in the
/usr/bin directory by using the following command:
</P>
<!-- CODE SNIP //-->
<PRE>
# cd ../..
</PRE>
<!-- END CODE SNIP //-->
<P>Finally, you can always go back to your home directory (where your files are) by using
either of the following commands:
</P>
<!-- CODE SNIP //-->
<PRE>
# cd
</PRE>
<!-- END CODE SNIP //-->
<P>or
</P>
<!-- CODE SNIP //-->
<PRE>
# cd ~
</PRE>
<!-- END CODE SNIP //-->
<P>Note that if you try to use the man command to read the
cd man page, you won't find one. Why? Because cd is built into the shell. See
bash in Hour 6, for more details.
</P>
<H4><A NAME="ch04_ 7">
Knowing Where You Are with the pwd Command
</A></H4>
<P>The pwd (print working directory) command tells you where you are, and prints the
working (current) directory. For example, if you execute
</P>
<!-- CODE SNIP //-->
<PRE>
# cd /usr/bin
</PRE>
<!-- END CODE SNIP //-->
<P>and then type
</P>
<!-- CODE SNIP //-->
<PRE>
# pwd
</PRE>
<!-- END CODE SNIP //-->
<P><CENTER>
<a href="../ch03/0038-0040.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0047-0049.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -