old-www/HOWTO/VMS-to-Linux-HOWTO/useful-programs.html

517 lines
7.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>Useful Programs </TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="From VMS to Linux HOWTO"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="Configuring "
HREF="configuring.html"><LINK
REL="NEXT"
TITLE="Real Life Examples "
HREF="examples.html"></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"
>From VMS to Linux HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="configuring.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="examples.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="USEFUL-PROGRAMS"
></A
>10. Useful Programs</H1
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN617"
></A
>10.1. Browsing Files: <TT
CLASS="LITERAL"
>less</TT
></H2
><P
>You'll use this file browser every day, so I'll give you a couple of tips to
use it at best. First of all, ask your sysadm to configure <TT
CLASS="LITERAL"
>less</TT
> so as
it can display not only plain text files, but also compressed files,
archives, and so on.</P
><P
>Like recent versions of <TT
CLASS="LITERAL"
>TYPE</TT
>, <TT
CLASS="LITERAL"
>less</TT
> lets you browse files
in both directions. It also accepts several commands that are issued
pressing a key. The most useful are:</P
><P
>&#13;<P
></P
><UL
><LI
><P
> first of all, press <TT
CLASS="LITERAL"
>q</TT
> to leave the browser;&#13;</P
></LI
><LI
><P
> <TT
CLASS="LITERAL"
>h</TT
> gives you extensive help;&#13;</P
></LI
><LI
><P
> <TT
CLASS="LITERAL"
>g</TT
> to go to beginning of file, <TT
CLASS="LITERAL"
>G</TT
> to the end, number+<TT
CLASS="LITERAL"
>g</TT
>
to go to line `number' (e.g. <TT
CLASS="LITERAL"
>125g</TT
>), number+<TT
CLASS="LITERAL"
>%</TT
> to move to that
percentage of the file;&#13;</P
></LI
><LI
><P
> <TT
CLASS="LITERAL"
>/pattern</TT
> searches forwards for `pattern'; <TT
CLASS="LITERAL"
>n</TT
> searches
forwards for the next match; <TT
CLASS="LITERAL"
>?pattern</TT
> and <TT
CLASS="LITERAL"
>N</TT
> search backwards;&#13;</P
></LI
><LI
><P
> <TT
CLASS="LITERAL"
>m</TT
>+letter marks current position (e.g. <TT
CLASS="LITERAL"
>ma</TT
>); <TT
CLASS="LITERAL"
>'</TT
>+letter go
to the marked position.&#13;</P
></LI
><LI
><P
> <TT
CLASS="LITERAL"
>:e</TT
> examines a new file;&#13;</P
></LI
><LI
><P
> <TT
CLASS="LITERAL"
>!command</TT
> executes the shell command.&#13;</P
></LI
></UL
>&#13;</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="NUMBERED-BACKUPS-UNDER-LINUX"
></A
>10.2. Numbered Backups Under Linux</H2
><P
>Alas, Linux doesn't still support file version numbers, but you overcome
this limitation in two ways. The first is to use RCS, the Revision Control
System, which allows you to keep previous versions of a file. RCS is
covered in ``The RCS MINI-HOWTO'' (<A
HREF="http://sunsite.unc.edu/mdw/HOWTO/mini/RCS.html"
TARGET="_top"
>&#65533;</A
>).</P
><P
>The second way is to use an editor that knows how to deal with numbered
backups; <TT
CLASS="LITERAL"
>emacs</TT
> and <TT
CLASS="LITERAL"
>jed</TT
> are OK. In <TT
CLASS="LITERAL"
>emacs</TT
>, add
these lines in your <TT
CLASS="LITERAL"
>.emacs</TT
>:</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>(setq version-control t)
(setq kept-new-versions 15) ;;; or any other value
(setq kept-old-versions 15)
(setq backup-by-copying-when-linked t)
(setq backup-by-copying-when-mismatch t)</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
><P
>In <TT
CLASS="LITERAL"
>jed</TT
>, make sure you have version 0.98.7 or newer; the patch for
numbered backups is available on <TT
CLASS="LITERAL"
> <A
HREF="http://ibogeo.df.unibo.it/guido/slang/backups.sl"
TARGET="_top"
>&#65533;</A
> </TT
>.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN672"
></A
>10.3. Archiving: tar &#38; gzip</H2
><P
>Under UNIX there are some widely used applications to archive and
compress files. <TT
CLASS="LITERAL"
>tar</TT
> is used to make archives, that is collections of
files. To make a new archive:</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ tar -cvf &#60;archive_name.tar&#62; &#60;file&#62; [file...]</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
><P
>To extract files from an archive:</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ tar -xpvf &#60;archive_name.tar&#62; [file...]</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
><P
>To list the contents of an archive:</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ tar -tf &#60;archive_name.tar&#62; | less</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
><P
>Files can be compressed to save disk space using <TT
CLASS="LITERAL"
>compress</TT
>, which is
obsolete and shouldn't be used any more, or <TT
CLASS="LITERAL"
>gzip</TT
>:</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ compress &#60;file&#62;
$ gzip &#60;file&#62;</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
><P
>that creates a compressed file with extension .Z (<TT
CLASS="LITERAL"
>compress</TT
>) or .gz
(<TT
CLASS="LITERAL"
>gzip</TT
>). These programs don't make archives, but compress files
individually. To decompress, use:</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ compress -d &#60;file.Z&#62;
$ gzip -d &#60;file.gz&#62;</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
><P
>RMP.</P
><P
>The <TT
CLASS="LITERAL"
>unarj</TT
>, <TT
CLASS="LITERAL"
>zip</TT
> and <TT
CLASS="LITERAL"
>unzip</TT
> utilities are also available. Files
with extension <TT
CLASS="LITERAL"
>.tar.gz</TT
> or <TT
CLASS="LITERAL"
>.tgz</TT
> (archived with <TT
CLASS="LITERAL"
>tar</TT
>, then
compressed with <TT
CLASS="LITERAL"
>gzip</TT
>) are very common in the UNIX world. Here's how to
list the contents of a <TT
CLASS="LITERAL"
>.tar.gz</TT
> archive:</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ tar -ztf &#60;file.tar.gz&#62; | less</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
><P
>To extract the files from a <TT
CLASS="LITERAL"
>.tar.gz</TT
> archive:</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ tar -zxf &#60;file.tar.gz&#62;</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
></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="configuring.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="examples.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Configuring</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Real Life Examples</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>