<!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 > <P ></P ><UL ><LI ><P > first of all, press <TT CLASS="LITERAL" >q</TT > to leave the browser; </P ></LI ><LI ><P > <TT CLASS="LITERAL" >h</TT > gives you extensive help; </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; </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; </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. </P ></LI ><LI ><P > <TT CLASS="LITERAL" >:e</TT > examines a new file; </P ></LI ><LI ><P > <TT CLASS="LITERAL" >!command</TT > executes the shell command. </P ></LI ></UL > </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" >�</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 > <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 > </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" >�</A > </TT >.</P ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="AEN672" ></A >10.3. Archiving: tar & 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 > <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" >$ tar -cvf <archive_name.tar> <file> [file...]</PRE ></FONT ></TD ></TR ></TABLE > </P ><P >To extract files from an archive:</P ><P > <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" >$ tar -xpvf <archive_name.tar> [file...]</PRE ></FONT ></TD ></TR ></TABLE > </P ><P >To list the contents of an archive:</P ><P > <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" >$ tar -tf <archive_name.tar> | less</PRE ></FONT ></TD ></TR ></TABLE > </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 > <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" >$ compress <file> $ gzip <file></PRE ></FONT ></TD ></TR ></TABLE > </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 > <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" >$ compress -d <file.Z> $ gzip -d <file.gz></PRE ></FONT ></TD ></TR ></TABLE > </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 > <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" >$ tar -ztf <file.tar.gz> | less</PRE ></FONT ></TD ></TR ></TABLE > </P ><P >To extract the files from a <TT CLASS="LITERAL" >.tar.gz</TT > archive:</P ><P > <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" >$ tar -zxf <file.tar.gz></PRE ></FONT ></TD ></TR ></TABLE > </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" > </TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Real Life Examples</TD ></TR ></TABLE ></DIV ></BODY ></HTML >