old-www/LDP/GNU-Linux-Tools-Summary/html/c2690.htm

1453 lines
21 KiB
HTML

<HTML
><HEAD
><TITLE
>Working with the file-system</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="GNU/Linux Command-Line Tools Summary"
HREF="book1.htm"><LINK
REL="PREVIOUS"
TITLE="Performing more than one command"
HREF="x2622.htm"><LINK
REL="NEXT"
TITLE="Working with files and folders"
HREF="x3289.htm"></HEAD
><BODY
CLASS="CHAPTER"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>GNU/Linux Command-Line Tools Summary</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x2622.htm"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x3289.htm"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="WORKING-WITH-THE-FILE-SYSTEM"
></A
>Chapter 7. Working with the file-system</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="c2690.htm#USING-FILESYSTEM"
>Moving around the filesystem</A
></DT
><DT
><A
HREF="x3289.htm"
>Working with files and folders</A
></DT
><DT
><A
HREF="x4055.htm"
>Mass Rename/copy/link Tools</A
></DT
></DL
></DIV
><P
>The working with the file-system <A
NAME="AEN2693"
></A
>chapter explains a number <A
NAME="AEN2695"
></A
>of commands that you use to move around the file system <A
NAME="AEN2697"
></A
>hierarchy <A
NAME="AEN2699"
></A
>and manipulate <A
NAME="AEN2701"
></A
>the files. Also explained are finding <A
NAME="AEN2703"
></A
>files and how to mass-rename <A
NAME="AEN2705"
></A
>files.</P
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="USING-FILESYSTEM"
></A
>Moving around the filesystem</H1
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>cd</DT
><DD
><P
><A
NAME="AEN2714"
></A
>Change directory. Use <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>&ldquo; cd ..&rdquo;</I
></SPAN
> to go up one directory. </P
><P
>One dot <A
NAME="AEN2718"
></A
>'.' represents <A
NAME="AEN2720"
></A
>the current directory <A
NAME="AEN2722"
></A
>while two dots <A
NAME="AEN2724"
></A
>'..' represent<A
NAME="AEN2726"
></A
> the parent directory.<A
NAME="AEN2728"
></A
> </P
><P
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>&ldquo; cd -&rdquo;</I
></SPAN
> will return <A
NAME="AEN2732"
></A
>you to the previous <A
NAME="AEN2734"
></A
>directory (a bit like an &ldquo;undo&rdquo;). </P
><P
>You can also use <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>cd absolute&nbsp;path</I
></SPAN
> or <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>cd relative&nbsp;path</I
></SPAN
> (see below):</P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Absolute&nbsp;paths</DT
><DD
><P
><A
NAME="AEN2744"
></A
>An &ldquo; absolute path&rdquo; is easily recognised <A
NAME="AEN2746"
></A
>from the leading<A
NAME="AEN2748"
></A
> forward slash, /. The /<A
NAME="AEN2750"
></A
> means that you start <A
NAME="AEN2752"
></A
>at the top level directory and continue down.</P
></DD
></DL
></DIV
><P
>For example to get to /boot/grub<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> </I
></SPAN
>you would type:</P
><PRE
CLASS="SCREEN"
>cd /boot/grub</PRE
><P
>This is an absolute path because you start at the top of the hierarchy and go downwards <A
NAME="AEN2758"
></A
>from there (it doesn't matter where in the filesystem <A
NAME="AEN2760"
></A
>you were when you typed the command).</P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Relative&nbsp;paths</DT
><DD
><P
><A
NAME="AEN2767"
></A
>A &ldquo; relative path&rdquo; doesn't have a preceding <A
NAME="AEN2769"
></A
>slash. Use a relative path when you start from a directory below the top <A
NAME="AEN2771"
></A
>level directory structure. This is dependent <A
NAME="AEN2773"
></A
>on where you are in the filesystem.<A
NAME="AEN2775"
></A
></P
><P
>For example<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> </I
></SPAN
>if you are in root's home <A
NAME="AEN2779"
></A
>directory and want to get to /root/music, you type:</P
><PRE
CLASS="SCREEN"
>cd music</PRE
></DD
></DL
></DIV
><P
>Please note that there is no / using the above<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> cd <A
NAME="AEN2784"
></A
></I
></SPAN
>command. Using a / would cause <A
NAME="AEN2786"
></A
>this to be an absolute <A
NAME="AEN2788"
></A
>path,<A
NAME="AEN2790"
></A
> working from the top<A
NAME="AEN2792"
></A
> of the hierarchy downward.</P
></DD
><DT
>ls</DT
><DD
><P
><A
NAME="AEN2798"
></A
>List files and directories.<A
NAME="AEN2800"
></A
> Typing &ldquo;ls&rdquo; will list <A
NAME="AEN2802"
></A
>files and directories, but will not list hidden <A
NAME="AEN2804"
></A
>files or directories<A
NAME="AEN2806"
></A
> that start with a leading full stop <A
NAME="AEN2808"
></A
> &ldquo;.&rdquo;<A
NAME="AEN2810"
></A
>.</P
><P
>Example options:</P
><P
></P
><UL
><LI
><P
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>ls -l</I
></SPAN
> --- long <A
NAME="AEN2817"
></A
><A
NAME="AEN2819"
></A
>style,<A
NAME="AEN2821"
></A
> this lists <A
NAME="AEN2823"
></A
>permissions, file size,<A
NAME="AEN2825"
></A
> modification <A
NAME="AEN2827"
></A
>date,<A
NAME="AEN2829"
></A
> ownership.<A
NAME="AEN2831"
></A
></P
></LI
><LI
><P
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>ls -a</I
></SPAN
> --- <A
NAME="AEN2836"
></A
>this means &quot;show all&quot;, this shows <A
NAME="AEN2838"
></A
>hidden <A
NAME="AEN2840"
></A
>files, by default <A
NAME="AEN2842"
></A
>any file or directory <A
NAME="AEN2844"
></A
>starting <A
NAME="AEN2846"
></A
>with a '.' will not be shown.<A
NAME="AEN2848"
></A
></P
></LI
><LI
><P
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>ls -d</I
></SPAN
> --- <A
NAME="AEN2853"
></A
>list directory entires rather than contents <A
NAME="AEN2855"
></A
>(see example below)</P
></LI
><LI
><P
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>ls -F</I
></SPAN
> --- <A
NAME="AEN2860"
></A
>append <A
NAME="AEN2862"
></A
>symbols <A
NAME="AEN2864"
></A
>to particular files, such as * (asterisk) for executable<A
NAME="AEN2866"
></A
> files. </P
></LI
><LI
><P
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>ls -S </I
></SPAN
>--- <A
NAME="AEN2871"
></A
>sort <A
NAME="AEN2873"
></A
>the output of the command in decending <A
NAME="AEN2875"
></A
>order <A
NAME="AEN2877"
></A
>sorted <A
NAME="AEN2879"
></A
>by size.</P
></LI
><LI
><P
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>ls -R</I
></SPAN
> --- <A
NAME="AEN2884"
></A
>(recursive) to list everything <A
NAME="AEN2886"
></A
>in the directories <A
NAME="AEN2888"
></A
>below as well as the current directory.</P
></LI
></UL
><P
>Command syntax, either:</P
><PRE
CLASS="SCREEN"
>ls -options</PRE
><P
>This simply lists everything in the current directory, the options <A
NAME="AEN2893"
></A
>are not required <A
NAME="AEN2895"
></A
>(options such as <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-l</I
></SPAN
>, <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-a</I
></SPAN
> et cetera).</P
><PRE
CLASS="SCREEN"
>ls -options string</PRE
><P
>This lists files using a certain string. The string <A
NAME="AEN2901"
></A
>can contain standard wildcards <A
NAME="AEN2903"
></A
>to list multiple files, to learn<A
NAME="AEN2905"
></A
> more about standard wildcards please read <A
HREF="x11655.htm#STANDARD-WILDCARDS"
>the Section called <I
>Standard Wildcards (globbing patterns)</I
> in Chapter 20</A
></P
><P
>You can use<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> ls -d</I
></SPAN
> to show <A
NAME="AEN2910"
></A
>directories that match <A
NAME="AEN2912"
></A
>an exact <A
NAME="AEN2914"
></A
>string, or use standard wildcards. Type &ldquo; ls -d */&rdquo; to list all subdirectories <A
NAME="AEN2916"
></A
>of the current directory. Depending <A
NAME="AEN2918"
></A
>on the setup <A
NAME="AEN2920"
></A
>of your aliases (see <A
HREF="c1195.htm"
>Chapter 4</A
>) you may simply be able to type<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> lsd <A
NAME="AEN2924"
></A
></I
></SPAN
>as the equivalent <A
NAME="AEN2926"
></A
>to<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> ls -d */</I
></SPAN
>.</P
><P
>Examples <A
NAME="AEN2930"
></A
>for<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> ls -d</I
></SPAN
>:</P
><PRE
CLASS="SCREEN"
>ls -d<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> </I
></SPAN
>*/</PRE
><P
>Lists all subdirectories <A
NAME="AEN2936"
></A
>of current directory.</P
><PRE
CLASS="SCREEN"
>ls -d string*</PRE
><P
>Lists directories that start with &quot;string&quot;.</P
><PRE
CLASS="SCREEN"
>ls -d /usr/*/*/doc</PRE
><P
>Lists all directories <A
NAME="AEN2942"
></A
>that are two levels <A
NAME="AEN2944"
></A
>below the /usr/ directory and have a directory called &ldquo;doc&rdquo;, this trick <A
NAME="AEN2946"
></A
>can come in quite handy sometimes.</P
><DIV
CLASS="TIP"
><BLOCKQUOTE
CLASS="TIP"
><P
><B
>You can also use: </B
>Depending on how your aliases (see <A
HREF="c1195.htm"
>Chapter 4</A
>) are setup you can also use <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>l</I
></SPAN
>, <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>la</I
></SPAN
> (list all) and <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>ll</I
></SPAN
> (list long) to perform the above commands</P
></BLOCKQUOTE
></DIV
></DD
><DT
>pwd</DT
><DD
><P
><A
NAME="AEN2959"
></A
>Print working directory<A
NAME="AEN2961"
></A
>. Print <A
NAME="AEN2963"
></A
>the absolute <A
NAME="AEN2965"
></A
>(complete) path <A
NAME="AEN2967"
></A
>to the directory the user is currently in. </P
><P
>Command syntax:</P
><PRE
CLASS="SCREEN"
>pwd</PRE
><P
>This will tell you the full path <A
NAME="AEN2972"
></A
>to the directory you are in, for example it may output <A
NAME="AEN2974"
></A
>&ldquo;/usr/local/bin&rdquo; if you are currently in that directory.</P
></DD
><DT
>tree</DT
><DD
><P
><A
NAME="AEN2980"
></A
>Outputs <A
NAME="AEN2982"
></A
>an <SPAN
CLASS="ACRONYM"
>ASCII</SPAN
> <A
NAME="AEN2985"
></A
>text tree/graph <A
NAME="AEN2987"
></A
>starting at a given directory (by default <A
NAME="AEN2989"
></A
>the current <A
NAME="AEN2991"
></A
>directory). This command recursively lists <A
NAME="AEN2993"
></A
>all files and all directories.<A
NAME="AEN2995"
></A
></P
><P
>In other words, it will list files within the directories <A
NAME="AEN2998"
></A
>below the current one, as well as all files in the current directory.</P
><P
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>tree</I
></SPAN
> has a large number of options, refer <A
NAME="AEN3002"
></A
>to the manual <A
NAME="AEN3004"
></A
>page <A
NAME="AEN3006"
></A
>for details.<A
NAME="AEN3008"
></A
></P
><P
>Command syntax:</P
><PRE
CLASS="SCREEN"
>tree</PRE
><P
>or</P
><PRE
CLASS="SCREEN"
>tree -option(s) /optional/directory/to/list</PRE
></DD
></DL
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="FINDING-FILES"
></A
>Finding files</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>find</DT
><DD
><P
><A
NAME="AEN3021"
></A
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>find</I
></SPAN
> is a tool which looks <A
NAME="AEN3024"
></A
>for files on a filesystem.<A
NAME="AEN3026"
></A
> <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>find</I
></SPAN
> has a large number <A
NAME="AEN3029"
></A
>of options which can be used to customise <A
NAME="AEN3031"
></A
>the search<A
NAME="AEN3033"
></A
> (refer to the manual/info pages).</P
><P
>Note that find works with standard wildcards,<A
NAME="AEN3036"
></A
><A
HREF="x11655.htm#STANDARD-WILDCARDS"
>the Section called <I
>Standard Wildcards (globbing patterns)</I
> in Chapter 20</A
>, and can work with regular expressions<A
NAME="AEN3039"
></A
>, <A
HREF="x11655.htm#REGULAR-EXPRESSIONS"
>the Section called <I
>Regular Expressions</I
> in Chapter 20</A
>.</P
><P
>Basic <A
NAME="AEN3043"
></A
>example:</P
><PRE
CLASS="SCREEN"
>find / -name file</PRE
><P
>This would look <A
NAME="AEN3047"
></A
>for a file named <A
NAME="AEN3049"
></A
>&ldquo;file&rdquo; and start at the root directory <A
NAME="AEN3051"
></A
>(it will search all directories <A
NAME="AEN3053"
></A
>including<A
NAME="AEN3055"
></A
> those that are mounted <A
NAME="AEN3057"
></A
>filesystems).</P
><P
>The <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>`-name'<A
NAME="AEN3061"
></A
></I
></SPAN
> option <A
NAME="AEN3063"
></A
>is case sensitive <A
NAME="AEN3065"
></A
>you can use the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>`-iname'</I
></SPAN
> option to find something regardless <A
NAME="AEN3068"
></A
>of case.</P
><P
>Use the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>'-regex'<A
NAME="AEN3072"
></A
></I
></SPAN
> and <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>'-iregex'<A
NAME="AEN3075"
></A
></I
></SPAN
> to find something according to a regular expression (either case sensitive<A
NAME="AEN3077"
></A
> or case insensitive <A
NAME="AEN3079"
></A
>respectively).</P
><P
>The <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>'-exec'<A
NAME="AEN3083"
></A
></I
></SPAN
> option is one of the more advanced <A
NAME="AEN3085"
></A
>find <A
NAME="AEN3087"
></A
>operations.<A
NAME="AEN3089"
></A
> It executes a command on the files it finds <A
NAME="AEN3091"
></A
>(such as moving <A
NAME="AEN3093"
></A
>or removing<A
NAME="AEN3095"
></A
> it or anything else...).</P
><P
>To use the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-exec</I
></SPAN
> option: use find to find something, then add <A
NAME="AEN3099"
></A
>the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-exec</I
></SPAN
> option to the end,<A
NAME="AEN3102"
></A
> then:</P
><PRE
CLASS="SCREEN"
>command_to_be_executed <A
NAME="COMMAND"
><IMG
SRC="../images/callouts/1.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(1)"></A
> then '{}'<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> </I
></SPAN
>(curly brackets) <A
NAME="BRACKETS"
><IMG
SRC="../images/callouts/2.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(2)"></A
> then the arguments (for example a new directory) and finally a ';' <A
NAME="END"
><IMG
SRC="../images/callouts/3.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(3)"></A
>. </PRE
><P
>See below for an example of use this command.</P
><DIV
CLASS="CALLOUTLIST"
><DL
COMPACT="COMPACT"
><DT
><A
HREF="c2690.htm#COMMAND"
><IMG
SRC="../images/callouts/1.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(1)"></A
></DT
><DD
> This is the tool you want to execute on the files find locates. For example if you wanted to remove everything it finds then you would use <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-exec rm -f</I
></SPAN
>
</DD
><DT
><A
HREF="c2690.htm#BRACKETS"
><IMG
SRC="../images/callouts/2.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(2)"></A
></DT
><DD
> The curly brackets are used in find to represent the current file which has been found. ie. If it found the file shopping.doc then {} would be substituted with shopping.doc. It would then continue to substitute {} for each file it finds. The brackets are normally protected by backslashes (\) or single-quotation marks ('), to stop bash expanding them (trying to interpret them as a special command eg. a wildcard).
</DD
><DT
><A
HREF="c2690.htm#END"
><IMG
SRC="../images/callouts/3.gif"
HSPACE="0"
VSPACE="0"
BORDER="0"
ALT="(3)"></A
></DT
><DD
> This is the symbol used by find to signal the end of the commands. It's usually protected by a backslash (\) or quotes to stop bash from trying to expand it.
</DD
></DL
></DIV
><PRE
CLASS="SCREEN"
>find / -name '*.doc' -exec cp '{}' /tmp/ ';'</PRE
><P
>The above command would find <A
NAME="AEN3120"
></A
>any files with the extension <A
NAME="AEN3122"
></A
>'.doc' and copy<A
NAME="AEN3124"
></A
> them to your /tmp directory, obviously this command is quite useless, it's just an example of what find can do. Note that the quotation <A
NAME="AEN3126"
></A
>marks are there to stop <A
NAME="AEN3128"
></A
>bash <A
NAME="AEN3130"
></A
>from trying to interpret<A
NAME="AEN3132"
></A
> the other characters <A
NAME="AEN3134"
></A
>as something.</P
><P
>Excluding <A
NAME="AEN3137"
></A
>particular folders <A
NAME="AEN3139"
></A
>with <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>find</I
></SPAN
> can be quite <A
NAME="AEN3142"
></A
>confusing, but it may be necessary if you want to search your main disk <A
NAME="AEN3144"
></A
>(without searching <A
NAME="AEN3146"
></A
>every mounted <A
NAME="AEN3148"
></A
>filesystem). Use the<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> -path <A
NAME="AEN3151"
></A
></I
></SPAN
> option to exclude <A
NAME="AEN3153"
></A
>the particular folder (note, you cannot have a '/' (forward slash) on the end) and the<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> -prune <A
NAME="AEN3156"
></A
></I
></SPAN
> option to exclude <A
NAME="AEN3158"
></A
>the subdirectories.<A
NAME="AEN3160"
></A
> An example is below:</P
><PRE
CLASS="SCREEN"
>find / -path '/mnt/win_c' -prune -o -name "string" -print</PRE
><P
><A
NAME="AEN3164"
></A
><A
NAME="AEN3166"
></A
><A
NAME="AEN3168"
></A
><A
NAME="AEN3170"
></A
>This example will search your entire directory tree (everything that is mounted <A
NAME="AEN3172"
></A
>under it) excluding <A
NAME="AEN3174"
></A
>/mnt/win_c and all of the subdirectories <A
NAME="AEN3176"
></A
>under /mnt/win_c. When using the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-path</I
></SPAN
> option you can use wildcards.<A
NAME="AEN3179"
></A
></P
><P
>Note that you could add <A
NAME="AEN3182"
></A
>more<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> -path <A
NAME="AEN3185"
></A
>'/directory'</I
></SPAN
> statements <A
NAME="AEN3187"
></A
>on if you wanted.</P
><P
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>find</I
></SPAN
> has many, many different <A
NAME="AEN3191"
></A
>options, refer <A
NAME="AEN3193"
></A
>to the manual (and info) page<A
NAME="AEN3195"
></A
> for more <A
NAME="AEN3197"
></A
>details.</P
></DD
><DT
>slocate</DT
><DD
><P
><A
NAME="AEN3203"
></A
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>slocate</I
></SPAN
> outputs <A
NAME="AEN3206"
></A
>a list <A
NAME="AEN3208"
></A
>of all files on the system that match <A
NAME="AEN3210"
></A
>the pattern,<A
NAME="AEN3212"
></A
> giving their full path <A
NAME="AEN3214"
></A
>name (it doesn't have to be an exact <A
NAME="AEN3216"
></A
>match, anything which contains the word is shown).</P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Replaces <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>locate</I
></SPAN
>: </B
>Secure locate is a replacement for <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>locate</I
></SPAN
>, both have identical syntax. On most distributions locate is an alias to <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>slocate</I
></SPAN
>.</P
></BLOCKQUOTE
></DIV
><P
>Commmand <A
NAME="AEN3225"
></A
>syntax:<A
NAME="AEN3227"
></A
></P
><PRE
CLASS="SCREEN"
>slocate string</PRE
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>This won't work unless: </B
>You need to run either <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>updatedb</I
></SPAN
> (as root) or <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>slocate -u<A
NAME="AEN3235"
></A
> </I
></SPAN
>(as root) for slocate to work.</P
></BLOCKQUOTE
></DIV
></DD
><DT
>whereis<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
></I
></SPAN
></DT
><DD
><P
>whereis<A
NAME="AEN3242"
></A
> locates <A
NAME="AEN3244"
></A
>the binary,<A
NAME="AEN3246"
></A
> source,<A
NAME="AEN3248"
></A
> and manual page for a particular program, it uses exact <A
NAME="AEN3250"
></A
>matches only, if you only know part <A
NAME="AEN3252"
></A
>of the name use <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>slocate</I
></SPAN
><A
NAME="AEN3255"
></A
>.</P
><P
>Command syntax:</P
><PRE
CLASS="SCREEN"
>whereis program_name</PRE
></DD
><DT
>which</DT
><DD
><P
><A
NAME="AEN3263"
></A
>Virtually the same as whereis,<A
NAME="AEN3265"
></A
> except it only finds <A
NAME="AEN3267"
></A
>the executable<A
NAME="AEN3269"
></A
> (the physical <A
NAME="AEN3271"
></A
>program). It only looks in the PATH <A
NAME="AEN3273"
></A
>(environment variable) of a users shell.<A
NAME="AEN3275"
></A
> </P
><P
>Use the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-a<A
NAME="AEN3279"
></A
></I
></SPAN
> option to list all occurances <A
NAME="AEN3281"
></A
>of the particular program_name <A
NAME="AEN3283"
></A
>in your path<A
NAME="AEN3285"
></A
> (so if theres more than one you can see it).</P
><P
>Command syntax:</P
><PRE
CLASS="SCREEN"
>which program_name</PRE
></DD
></DL
></DIV
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x2622.htm"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.htm"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x3289.htm"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Performing more than one command</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Working with files and folders</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>