old-www/HOWTO/VMS-to-Linux-HOWTO/advanced-topics.html

855 lines
13 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>Advanced Topics </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="Mail and Internet Tools "
HREF="mail-and-internet-tools.html"><LINK
REL="NEXT"
TITLE="Configuring "
HREF="configuring.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="mail-and-internet-tools.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="configuring.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="ADVANCED-TOPICS"
></A
>8. Advanced Topics</H1
><P
>Here the game gets tough. Learn these features, then you'll be ready to say
that you `know something about Linux' ;-)</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="PERMISSIONS"
></A
>8.1. Permissions and Ownership</H2
><P
>Files and directories have permissions (`protections') and ownership, just
like under VMS. If you can't run a program, or can't modify a file, or can't
access a directory, it's because you don't have the permission to do so,
and/or because the file doesn't belong to you. Let's have a look at the
following example:</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ ls -l /bin/ls
-rwxr-xr-x 1 root bin 27281 Aug 15 1995 /bin/ls*</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
><P
>The first field shows the permissions of the file <TT
CLASS="LITERAL"
>ls</TT
> (owner root,
group bin). There are three types of ownership: owner, group, and others
(similar to VMS owner, group, world), and three types of permissions:
read, write (and delete), and execute.</P
><P
>From left to right, <TT
CLASS="LITERAL"
>-</TT
> is the file type (<TT
CLASS="LITERAL"
>-</TT
> = ordinary file, <TT
CLASS="LITERAL"
>d</TT
>
= directory, <TT
CLASS="LITERAL"
>l</TT
> = link, etc); <TT
CLASS="LITERAL"
>rwx</TT
> are the permissions for the file
owner (read, write, execute); <TT
CLASS="LITERAL"
>r-x</TT
> are the permissions for the group of
the file owner (read, execute); <TT
CLASS="LITERAL"
>r-x</TT
> are the permissions for all other
users (read, execute).</P
><P
>To change a file's permissions:</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ chmod &#60;whoXperm&#62; &#60;file&#62;</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
><P
>where who is <TT
CLASS="LITERAL"
>u</TT
> (user, that is owner), <TT
CLASS="LITERAL"
>g</TT
> (group), <TT
CLASS="LITERAL"
>o</TT
> (other),
X is either <TT
CLASS="LITERAL"
>+</TT
> or <TT
CLASS="LITERAL"
>-</TT
>, perm is <TT
CLASS="LITERAL"
>r</TT
> (read), <TT
CLASS="LITERAL"
>w</TT
> (write), or
<TT
CLASS="LITERAL"
>x</TT
> (execute). Examples:</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ chmod u+x file</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
><P
>this sets the execute permission for the file owner. Shortcut:
<TT
CLASS="LITERAL"
>chmod +x file</TT
>.</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ chmod go-wx file</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
><P
>this removes write and execute permission for everyone except the owner.</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ chmod ugo+rwx file</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
><P
>this gives everyone read, write, and execute permission. </P
><P
>A shorter way to refer to permissions is with numbers: <TT
CLASS="LITERAL"
>rwxr-xr-x</TT
> can be
expressed as 755 (every letter corresponds to a bit: <TT
CLASS="LITERAL"
>---</TT
> is 0,
<TT
CLASS="LITERAL"
>--x</TT
> is 1, <TT
CLASS="LITERAL"
>-w-</TT
> is 2...).</P
><P
>For a directory, <TT
CLASS="LITERAL"
>rx</TT
> means that you can <TT
CLASS="LITERAL"
>cd</TT
> to that directory, and
<TT
CLASS="LITERAL"
>w</TT
> means that you can delete a file in the directory (according to the
file's permissions, of course), or the directory itself. All this is only
part of the matter---RMP.</P
><P
>To change a file's owner:</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ chown username file</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
><P
>To sum up, a table:</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>VMS Linux Notes
------------------------------------------------------------------------------
SET PROT=(O:RW) file.txt $ chmod u+rw file.txt
$ chmod 600 file.txt
SET PROT=(O:RWED,W) file $ chmod u+rwx file
$ chmod 700 file
SET PROT=(O:RWED,W:RE) file $ chmod 755 file
SET PROT=(O:RW,G:RW,W) file $ chmod 660 file
SET FILE/OWNER_UIC=JOE file $ chown joe file
SET DIR/OWNER_UIC=JOE [.dir] $ chown joe dir/</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="MULTITASKING"
></A
>8.2. Multitasking: Processes and Jobs</H2
><P
>More about running programs. There are no `batch queues' under Linux as
you're used to; multitasking is handled very differently. Again, this is
what the typical command line looks like:</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ command -s1 -s2 ... -sn par1 par2 ... parn &#60; input &#62; output &#38;</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
><P
>where <TT
CLASS="LITERAL"
>-s1</TT
>, ..., <TT
CLASS="LITERAL"
>-sn</TT
> are the program switches,
<TT
CLASS="LITERAL"
>par1</TT
>, ..., <TT
CLASS="LITERAL"
>parn</TT
> are the program parameters.</P
><P
>Now let's see how multitasking works. Programs, running in foreground or
background, are called `processes'.</P
><P
>&#13;<P
></P
><UL
><LI
><P
> To launch a process in background:
<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ progname [-switches] [parameters] [&#60; input] [&#62; output] &#38;
[1] 234</PRE
></FONT
></TD
></TR
></TABLE
>
the shell tells you what the `job number' (the first digit; see below) and
PID (Process IDentifier) of the process are. Each process is identified
by its PID.&#13;</P
></LI
><LI
><P
> To see how many processes there are:
<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ ps -ax</PRE
></FONT
></TD
></TR
></TABLE
>
This will output a list of currently running processes.&#13;</P
></LI
><LI
><P
> To kill a process:
<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ kill &#60;PID&#62;</PRE
></FONT
></TD
></TR
></TABLE
>
You may need to kill a process when you don't know how to quit it
the right way... ;-). Sometimes, a process will only be killed by
one of the following:
<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ kill -15 &#60;PID&#62;
$ kill -9 &#60;PID&#62;</PRE
></FONT
></TD
></TR
></TABLE
>
&#13;</P
></LI
></UL
>&#13;</P
><P
>In addition to this, the shell allows you to stop or temporarily suspend a
process, send a process to background, and bring a process from background
to foreground. In this context, processes are called `jobs'.</P
><P
>&#13;<P
></P
><UL
><LI
><P
> To see how many jobs there are:
<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ jobs</PRE
></FONT
></TD
></TR
></TABLE
>
jobs are identified by the numbers the shell gives them, not by their PID.&#13;</P
></LI
><LI
><P
> To stop a process running in foreground:
<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ CTRL-C</PRE
></FONT
></TD
></TR
></TABLE
>
(it doesn't always work)&#13;</P
></LI
><LI
><P
> To suspend a process running in foreground:
<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ CTRL-Z</PRE
></FONT
></TD
></TR
></TABLE
>
(ditto)&#13;</P
></LI
><LI
><P
> To send a suspended process into background (it becomes a job):
<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ bg &#60;job&#62;</PRE
></FONT
></TD
></TR
></TABLE
>
&#13;</P
></LI
><LI
><P
> To bring a job to foreground:
<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ fg &#60;job&#62;</PRE
></FONT
></TD
></TR
></TABLE
>
&#13;</P
></LI
><LI
><P
> To kill a job:
<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ kill &#60;%job&#62;</PRE
></FONT
></TD
></TR
></TABLE
>
&#13;</P
></LI
></UL
>&#13;</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN542"
></A
>8.3. Files, Revisited</H2
><P
>More information about files.</P
><P
>&#13;<P
></P
><UL
><LI
><P
> <EM
>stdin, stdout, stderr</EM
>: under UNIX, every system component is
treated as if it were a file. Commands and programs get their input from a
`file' called <TT
CLASS="LITERAL"
>stdin</TT
> (standard input; usually, the keyboard), put their
output on a `file' called <TT
CLASS="LITERAL"
>stdout</TT
> (usually, the screen), and error
messages go to a `file' called <TT
CLASS="LITERAL"
>stderr</TT
> (usually, the screen).
Using <TT
CLASS="LITERAL"
>&#60;</TT
> and <TT
CLASS="LITERAL"
>&#62;</TT
> you redirect input and output to a different
file. Moreover, <TT
CLASS="LITERAL"
>&#62;&#62;</TT
> appends the output to a file instead of
overwriting it; <TT
CLASS="LITERAL"
>2&#62;</TT
> redirects error messages (stderr); 2&#62;&#38;1
redirects stderr to stdout, while 1&#62;&#38;2 redirects stdout to stderr.
There's a `black hole' called <TT
CLASS="LITERAL"
>/dev/null</TT
>: everything redirected to
it disappears;&#13;</P
></LI
><LI
><P
> <EM
>wildcards</EM
>: '<TT
CLASS="LITERAL"
>*</TT
>' is almost the same. Usage: * matches all
files except the hidden ones; .* matches all hidden files; *.* matches
only those that have a '.' in the middle, followed by other characters;
p*r matches both `peter' and `piper'; *c* matches both `picked' and `peck'.
'<TT
CLASS="LITERAL"
>%</TT
>' becomes '<TT
CLASS="LITERAL"
>?</TT
>'. There is another wildcard: the
<TT
CLASS="LITERAL"
>[]</TT
>. Usage: <TT
CLASS="LITERAL"
>[abc]*</TT
> matches files starting with a, b, c;
<TT
CLASS="LITERAL"
>*[I-N,1,2,3]</TT
> matches files ending with I, J, K, L, M, N, 1, 2, 3;&#13;</P
></LI
><LI
><P
> <TT
CLASS="LITERAL"
>mv</TT
> (<TT
CLASS="LITERAL"
>RENAME</TT
>) doesn't work for multiple files; that is,
<TT
CLASS="LITERAL"
>mv *.xxx *.yyy</TT
> won't work;&#13;</P
></LI
><LI
><P
> use <TT
CLASS="LITERAL"
>cp -i</TT
> and <TT
CLASS="LITERAL"
>mv -i</TT
> to be warned when a file is going to
be overwritten.&#13;</P
></LI
></UL
>&#13;</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="PRINT-QUEUES"
></A
>8.4. Print Queues</H2
><P
>Your prints are queued, like under VMS. When you issue a print command, you
may specify a printer name. Example:</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>$ lpr file.txt # this goes to the standard printer
$ lpr -Plaser file.ps # this goes to the printer named 'laser'</PRE
></FONT
></TD
></TR
></TABLE
>&#13;</P
><P
>To handle the print queues, you use the following commands:</P
><P
>&#13;<TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>&#13;VMS Linux
------------------------------------------------------------------------------
$ PRINT file.ps $ lpr file.ps
$ PRINT/QUEUE=laser file.ps $ lpr -Plaser file.ps
$ SHOW QUEUE $ lpq
$ SHOW QUEUE/QUEUE=laser $ lpq -Plaser
$ STOP/QUEUE $ lprm &#60;item&#62;&#13;</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="mail-and-internet-tools.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="configuring.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Mail and Internet Tools</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Configuring</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>