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

📄 0050-0052.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 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="0047-0049.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0053-0055.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-50"><P>Page 50</P></A>







<P>do. But what if you want to do something and can't remember which program does

what? In this case, you can turn to the apropos command.

</P>



<P>For example, if you can't remember which command searches for files, you can enter

</P>



<!-- CODE //-->

<PRE>

# apropos search

apropos (1)          - search the whatis database for strings

badblocks (8)        - search a device for bad blocks

bsearch (3)          - binary search of a sorted array.

conflict (8)         - search for alias/password conflicts

find (1)             - search for files in a directory hierarchy

hcreate, hdestroy, hsearch (3) - hash table management

lfind, lsearch (3)   - linear search of an array.

lkbib (1)            - search bibliographic databases

lookbib (1)          - search bibliographic databases

lsearch (n)          - See if a list contains a particular element

manpath (1)          - determine user's search path for man pages

strpbrk (3)          - search a string for any of a set of characters

strspn, strcspn (3)  - search a string for a set of characters

tsearch, tfind, tdelete, twalk (3) - manage a binary tree

whatis (1)           - search the whatis database for complete words.

zgrep (1)            - search possibly compressed files for a regular expression

zipgrep (1)          - search possibly zip files for a regular expression

</PRE>

<!-- END CODE //-->



<P>You'll see a list of programs from the whatis database on your screen.

The apropos command uses this database to search for the keyword you entered. If you keep your manual

pages and whatis database up-to-date, you'll be able to use

apropos to help you find the program you need.

</P>



<TABLE BGCOLOR=#FFFF99><TR><TD>JUST A MINUTE</TD></TR><TR><TD>

<BLOCKQUOTE>

You can also use the man command's -K option to do the same thing as

apropos, but the search will be slow, and you'll be presented each manual page in

the search result. For example, to search for any programs dealing with

PostScript, you can try

<!-- CODE SNIP //-->

<PRE>

# man -K PostScript

</PRE>

<!-- END CODE SNIP //-->

This can result in the following output (before you quit with q):<BR>



<!-- CODE //-->

<PRE>

/usr/dt/man/man5/DtStdAppFontNames.5? [ynq] n

/usr/dt/man/man4/dtdtsfile.4? [ynq] n

/usr/man/man7/unicode.7? [ynq] n

/usr/man/man7/suffixes.7? [ynq] n

/usr/man/man7/groff_char.7? [ynq] n

/usr/man/man1/convert.1x? [ynq] n

/usr/man/man1/xv.1? [ynq] n

/usr/man/man1/xdvi.1? [ynq] n

/usr/man/man1/dvips.1? [ynq] n

/usr/man/man1/afm2tfm.1? [ynq] n

/usr/man/man1/ps2pk.1? [ynq] n

/usr/man/man1/ps2frag.1? [ynq] q

</PRE>

<!-- END CODE //-->

</BLOCKQUOTE>

</TD></TR></TABLE>



<A NAME="PAGENUM-51"><P>Page 51</P></A>





<H3><A NAME="ch04_ 12">

Reading Directories and Files

</A></H3>



<P>Now that you know about directory navigation, searching for files, or how to find

more information about programs, I'll introduce you to other basic Linux commands you

can use. This section shows you how to list the contents of directories, make a catalog of

your hard drive, and read the contents of files. You'll learn the basic forms of these

commands to help get you started.

</P>



<H4><A NAME="ch04_ 13">

Listing Directories with the ls Command

</A></H4>



<P>The ls (list directory) command will quickly become one of your most often used

programs. In its simplest form, ls lists nearly all of the files in the current directory. But this

command, which has such a short name, probably has more command-line options (more than 75

at last count) than any other program!

</P>



<P>In the simple form, ls lists your files:

</P>



<!-- CODE SNIP //-->

<PRE>

# ls

News          axhome        nsmail        search

author.msg    documents     reading       vultures.msg

auto          mail          research

</PRE>

<!-- END CODE SNIP //-->



<P>You can also list the files as a single line, with comma separations, with the

-m option:

</P>



<!-- CODE SNIP //-->

<PRE>

# ls -m

News, author.msg, auto, axhome, documents, mail, nsmail, reading,

&Acirc; research, search, vultures.msg

</PRE>

<!-- END CODE SNIP //-->



