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

839 lines
12 KiB
HTML

<HTML
><HEAD
><TITLE
>Internet Specific Commands</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="UP"
TITLE="Network Commands"
HREF="c8319.htm"><LINK
REL="PREVIOUS"
TITLE="Network Commands"
HREF="c8319.htm"><LINK
REL="NEXT"
TITLE="Remote Administration Related"
HREF="x9094.htm"></HEAD
><BODY
CLASS="SECT1"
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="c8319.htm"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 13. Network Commands</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x9094.htm"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="INTERNET-SPECIFIC-COMMANDS"
></A
>Internet Specific Commands</H1
><P
>Note that should DNS <A
NAME="AEN8754"
></A
>not be configured correctly <A
NAME="AEN8756"
></A
>on your machine,<A
NAME="AEN8758"
></A
> you need to edit <A
NAME="AEN8760"
></A
>&ldquo;/etc/resolv.conf&rdquo;<A
NAME="AEN8762"
></A
> to make things work...</P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>host</DT
><DD
><P
><A
NAME="AEN8769"
></A
>Performs a simple lookup <A
NAME="AEN8771"
></A
>of an internet <A
NAME="AEN8773"
></A
>address (using the Domain Name System, DNS). Simply type:</P
><PRE
CLASS="SCREEN"
>host ip_address</PRE
><P
>or</P
><PRE
CLASS="SCREEN"
>host domain_name</PRE
></DD
><DT
>dig</DT
><DD
><P
><A
NAME="AEN8782"
></A
>The &quot;domain information groper&quot;<A
NAME="AEN8784"
></A
> tool. More advanced <A
NAME="AEN8786"
></A
>then <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>host</I
></SPAN
>... If you give a hostname <A
NAME="AEN8789"
></A
>as an argument <A
NAME="AEN8791"
></A
>to output <A
NAME="AEN8793"
></A
>information about that host,<A
NAME="AEN8795"
></A
> including <A
NAME="AEN8797"
></A
>it's IP address, hostname and various other information. </P
><P
>For example, to look up information about &ldquo;www.amazon.com&rdquo; type:</P
><PRE
CLASS="SCREEN"
>dig www.amazon.com</PRE
><P
>To find the host name for a given IP address (ie a reverse <A
NAME="AEN8802"
></A
>lookup), use <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>dig</I
></SPAN
> with the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>`-x'<A
NAME="AEN8806"
></A
></I
></SPAN
> option.<A
NAME="AEN8808"
></A
></P
><PRE
CLASS="SCREEN"
>dig -x 100.42.30.95</PRE
><P
>This will look up the address <A
NAME="AEN8812"
></A
>(which may or may not exist) and returns <A
NAME="AEN8814"
></A
>the address of the host,<A
NAME="AEN8816"
></A
> for example if that was the address of &ldquo;http://slashdot.org&rdquo;<A
NAME="AEN8818"
></A
> then it would return <A
NAME="AEN8820"
></A
>&ldquo;http://slashdot.org&rdquo;.</P
><P
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>dig</I
></SPAN
> takes a huge <A
NAME="AEN8824"
></A
>number <A
NAME="AEN8826"
></A
>of options <A
NAME="AEN8828"
></A
>(at the point of being too many), refer<A
NAME="AEN8830"
></A
> to the manual page for more information.<A
NAME="AEN8832"
></A
></P
><P
></P
></DD
><DT
>whois</DT
><DD
><P
><A
NAME="AEN8839"
></A
>(now <SPAN
CLASS="ACRONYM"
>BW</SPAN
> whois) is used to look up the contact <A
NAME="AEN8842"
></A
>information from the &ldquo;whois&rdquo; databases,<A
NAME="AEN8844"
></A
> the servers <A
NAME="AEN8846"
></A
>are only likely to hold major <A
NAME="AEN8848"
></A
>sites. Note that contact information is likely to be hidden <A
NAME="AEN8850"
></A
>or restricted <A
NAME="AEN8852"
></A
>as it is often abused by crackers <A
NAME="AEN8854"
></A
>and others looking <A
NAME="AEN8856"
></A
>for a way to cause <A
NAME="AEN8858"
></A
>malicious damage <A
NAME="AEN8860"
></A
>to organisation's.</P
></DD
><DT
>wget</DT
><DD
><P
><A
NAME="AEN8866"
></A
>(GNU Web get) used to download <A
NAME="AEN8868"
></A
>files from the World Wide Web.</P
><P
>To archive <A
NAME="AEN8871"
></A
>a single web-site, use the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-m<A
NAME="AEN8874"
></A
></I
></SPAN
> or <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>--mirror<A
NAME="AEN8877"
></A
></I
></SPAN
> (mirror) option.</P
><P
>Use<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> </I
></SPAN
>the<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> -nc <A
NAME="AEN8882"
></A
></I
></SPAN
>(no clobber) option to stop <A
NAME="AEN8884"
></A
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>wget</I
></SPAN
> from overwriting <A
NAME="AEN8887"
></A
>a file if you already have it.</P
><P
>Use the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-c<A
NAME="AEN8891"
></A
></I
></SPAN
> or <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>--continue</I
></SPAN
> option to continue a file that was unfinished <A
NAME="AEN8894"
></A
>by wget or another program.<A
NAME="AEN8896"
></A
></P
><P
>Simple usage <A
NAME="AEN8899"
></A
>example:</P
><PRE
CLASS="SCREEN"
>wget url_for_file</PRE
><P
>This would simply get a file from a site.<A
NAME="AEN8903"
></A
> </P
><P
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>wget</I
></SPAN
> can also retrieve <A
NAME="AEN8907"
></A
>multiple files using standard wildcards,<A
NAME="AEN8909"
></A
> the same as the type used in bash,<A
NAME="AEN8911"
></A
> like *, [ ], ?. Simply use <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>wget</I
></SPAN
> as per normal <A
NAME="AEN8914"
></A
>but use single quotation <A
NAME="AEN8916"
></A
>marks (' ') on the URL <A
NAME="AEN8918"
></A
>to prevent<A
NAME="AEN8920"
></A
> bash <A
NAME="AEN8922"
></A
>from expanding <A
NAME="AEN8924"
></A
>the wildcards.<A
NAME="AEN8926"
></A
> There are complications if you are retrieving from a http site (see below...).</P
><P
>Advanced usage <A
NAME="AEN8929"
></A
>example, (used from <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>wget</I
></SPAN
> manual page):</P
><PRE
CLASS="SCREEN"
>wget --spider --force-html -i bookmarks.html</PRE
><P
>This will parse <A
NAME="AEN8934"
></A
>the file bookmarks.html <A
NAME="AEN8936"
></A
>and check <A
NAME="AEN8938"
></A
>that all the links <A
NAME="AEN8940"
></A
>exist.<A
NAME="AEN8942"
></A
></P
><P
>Advanced usage:<A
NAME="AEN8945"
></A
> this is how you can download <A
NAME="AEN8947"
></A
>multiple files using http <A
NAME="AEN8949"
></A
>(using a wildcard...).</P
><P
>Notes: http <A
NAME="AEN8952"
></A
>doesn't support <A
NAME="AEN8954"
></A
>downloading <A
NAME="AEN8956"
></A
>using standard wildcards,<A
NAME="AEN8958"
></A
> ftp <A
NAME="AEN8960"
></A
>does so you may use wildcards with ftp and it will work fine. A work-around <A
NAME="AEN8962"
></A
>for this http limitation is shown <A
NAME="AEN8964"
></A
>below:</P
><PRE
CLASS="SCREEN"
>wget -r -l1 --no-parent -A.gif http://www.website.com<A
NAME="AEN8967"
HREF="#FTN.AEN8967"
><SPAN
CLASS="footnote"
>[1]</SPAN
></A
></PRE
><P
>This will download (recursively), to a depth <A
NAME="AEN8972"
></A
>of one, in other words in the current <A
NAME="AEN8974"
></A
>directory <A
NAME="AEN8976"
></A
>and not below that. This command will ignore references <A
NAME="AEN8978"
></A
>to the parent <A
NAME="AEN8980"
></A
>directory,<A
NAME="AEN8982"
></A
> and downloads<A
NAME="AEN8984"
></A
> anything that ends in &ldquo;.gif&rdquo;. If you wanted to download say, anything that ends <A
NAME="AEN8986"
></A
>with &ldquo;.pdf&rdquo; as well than add <A
NAME="AEN8988"
></A
>a <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-A.pdf</I
></SPAN
> <A
NAME="AEN8991"
></A
>before the website <A
NAME="AEN8993"
></A
>address. Simply change <A
NAME="AEN8995"
></A
>the website <A
NAME="AEN8997"
></A
>address and the type of file being downloaded<A
NAME="AEN8999"
></A
> to download something else. Note that doing <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-A.gif</I
></SPAN
> is the same as doing <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-A &ldquo;*.gif</I
></SPAN
>&rdquo; (double quotes <A
NAME="AEN9003"
></A
>only, single quotes <A
NAME="AEN9005"
></A
>will not work).</P
><P
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>wget</I
></SPAN
> has many more options refer to the examples section of the manual page,<A
NAME="AEN9009"
></A
> this tool is very well documented.</P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Alternative website downloaders: </B
>You may like to try alternatives like httrack<A
NAME="AEN9014"
></A
>. A full <SPAN
CLASS="ACRONYM"
>GUI</SPAN
> website downloader written in python and available for GNU/Linux </P
></BLOCKQUOTE
></DIV
></DD
><DT
>curl</DT
><DD
><P
><A
NAME="AEN9021"
></A
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>curl</I
></SPAN
> is another remote <A
NAME="AEN9024"
></A
>downloader.<A
NAME="AEN9026"
></A
> This remote <A
NAME="AEN9028"
></A
>downloader <A
NAME="AEN9030"
></A
>is designed <A
NAME="AEN9032"
></A
>to work without user interaction and supports <A
NAME="AEN9034"
></A
>a variety <A
NAME="AEN9036"
></A
>of protocols,<A
NAME="AEN9038"
></A
> can upload/download and has a large number of tricks/work-arounds for various things. It can access <A
NAME="AEN9040"
></A
>dictionary <A
NAME="AEN9042"
></A
>servers <A
NAME="AEN9044"
></A
>(dict), ldap <A
NAME="AEN9046"
></A
>servers, ftp, http,<A
NAME="AEN9048"
></A
> gopher,<A
NAME="AEN9050"
></A
> see the manual <A
NAME="AEN9052"
></A
>page for full <A
NAME="AEN9054"
></A
>details.<A
NAME="AEN9056"
></A
> </P
><P
>To access <A
NAME="AEN9059"
></A
>the full <A
NAME="AEN9061"
></A
>manual (which is huge) for this command type:</P
><PRE
CLASS="SCREEN"
>curl -M<A
NAME="AEN9064"
></A
></PRE
><P
>For general <A
NAME="AEN9067"
></A
>usage you can use it like <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>wget</I
></SPAN
>. You can also login <A
NAME="AEN9070"
></A
>using a user name by using the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-u<A
NAME="AEN9073"
></A
></I
></SPAN
> option and typing your username <A
NAME="AEN9075"
></A
>and password like this:</P
><PRE
CLASS="SCREEN"
>curl -u username:password http://www.placetodownload/file</PRE
><P
>To upload <A
NAME="AEN9079"
></A
>using ftp <A
NAME="AEN9081"
></A
>you the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-T<A
NAME="AEN9084"
></A
></I
></SPAN
> option:<A
NAME="AEN9086"
></A
></P
><PRE
CLASS="SCREEN"
>curl -T file_name ftp://ftp.uploadsite.com</PRE
><P
>To continue a file use the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-C<A
NAME="AEN9091"
></A
></I
></SPAN
> option:</P
><PRE
CLASS="SCREEN"
>curl -C - -o file http://www.site.com</PRE
></DD
></DL
></DIV
></DIV
><H3
CLASS="FOOTNOTES"
>Notes</H3
><TABLE
BORDER="0"
CLASS="FOOTNOTES"
WIDTH="100%"
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.AEN8967"
HREF="x8751.htm#AEN8967"
><SPAN
CLASS="footnote"
>[1]</SPAN
></A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>This way around the wildcard limitation has been adopted (with a tiny amount of editing) from <A
HREF="http://www.lns.cornell.edu/public/COMP/info/wget/wget_7.html"
TARGET="_top"
>wget manual page</A
>, see [9] in the <A
HREF="b12722.htm"
><I
>Bibliography</I
></A
> for further information.</P
></TD
></TR
></TABLE
><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="c8319.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="x9094.htm"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Network Commands</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c8319.htm"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Remote Administration Related</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>