<P>If you don't like this type of listing, you can have your files sorted horizontally, instead

of vertically (the default), with the -x option:

</P>



<!-- CODE SNIP //-->

<PRE>

# ls -x

News          axhome        nsmail        search

author.msg    documents     reading       vultures.msg

auto          mail          research

</PRE>

<!-- END CODE SNIP //-->





<P>But are all these just files, or are there several directories? One way to find out is to

use the -F option:

</P>



<!-- CODE SNIP //-->

<PRE>

# ls -F

News/         axhome/       nsmail/       search*

author.msg    documents/    reading/      vultures.msg

auto/         mail/         research/

</PRE>

<!-- END CODE SNIP //-->



<P>As you can see, the -F option causes the ls command to show the directories, each with

a / character appended to the filename. The asterisk

(*) shows that the file search is an executable program. But are these all the files in this directory? If you want to see

everything, you can use the -a option with -F, as follows:

</P>



<!-- CODE SNIP //-->

<PRE>

# ls -aF

./                 .dt/               .neditdb           auto/

../                .dtprofile*        .netscape/         axhome/

</PRE>

<!-- END CODE SNIP //-->





<A NAME="PAGENUM-52"><P>Page 52</P></A>







<!-- CODE //-->

<PRE>

.Xauthority        .festival_history  .newsrc            documents/

.Xdefaults         .forward           .oldnewsrc         mail/

.addressbook       .fvwm2rc95*        .pinerc            nsmail/

.addressbook.lu    .index/            .procmail/         reading/

.bash_history      .mailcap           .procmailrc        research/

.bash_logout       .mailrc            .tin/              search*

.bash_profile      .mime.types        .xinitrc*          vultures.msg

.bashrc            .ncftp/            News/

.desksetdefaults   .nedit             author.msg

</PRE>

<!-- END CODE //-->



<P>Using the -F option is one way to see the files and directories in your listings, but if

you have a color monitor, or use X11 in color, you can tell

ls to show files, directories, or executable files in different colors. To do this, use the

--color option. In X11, using the rxvt terminal, directories will be blue, programs will be green, and regular files will be

black. You can also customize which colors are used for different types of files.

</P>



<P>Look in the /etc/ directory for the file named

DIR_COLORS. Copy this file, renaming it to

.dir_colors, and save it in your home directory. You can then edit this file to customize or

add file types recognized for colorizing. See the

DIR_COLORS file for details.

</P>



<P><B>

Long Directory Listing

</B></P>



<P>Would you like even more information about your files? You can view the long

format listing by using the ls -l option, for example:

</P>



<!-- CODE //-->

<PRE>

# ls -l

drwxr-xr-x   2 bball    bball        1024 Nov 12 08:20 News

-rw-rw-r--   1 bball    bball        4766 Nov 12 07:41 author.msg

drwxrwxr-x   2 bball    bball        1024 Nov  5 10:04 auto

drwxrwxr-x   3 bball    bball        1024 Nov 12 13:54 axhome

drwxrwxr-x   2 bball    bball        1024 Nov 12 14:33 documents

drwx------   2 bball    bball        1024 Nov 12 14:02 mail

drwx------   2 bball    bball        1024 Sep 15 01:57 nsmail

drwxrwxr-x   2 bball    bball        1024 Oct 29 20:28 reading

drwxrwxr-x   5 bball    bball        1024 Nov  5 10:03 research

-rwxrwxr-x   1 bball    bball         200 Oct 24 13:24 search

-rw-rw-r--   1 bball    bball         801 Nov 11 22:46 vultures.msg

</PRE>

<!-- END CODE //-->



<P>As you can see, there are eight different columns. The first column is the file's

permissions flags, which are covered in Hour 21, &quot;Handling Files.&quot; These flags generally show the

file's type, and who can read, write (or modify or delete), or run the file. The next column

shows the number of links, which are discussed in Hour 5, &quot;Manipulation and

Searching Commands.&quot; Next is the owner name, followed by group name. Owners and groups

are discussed in Hour 21. The file size is listed next, followed by a timestamp of the file

or directory was created or last modified. The last column, obviously, is each file's name.

</P>





<P><CENTER>

<a href="0047-0049.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0053-0055.html">Next</A>

</CENTER></P>











</td>
</tr>
</table>

<!-- begin footer information -->









</body></html>

⌨️ 快捷键说明

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