From VMS to Linux HOWTO <author>著者:Guido Gonzato, <!-- <url url="guido ``at'' ibogeo.df.unibo.it">, and Mike Miller, --> <url url="guido@ibogeo.df.unibo.it">, and Mike Miller, <url url="miller5@uiuc.edu"> <date>v1.1.3 1999年9月17日 <trans> 翻訳:青野 正幸 <url url="masayuki@shikoku.ne.jp"> <tdate> 日本語訳: 1999年10月6日作成 <abstract> <!-- This HOWTO is aimed at all those who have been using VMS and now need or want to switch to Linux, the free UNIX clone. The transition is made (hopefully) painless with a step--to--step comparison between commands and available tools. --> この文書は、VMS を使っていて、フリー UNIX クローンである Linux へ切り替 えようと考えている人達の手助けになればと思い書いたものです。 Linux への移行が(望むらくは)楽にできるよう、コマンドやツールの比較などを盛り込んでいます。 </abstract> <toc> <sect><!-- Introduction <label id="Introduction">-->イントロダクション <label id="Introduction"> <sect1><!-- Why Linux?-->なぜ Linux なのか? <p> <!--You've heard that UNIX is difficult and balk at the prospect of leaving VMS, don't you? Don't worry. Linux, one of the finest UNIX clones, is not more difficult to use than VMS; actually, I find it easier. Although VMS aficionados may not agree, in many people's opinion Linux is much more powerful and versatile. --> あなたは UNIX が難しいと聞いて、VMS からの移行をちゅうちょしていませんか? 御心配なく。洗練された UNIX クローンの一つである Linux は VMS を扱うほど難 しくないし、実際、楽しいものですよ。 熱狂的な VMS ファンは同意しないかもしれないけど、大方の意見は、 Linux のほうがはるかに強力で万能だということです。 <!-- Linux and VMS are both good operating systems and accomplish essentially the same tasks, but Linux has a few features that make it a good alternative to VMS. Moreover, Linux is available for PCs while VMS is not, and modern Pentium-based Linux machines can outperform a VAX. The icing on the cake is the excellent performance of modern video cards, which turn an X11-based Linux box into a fast graphic workstation; nearly always, quicker than dedicated machines. --> Linux と VMS は両者ともすばらしいオペレーティングシステムで、どちらを使っ ても同じ仕事ができますが、Linux には VMS を代替するにたる際だった特徴があります。 その上、VMS ではまだ実現していませんが、Linux は VAX を凌ぐ性能をもつ最 新の Pentium PC で動いています。 新鋭の高性能グラフィックカードを塔載した Linux 機で X11 を利用すれば、高 速グラフィックワークステーションができあがる、というおまけもあります。性 能はほぼ例外なくグラフィックス専用機を凌ぎますから。 <!-- I imagine you're a university researcher or a student, and that you use VMS for the following everyday tasks: --> あなたは大学の研究者か学生で、VMS を使って次のような仕事をしているんじゃないでしょうか。 <itemize> <!-- <item> writing papers with TeX/LaTeX; <item> programming in Fortran; <item> doing some graphics; <item> using Internet services; <item> et cetera. --> <item>TeX/LaTeX を使って論文を書く <item>Fortran プログラミング <item>図や表の作成 <item>インターネットの利用 <item>その他 ... </itemize> <!-- In the following sections I'm going to explain to you how to do these tasks under Linux, exploiting your experience with VMS. Prerequisites: --> 次章から、あなたの VMS での経験も踏まえて、こういった仕事を Linux で はどんな風にやるのか説明していきます。 前提条件: <itemize> <!-- <item> Linux and X Window System are properly installed; <item> there's a system administrator to take care of the technical details (please get help from them, not from me ;-) ; <item> your shell---the equivalent of <tt/DCL/---is <tt/bash/ (ask your sysadm). --> <item>Linux と X Window System が正しくインストールされていること。 <item>技術上の細かな面倒をみてくれる管理者がいること (質問は私にではなく、管理者の方にしてくださいね ;-) 。 <item>シェル - DCL と同じもの - は <tt/bash/ を使います(システム管理者に確認してください)。 </itemize> <!-- Please note that this HOWTO is not enough to acquaint you fully with Linux: it only contains the bare essential to get you started. You should learn more about Linux to make the most of it (advanced <tt/bash/ features, programming, regular expressions...). From now on, RMP means `please read the man pages for further details'. The man pages are the equivalent of the command <tt/HELP/. --> この HOWTO 文書は、Linux について十分説明したものじゃなくて、 最初に知っておくべき最低限の事柄について述べたものです。 従って、Linux を使いこなすためには、さらに学ばなけばなりません (高度な <tt/bash/ の特徴、プログラミング、正規表現 など...)。これ以降、 「詳細については man ページを参照のこと」という意味で、RMP(please Read the Man Pages for further details) というマークを使います。 <!-- The Linux Documentation Project documents, available on <url url="ftp://sunsite.unc.edu:/pub/Linux/docs/LDP">, are an important source of information. I suggest that you read Larry Greenfield's ``Linux User Guide''---it's invaluable for the novice user. And now, go ahead. --> <url url="ftp://sunsite.unc.edu:/pub/Linux/docs/LDP" name="この ftp サイ ト">から入手可能な Linux Documentation Project の文書が重要な情報源となるでしょう。 初心者向けとして、Larry Greenfield の「 Linux User Guide 」をお薦めします。 さあ、はじめましょう <sect1><!-- Comparing Commands and Files-->コマンドやファイル操作の比較 <p> <!-- This table attempts to compare VMS' and Linux' most used commands. Please keep in mind that the syntax is often very different; for more details, refer to the following sections. --> これは、VMS と Linux でよく使うコマンドの比較表です。 文法がかなり異なっています。 − 詳細は次章以降を御覧ください。 <!-- <tscreen><verb> VMS Linux Notes ============================================================================ @COMMAND command must be executable COPY file1 file2 cp file1 file2 CREATE/DIR [.dirname] mkdir dirname only one at a time CREATE/DIR [.dir1.dir2] mkdirhier dir/name DELETE filename rm filename DIFF file1 file2 diff -c file1 file2 DIRECTORY ls DIRECTORY [...]file find . -name file DIRECTORY/FULL ls -al EDIT filename vi filename, you won't like it emacs filename, EDT compatible jed filename ditto===my favourite FORTRAN prog.for g77 prog.f, no need to do LINK f77 prog.f, fort77 prog.f HELP command man command must specify `command' info command ditto LATEX file.tex latex file.tex LOGIN.COM .bash_profile, `hidden' file .bashrc ditto LOGOUT.COM .bash_logout ditto MAIL mail, crude elm, much better pine better still PRINT file.ps lpr file.ps PRINT/QUEUE=laser file.ps lpr -Plaser file.ps PHONE user talk user RENAME file1 file2 mv file1 file2 not for multiple files RUN progname progname SEARCH file "pattern" grep pattern file SET DEFAULT [-] cd .. SET DEFAULT [.dir.name] cd dir/name SET HOST hostname telnet hostname, not exactly the same rlogin hostname SET FILE/OWNER_UIC=joe chown joe file completely different SET NOBROADCAST mesg SET PASSWORD passwd SET PROT=(perm) file chmod perm file completely different SET TERMINAL export TERM= different syntax SHOW DEFAULT pwd SHOW DEVICE du, df SHOW ENTRY lpq SHOW PROCESS ps -ax SHOW QUEUE lpq SHOW SYSTEM top SHOW TIME date SHOW USERS w STOP kill STOP/QUEUE kill, for processes lprm for print queues SUBMIT command command & SUBMIT/AFTER=time command at time command TEX file.tex tex file.tex TYPE/PAGE file more file less file much better --> <tscreen><verb> VMS Linux Notes ------------------------------------------------------------------------------ @COMMAND command 実行ファイルであること COPY file1 file2 cp file1 file2 CREATE/DIR [.dirname] mkdir dirname 一度に一回実行 CREATE/DIR [.dir1.dir2] mkdirhier dir/name DELETE filename rm filename DIFF file1 file2 diff -c file1 file2 DIRECTORY ls DIRECTORY [...]file find . -name file DIRECTORY/FULL ls -al EDIT filename vi filename, 多分気に入らないでしょう emacs filename, EDT 互換 jed filename 同上-- 私のお気に入り FORTRAN prog.for g77 prog.f, LINK の実行は不要 f77 prog.f, fort77 prog.f HELP command man command 「 command 」を指定します info command 同上 LATEX file.tex latex file.tex LOGIN.COM .bash_profile, 「隠し」ファイル .bashrc 同上 LOGOUT.COM .bash_logout 同上 MAIL mail, お粗末 elm, ずっといい pine さらにいい PRINT file.ps lpr file.ps PRINT/QUEUE=laser file.ps lpr -Plaser file.ps PHONE user talk user RENAME file1 file2 mv file1 file2 複数ファイル指定は不可 RUN progname progname SEARCH file "pattern" grep pattern file SET DEFAULT [-] cd .. SET DEFAULT [.dir.name] cd dir/name SET HOST hostname telnet hostname, 正確には同じじゃない rlogin hostname SET FILE/OWNER_UIC=joe chown joe file まったく違う SET NOBROADCAST mesg SET PASSWORD passwd SET PROT=(perm) file chmod perm file まったく違う SET TERMINAL export TERM= 文法が違う SHOW DEFAULT pwd SHOW DEVICE du, df SHOW ENTRY lpq SHOW PROCESS ps -ax SHOW QUEUE lpq SHOW SYSTEM top SHOW TIME date SHOW USERS w STOP kill STOP/QUEUE kill, プロセス用 lprm プリンターキュー用 SUBMIT command command & SUBMIT/AFTER=time command at time command TEX file.tex tex file.tex TYPE/PAGE file more file less file ずっといい </verb></tscreen> <!-- But of course it's not only a matter of different command names. Read on. --> もちろんコマンド名が違ってるだけじゃありません。続けましょう。 <sect><!--Short Intro <label id="Short Intro">-->ショートイントロダクション<label id="Short Intro"> <p> <!-- This is what you absolutely need to know before logging in the first time. Relax, it's not much. --> 本当にはじめて、ログインする前にどうしても知っておくべきことを書きます。 リラックスして、そんなに多くないから。 <sect1><!-- Files-->ファイル <p> <itemize> <!-- <item> Under VMS filenames are in the form <tt/filename.extension;version/. Under Linux, the version number doesn't exist (big limitation, but see Section <ref id="Numbered Backups Under Linux" name="Numbered Backups Under Linux">); the filename has normally a limit of 255 characters and can have as many dots as you like. Example of filename: <tt/This.is_a_FILEname.txt/. --> <item>VMS でファイル名は<tt/ファイル名.拡張子;バージョン番号/でしたが、 Linux ではバージョン番号はありません(これはかなり痛い制約です。 <ref id="Numbered Backups Under Linux" name="Linux での符番によるバックアップ">を参照してください)。 ファイル名は通常 255 文字以内、好きなだけドットで区切ることができます。 例えば、<tt/This.is_a_FILEname.txt/ のように。 <!-- <item> Linux distinguishes between upper case and lower case characters: <tt/FILENAME.txt/ and <tt/filename.txt/ are two different files; <tt/ls/ is a command, <tt/LS/ is not. --> <item>Linux では大文字と小文字を区別します。 <tt/FILENAME.txt/ と <tt/filename.txt/ は別なファイルとして扱います。 <tt/ls/ はコマンドですが、<tt/LS/ は違います。 <!-- <item> A filename starting with a dot is a `hidden' file (that is, it won't normally show up in dir listings), while filenames ending with a tilde '<tt/&tilde/' represent backup files. --> <item>ドットで始まるファイルは「隠し」ファイルであり(通常、ディレクトリ 一覧には表示されません) チルダ「 <tt/&tilde/ 」で終るファイルはバックアップファイルです。 </itemize> <!-- Now, a table to sum up how to translate commands from VMS to Linux: --> これはVMS のコマンドを Linux に置き換えたものです。 <tscreen><verb> VMS Linux --------------------------------------------------------------------- $ COPY file1.txt file2.txt $ cp file1.txt file2.txt $ COPY [.dir]file.txt [] $ cp dir/file.txt . $ COPY [.dir]file.txt [-] $ cp dir/file.txt .. $ DELETE *.dat;* $ rm *dat $ DIFF file1 file2 $ diff -c file1 file2 $ PRINT file $ lpr file $ PRINT/queue=queuename file $ lpr -Pprintername file $ SEARCH *.tex;* "geology" $ grep geology *tex </verb></tscreen> <!-- For other examples involving directories, see below; for details about protections, ownership, and advanced topics, see Section <ref id="Advanced Topics" name="Advanced Topics">. --> ディレクトリを含む他の例については以下で説明します。アクセス保護、所有権、その他の高度な話題などについては、<ref id="Advanced Topics" name="高度な話題">の章を見てください。 <sect1><!-- Directories-->ディレクトリ <p> <itemize> <!-- <item> Within the same node and device, directories names under VMS are in the form <tt/[top.dir.subdir]/; under Linux, <tt>/top/dir/subdir/</tt>. On the top of the directory tree lies the so--called `root directory' called <tt>/</tt>; underneath there are other directories like <tt>/bin</tt>, <tt>/usr</tt>, <tt>/tmp</tt>, <tt>/etc</tt>, and others. --> <item>同じノードの装置上にある場合、VMS でのディレクトリ名は <tt/[top.dir.subdir]/ の形式となりますが、Linux では <tt>/top/dir/subdir/</tt> の形式になります。 また、ディレルトリーツリーの先頭にあたるディレクトリをルートディレクトリ と呼び <tt>/</tt> で表し、その下に <tt>/bin</tt>,<tt>/usr</tt>, <tt>/tmp</tt>, <tt>/etc</tt> などの他のディレクトリがその下に位置します。 <!-- <item> The directory <tt>/home</tt> contains the so--called users' `home directories': e.g. <tt>/home/guido</tt>, <tt>/home/warner</tt>, and so on. When a user logs in, they start working in their home dir; it's the equivalent of <tt/SYS$LOGIN/. There's a shortcut for the home directory: the tilde '<tt/&tilde/'. So, <tt>cd ˜/tmp</tt> is the same as, say, <tt>cd /home/guido/tmp</tt>. --> <item><tt>/home</tt> ディレクトリの下にはユーザ毎に用意された「ホームディレクトリ」 があります。例えば <tt>/home/guido</tt> や <tt>/home/warner</tt> のように。 ログインして、自分のホームディレクトリで作業しますが、これは <tt/SYS$LOGIN/ と同じですね。 「<tt/&tilde/」はホームディレクトリへのショートカットで、<tt>cd ˜/tmp</tt> と <tt>cd /home/guido/tmp</tt> は同じディレクトリを指します。 <!-- <item> Directory names follow the same rules as file names. Furthermore, each directory has two special entries: one is <tt/./ and refers to the directory itself (like <tt/[]/), and <tt/../ that refers to the parent directory (like <tt/[-]/). --> <item>ディレクトリとファイルは同じ命名則に従います。 さらに、各ディレクトリには二つの特別なエントリが存在します。 一つは <tt/./ で、これは現在のディレクトリ自体を指します( <tt/[]/ と同じ)。 もう一つは <tt/../ で、親ディレクトリを指します( <tt/[-]/ と同じ)。 </itemize> <!-- And now for some other examples: --> 別な例を示します。 <tscreen><verb> VMS Linux --------------------------------------------------------------------- $ CREATE/DIR [.dirname] $ mkdir dirname $ CREATE/DIR [.dir1.dir2.dir3] $ mkdirhier dir1/dir2/dir3 n/a $ rmdir dirname (if dirname is empty) $ rm -R dirname $ DIRECTORY $ ls $ DIRECTORY [...]file.*;* $ find . -name "file*" $ SET DEF SYS$LOGIN $ cd $ SET DEF [-] $ cd .. $ SET DEF [top.dir.subdir] $ cd /top/dir/subdir $ SET DEF [.dir.subdir] $ cd dir/subdir $ SHOW DEF $ pwd </verb></tscreen> <!-- For protections, ownership, and advanced topics, see Section <ref id="Advanced Topics" name="Advanced Topics">. --> アクセス保護、所有権、その他の高度な話題については<ref id="Advanced Topics" name="高度な話題">を御覧ください。 <sect1><!-- Programs-->プログラム <p> <itemize> <!-- <item> Commands, compiled programs, and shell scripts (VMS' `command files') don't have sort of mandatory extensions like <tt/.EXE/ or <tt/.COM/ and can be called whatever you like. Executable files are marked by an asterisk '<tt/*/' when you issue <tt/ls -F/. --> <item>コマンドやコンパイルしたプログラム、およびシェルスクリプト ( VMS の「コマンドファイル」と同じ)には、<tt/.EXE/ や <tt/.COM/ のような拡張子 は不要で、好きな名前をつけることができます。 <tt/ls -F/ で見ると、実行可能なファイルにはアスタリスク「 <tt/*/ 」がついています。 <!-- <item> To run an executable file, just type its name (no <tt/RUN PROGRAM.EXE/ or <tt/@COMMAND/). Caveat: it's essential that the file be located in a directory included in the <em/path of executables/, which is a list of directories. Typically, the path includes dirs like <tt>/bin</tt>, <tt>/usr/bin</tt>, <tt>/usr/X11R6/bin</tt>, and others. If you write your own programs, put them in a directory you have included in the path (see how in Section <ref id="Configuring" name="Configuring">). As an alternative, you may run a program specifying its complete path: e.g., <tt>/home/guido/data/myprog</tt>; or <tt>./myprog</tt>, if the current directory isn't in the path. --> <item>実行可能ファイルを起動するには、ファイル名をタイプしてください( <tt/RUN PROGRAM.EXE/ や <tt/@COMMAND/ じゃありません)。 警告:ファイルが<em/実行パス/にあることが不可欠です。通常、パスには <tt>/bin</tt>,<tt>/usr/bin</tt>,<tt>/usr/X11R6/bin</tt> などが含まれています。プログラム を作ったら、パスの通ったディレクトリに移してください。 (設定方法は<ref id="Configuring" name="設定">を御覧ください) カレントディレクトリがパスに含まれていないなら、替わりの手段として、 フルパス指定でプログラムを実行することもできます。 例えば、<tt>/home/guido/data/myprog</tt> や <tt>./myprog</tt> のように。 <!-- <item> Command switches are obtained with <tt>/OPTION=</tt> under VMS, and with <tt/-switch/ or <tt/--switch/ under Linux, where <tt/switch/ is a letter, more letters combined, or a word. In particular, the switch <tt/-R/ (recursive) of many Linux commands performs the same action as <tt/[...]/ under VMS; --> <item>VMS では <tt>/OPTION=</tt> の形でコマンドスイッチを指定しますが、 Linux では <tt/-switch/ や <tt/--switch/ のように指定します。 <tt/switch/ は文字や文字の組合せ、または単語などです。 特に、多くのコマンドに共通の <tt/-R/ スイッチ(再帰的に)は VMS で <tt/[...]/ と同じ効果があります。 <!-- <item> You can issue several commands on the command line: --> <item>一行で複数のコマンドを実行することもできます。 <tscreen><verb> $ command1 ; command2 ; ... ; commandn </verb></tscreen> <!-- <item> Most of the flexibility of Linux comes from two features awkwardly implemented or missing in VMS: I/O redirection and piping. (I have been tod that recent versions of DCL support redirection and piping, but I don't have that version.) Redirection is a side feature under VMS (remember the switch <tt>/OUTPUT=</tt> of many commands), or a fastidious process, like: --> Linux をさらに使いやすくしているのが I/O リダイレクトとパイプなんですが、 VMS では扱いにくかったり、あるいはそれに匹敵するものがありません(最近の DCL では リダイレクトとパイプをサポートしたようですが、残念ながら私はそのバージョンを持っていません)。 VMS でのリダイレクトは、コマンドのスイッチとして補助的にサポートされてい るか(多くのコマンドにある <tt>/OUTPUT=</tt> スイッチを思い出してください)、つぎのような面倒なやり方で実現できます。 <tscreen><verb> $ DEFINE /USER SYS$OUTPUT OUT $ DEFINE /USER SYS$INPUT IN $ RUN PROG </verb></tscreen> <!-- which has the simple Linux (UNIX) equivalent: --> Linux ではこんなに簡単になります。 <tscreen><verb> $ prog < in > out </verb></tscreen> <!-- Piping is not readily available under VMS, but has a key role under UNIX. A typical example: --> パイプは VMS では利用できませんが、UNIX では重要な役割を持っています。 これが典型的な例です。 <tscreen><verb> $ myprog < datafile | filter_1 | filter_2 >> result.dat 2> errors.log & </verb></tscreen> <!-- which means: the program <tt/myprog/ gets its input from the file <tt/datafile/ (via <tt/</), its output is piped (via <tt/|/) to the program <tt/filter_1/ that takes it as input and processes it, the resulting output is piped again to <tt/filter_2/ for further processing, the final output is appended (via <tt/>>/) to the file <tt/result.dat/, and error messages are redirected (via <tt/2>/) onto the file <tt/errors.log/. All this in background (<tt/&/ at the end of the command line). More about this in Section <ref id="Examples" name="Examples">. --> プログラム <tt/myprog/ はファイル <tt/datafile/ を( <tt/</ を経由して)入力として取り込み、 出力はプログラム <tt/filter_1/ の入力に( <tt/|/ を経由して)渡されます。 プログラム <tt/filter_1/ の出力は、再びプログラム <tt/filter_2/ に渡され、 最終的な出力は ファイル <tt/result.dat/ に( <tt/>>/ を経由して)追 記されます。またエラー出力はファイル <tt/errors.log/ に( <tt/2>/ を経由して)リダイレクトされます。 以上の処理はバックグラウンドで処理されます(コマンドラインの最後に <tt/&/ をつけているため)。 より詳しい説明は<ref id="Examples" name="Examples">を御覧ください。 </itemize> <!-- For multitasking, `queues', and the like, see Section <ref id="Advanced Topics"name="Advanced Topics">. --> マルチタスク処理、「キュー」などについては<ref id="Advanced Topics" name="高度な話題">を御覧ください。 <sect1><!-- Quick Tour <label id="Quick Tour">--> クイックツアー <p> <!-- Now you are ready to try Linux out. Enter your login name and password <em/exactly/ as they are. For example, if your login name and password are <tt/john/ and <tt/My_PassWd/, <em/don't/ type <tt/John/ or <tt/my_passwd/. Remember, UNIX distinguishes between capital and small letters. --> ここまでで Linux を試す準備ができました。ログイン名とパスワードを<em/正確/に入力し てみてください。例えば、ログイン名が <tt/john/ でパスワードが <tt/My_PassWd/ なら<em/決して/ <tt/John/ や <tt/my_passwd/ などと入力し ないこと。 UNIX は大文字と小文字を区別するのですから。 <!-- Once you've logged in, you'll see a prompt; chances are it'll be something like <tt/machinename:$/. If you want to change the prompt or make some programs start automatically, you'll have to edit a `hidden' file called <tt/.profile/ or <tt/.bash_profile/ (see example in Section <ref id="Configuring" name="Configuring">). This is the equivalent of <tt/LOGIN.COM/. --> 一旦ログインしたら、<tt/マシン名:$/ のようなプロンプトが表示され ることでしょう。プロンプトを変更したり、プログラムを自動的に実行させたい 場合は、<tt/.profile/ や <tt/.bash_profile/ などの「隠し」ファイルを修正しま す。(<ref id="Configuring" name="設定">を御覧ください) これらのファイル は <tt/LOGIN.COM/ と同じ働きをします。 <!-- Pressing ALT--F1, ALT--F2, ... ALT--F6 switches between `virtual consoles'. When one VC is busy with a full--screen application, you can flip over to another and continue to work. Try and log in to another VC. --> ALT-F1(ALT キーと F1 キーを同時に押します)、ALT-F2, ... ALT-F6 のどれかを押せば「仮想コンソール(訳注 : 以下 VC と呼ぶ)」を切り替えることができます。画面全体を使うアプリケーションが VC を占有しても、他の VC に切り替えることで作業を続けることができます。別な VC を開いてログインしてみてください。 <!-- Now you may want to start X Window System (from now on, X). X is a graphic environment very similar to DECWindows---actually, the latter derives from the former. Type the command <tt/startx/ and wait a few seconds; most likely you'll see an open <tt/xterm/ or equivalent terminal emulator, and possibly a button bar. (It depends on how your sysadm configured your Linux box.) Click on the desktop (try both mouse buttons) to see a menu. --> X Window System (以下、X と省略)を起動できることと思います。 X は DEC ウインドウに似たグラフィック環境です。- 実際、DEC ウインドウは X から派生したものです。 startx と打って数秒待つ と、<tt/xterm/ か それに似た端末エミュレータが起動し、ボタンバーも表 示されることでしょう(何が起動されるかは Linux の設定にもよりますが)。デ スクトップをクリック(マウスの両方のボタンを試してくださいね)すればメニューを表示します。 <!-- While in X, to access the text mode (`console') sessions press CTRL--ALT--F1 ... CTRL--ALT--F6. Try it. When in console, go back to X pressing ALT--F7. To quit X, follow the menu instructions or press CTRL--ALT--BS. Type the following command to list your home dir contents, including the hidden files: --> X 環境でテキストモード(「コンソール」)にするには、CTRL-ALT-F1(コントロールキーと ALT キーと F1 を同時に押します)、CTRL-ALT-F2、... CTRL-ALT-F6 のどれかを押してみてください。コンソールから X に復 帰するには ALT-F7 キーです。X を終了するには、メニューの指示に従うか、 CTRL-ALT-BS を押します。 次のコマンドはホームディレクトリ内の全てのファイル(隠しファイルも含む)を 一覧します。 <tscreen><verb> $ ls -al </verb></tscreen> <!-- Press SHIFT--PAG UP to back-scroll. Now get help about the <tt/ls/ command typing: --> ここで SHIFT-Page Up キーを押すと画面後方にスクロールするでしょう。 <tt/ls/ のヘルプを見たければ、 <tscreen><verb> $ man ls </verb></tscreen> とタイプしましょう。 <!-- pressing 'q' to exit. To end the tour, type <tt/exit/ to quit your session. If now you want to turn off your PC, press CTRL--ALT--DEL and wait a few seconds (<em/never/ switch off the PC while in Linux! You could damage the filesystem.) If you think you're ready to work, go ahead, but if I were you I'd jump to Section <ref id="Advanced Topics"name="Advanced Topics">. --> 「 q 」でヘルプ画面から抜けることができます。ツアーの最後に <tt/exit/ で セッションを終了しましょう。もし PC の電源を切るのなら、CTRL-ALT-DEL を 同時に押して、数秒後に電源を切ってください(<em/決して/ Linux の稼働中に電 源を切ってはいけませんよ!ファイルシステムが壊れるおそれがありますから)。 すでに何らかの作業を開始しようと思われてる方、<ref id="Advanced Topics" name="高度な話題">を見てからにしましょう。 <sect><!-- Editing Files <label id="Editing Files">-->ファイルの編集<label id="Editing Files"> <p> <!-- Linux doesn't have <tt/EDT/, but there are scores of editors available. The only one that's guaranteed to be included in every UNIX version is <tt/vi/---forget it, your sysadm must have installed something better. Probably the most popular editor is <tt/emacs/, which can emulate <tt/EDT/ to a certain degree; <tt/jed/ is another editor that provides <tt/EDT/ emulation. --> Linux には <tt/EDT/ はありませんが、たくさんのエディターが使えます。また、 これだけは保証されていることですが、全ての UNIX には <tt/vi/ エディター がついています - 忘れないでくださいね。でも システム管理者がもっといいエディターをインストールしてるに違いないけど。 おそらく、最もポピュラーなエディターは <tt/emacs/ であり、多少は <tt/EDT/ をエミュレートできます。<tt/jed/ も <tt/EDT/ をエミュレートでき るエディターです。 <!-- These two editors are particularly useful for editing program sources, since they have two features unknown to <tt/EDT/: syntax hilighting and automatic indentation. Moreover, you can compile your programs from within the editor (command <tt/ESC-X compile/); in case of a syntax error, the cursor will be positioned on the offending line. I bet that you'll never want to use the true blue <tt/EDT/ again. --> これら二つのエディターは、、<tt/EDT/ にはない二つの特徴 * 文法強調機能と自動インデント機能 * があるので、プログラムソースの編集には大いに有用です。さらに、 エディター上でコンパイルできて(コマンドは <tt/ESC-X compile/ )、文法エラー のある行にカーソルを飛ばします。さえない <tt/EDT/ を再び使う気にはならないと断言で きます。 <!-- If you have <tt/emacs/: start it, then type <tt/ESC-X edt-emulation-on/. Pressing ALT--X or ESC-X is <tt/emacs/' way of issuing commands, like <tt/EDT/'s CTRL--Z. From now on, <tt/emacs/ acts like <tt/EDT/ apart from a few commands. Differences: --> <tt/emacs/ を立ち上げて、<tt/ESC-X edt-emulation-on/ とタイプして見てく ださい。 ALT-X や ESC-X は <tt/emacs/ でコマンドを実行する時に押します。 <tt/EDT/ の CTRL-Z のようなものです。<tt/emacs/ と <tt/EDT/ のコマンドの 違いを少し挙げてみましょう。 <itemize> <!-- <item> <em/don't/ press CTRL--Z to issue commands (if you did, you stopped <tt/emacs/. Type <tt/fg/ to resume it); <item> there's an extensive on-line help. Press CTRL-H ?, or CTRL-H T to start a tutorial; <item> to save a file, press CTRL-X CTRL-S; <item> to exit, press CTRL-X CTRL-C; <item> to insert a new file in a buffer, press CTRL-X CTRL-F, then CTRL-X B to switch among buffers. --> <item>コマンドを実行しようとして、CTRL-Z を<em/押さないように/ (もしやっ ちゃったら、<tt/emacs/ は停止します。でも <tt/fg/ で復帰します)。 <item>オンラインヘルプを拡張したものもあります。CTRL-H ? か CTRL-H T を 押してみてください。チュートリアルが始まります。 <item>ファイルの保存は CTRL-X CTRL-S です。 <item>終了は CTRL-X CTRL-C です。 <item>新規にファイルを編集するなら CTRL-X CTRL-F で、CTRL-X B で編集バッ ファを切替えることができます。 </itemize> <!-- If you have <tt/jed/: ask your sysadm to configure <tt/jed/ properly. Emulation is already on when you start it; use the normal keypad keys, and press CTRL--H CTRL--H or CTRL-? to get help. Commands are issued in the same way as <tt/emacs/'. In addition, there are some handy key bindings missing in the original <tt/EDT/; key bindings can also be tailored to your own taste. Ask your sysadm. --> もし <tt/jed/ があるなら (システム管理者にちゃんと設定されているか尋 ねてください)、立ち上げたときにエミュレーションが働くようになっている 筈です。普通にキーパッドが使えて、CTRL-H CTRL-P か CTRL-? でヘルプが表示 されると思います。<tt/emacs/ と同じ方法でコマンドを実行でき、加えて、 オリジナルの <tt/EDT/ にはない、あなた好みのキーバインドにすることも可能 です。細かいことはシステム管理者に尋ねてください。 <!-- In alternative, you may use another editor with a completely different interface. <tt/emacs/ in native mode is an obvious choice; another popular editor is <tt/joe/, which can emulate other editors like <tt/emacs/ itself (being even easier to use) or the DOS editor. Invoke the editor as <tt/jmacs/ or <tt/jstar/ and press, respectively, CTRL-X H or CTRL-J to get online help. <tt/emacs/ and <tt/jed/ are <em/much/ more powerful than good ol' <tt/EDT/. --> これらの代わりに、全く違った操作性をもつエディターを使用してもいいのです。 素のままの <tt/emacs/ も一つの選択肢です。ポピュラーなエディターである <tt/joe/ は <tt/emacs/ (幾分操作が簡単になっている)や DOS エディターなどをエミュレートします。<tt/jmacs/ か <tt/jstar/ を呼び出し、 CTRL-X H か CTRL-J でヘルプを表示させることもできます。<tt/emacs/ や <tt/jed/ は古き良き <tt/EDT/ <em/より/強力です。 <sect><!-- TeXing <label id="TeXing">-->TeX <label id="TeXing"> <p> <!-- TeX and LaTeX are identical to their VMS counterparts---only quicker :-), but the tools to handle the <tt/.dvi/ and <tt/.ps/ files are superior: --> TeX と LaTeX はどちらも VMS 版と同じです - 速いところは違いますよ :-) 。 でも <tt/.dvi/ や <tt/.ps/ ファイルを扱うツールには優れたものがあります。 <itemize> <!-- <item> to run a TeX file through TeX, do as usual: <tt/tex file.tex/; <item> to turn a <tt/.dvi/ file into a <tt/.ps/ file, type <tt/dvips -o filename.ps filename.dvi/; <item> to visualize a <tt/.dvi/ file, type within an X session: <tt/xdvi filename.dvi &/. Click on the page to magnify. This program is smart: if you edit and run TeX producing newer versions of the <tt/.dvi/ file, <tt/xdvi/ will update it automatically; <item> to visualize a <tt/.ps/ file, type within an X session: <tt/ghostview filename.ps &/. Click on the page to magnify. The whole document or selected pages can be printed. A newer and better program is <tt/gv/. <item> to print the <tt/.ps/: usually the command <tt/lpr mypaper.ps/ will do, but if the PostScript printer is called, say, `ps' (ask your sysadm) you'll do: <tt/lpr -Pps mypaper.ps/. For more information about print queues, go to Section <ref id="Print Queues" name="Print Queues">. --> <item>TeX から TeX ファイルを起動するには、(あいも変わらず) <tt/tex file.tex/ のようにします。 <item><tt/.dvi/ ファイルを <tt/.ps/ ファイルに変換するには、<tt/dvips -o filename.ps filename.dvi/ とします。 <item>X 環境で <tt/.dvi/ を画面に表示するには、<tt/xdvi filename.dvi &/ とします。クリックすれば拡大表示します。<tt/xdvi/ のお利口なところは、TeX ファイルをエディターで変更して TeX を通してやれば、自動的に <tt/.dvi/ ファイルを新しいものに表示しなおす点です。 <item>ページ全体か、選択部分を印刷するのに最適なツールは、現在のところ <tt/gv/ です。 <item><tt/.ps/ ファイルを印刷するには、<tt/lpr mypaper.ps/ コマンドを使 います。もしポストスクリプトプリンター(かどうかはシステム管理者に聞いて ください)なら <tt/lpr -Pps mypaper.ps/ とします。プリンターキューの詳し い情報は、<ref id="Print Queues" name="プリンターキュー">を御覧ください。 </itemize> <sect><!-- Programming <label id="Programming">-->プログラミング <label id="Programming"> <p> <!-- Programming under Linux is <em/much/ better: there are lots of tools that make programming easier and quicker. For instance, the drudgery of editing--saving--exiting--compiling--re-editing can be cut short by using editors like <tt/emacs/ or <tt/jed/, as seen above. --> Linux はプログラムを作るには<em/良い/環境だと思います。プログラムを簡単 に素早く作成するための多くのツールが揃っています。例えば、編集 - 保存 - コンパイル - 再編集といった単調な作業にあくせくしなくても、 前述の <tt/emacs/ や <tt/jed/ などのエディターを使えば迅速に作業できます。 <sect1><!-- Fortran--> Fortran <p> <!-- Not substantial differences here, but note that at the time of writing the available (free) compilers are not 100% compatible with VMS'; expect some minor quirks. (It's actually the VMS compiler which has non-standard extensions.) See <tt>/usr/doc/g77/DOC</tt> or <tt>/usr/doc/f2c/f2c.ps</tt> for details. --> あまり大差ないのですが、この文書を書いている時点で利用できる(フリー)コン パイラーと VMS とでは完全互換ではありません - 幾つかのマイナーな警告の発生が予想されます( VMS のコンパイラは非標準の拡張を行なっているのです)。 詳細は <tt>/usr/doc/g77/DOC</tt> か <tt>/usr/doc/f2c/f2c.ps</tt> を御覧ください。 <!-- Your sysadm has installed a native compiler called <tt/g77/ (good but, as of version 0.5.21, still not perfectly compatible with DEC Fortran) or possibly the Fortran to C translator, <tt/f2c/, and one of the front-ends that make it mimic a native compiler. In my experience, the package <tt/yaf77/ is the one that provides best results. --> システム管理者は、<tt/g77/ ネイティブコンパイラ(すぐれものですが、0.5.21 版ではまだ DEC Fortran と互換性はありません)か、Fortran から C へのトラ ンスレータである <tt/f2c/ (疑似ネイティブコンパイラのフロントエンド) の どちらかをインストールしているはずです。私の経験では、<tt/yaf77/ が最も 優れた結果を出すパッケージの一つだと思います。 <!-- To compile a Fortran program with <tt/g77/, edit the source, save it with extension <tt/.f/, then do: --> <tt/g77/ で Fortran プログラムをコンパイルするには、ソースを編集して、 <tt/.f/ 拡張子をつけて保存した後、 <tscreen><verb> $ g77 myprog.f </verb></tscreen> を実行します。 <!-- which creates by default an executable called <tt/a.out/ (you don't have to link anything). To give the executable a different name and do some optimisation: --> デフォルトでは、<tt/a.out/ の名で実行ファイルが生成されます(他に何もリ ンクしなければ)。異なった実行ファイル名にして、最適化オプションをつけるに は、 <tscreen><verb> $ g77 -O2 -o myprog myprog.f </verb></tscreen> とします。 <!-- Beware of optimisations! Ask your sysadm to read the documentation that comes with the compiler and tell you if there are any problems. To compile a subroutine: --> 最適化には注意! システム管理者にコンパイラについてのドキュメントを一読してもらい、問題がないかどうか確認してください。 サブルーチンをコンパイルするには、 <tscreen><verb> $ g77 -c mysub.f </verb></tscreen> <!-- This creates a file <tt/mysub.o/. To link this subroutine to a program, you'll do --> とすれば、<tt/mysub.o/ が生成されます。このサブルーチンをリンクするには、 <tscreen><verb> $ g77 -o myprog myprog.f mysub.o </verb></tscreen> としてください。 <!-- If you have many external subroutines and you want to make a library, do the following: --> たくさんのサブルーチンがあって、ライブラリにまとめたいなら、 <tscreen><verb> $ cd subroutines/ $ cat *f >mylib.f ; g77 -c mylib.f </verb></tscreen> のようにします。 <!-- This will create <tt/mylib.o/ that you can link to your programs. Finally, to link an external library called, say, <tt/libdummy.so/: --> これであなたのプログラムにリンク可能な <tt/mylib.o/ が生成されます。 最後に、外部ライブラリ <tt/libdummy.so/ をリンクするには、 <tscreen><verb> $ g77 -o myprog myprog.f -ldummy </verb></tscreen> とします。 <!-- If you have <tt/f2c/, you only have to use <tt/f77/ or <tt/fort77/ instead of <tt/g77/. Another useful programming tool is <tt/make/, described below. --> <tt/f2c/ をお持ちなら、<tt/g77/ の替わりに <tt/f77/ か <tt/fort77/ のみを使うことでしょう。 以下では、さらに使いやすいプログラミングツール <tt/make/ を紹介します。 <sect1><!-- Using <tt/make/--> <tt/make/ の使いかた <p> <!-- The utility <tt/make/ is a tool to handle the compilation of programs that are split into several source files. The VMS counterparts are <tt>MMS</tt> and <tt>MMK</tt>, which have a different syntax. --> ユーティリティ <tt/make/ は、複数のソースファイルに分かれたプログラムの コンパイルに使うツールです。VMS での <tt>MMS</tt> と <tt>MMK</tt> に相当しますが、構文は異なっています。 <!-- Let's suppose you have source files containing your routines, <tt/file_1.f, file_2.f, file_3.f/, and a source file of the main program that uses the routines, <tt/myprog.f/. If you compile your program manually, whenever you modify one of the source files you have to figure out which file depends on which, which file to recompile first, and so on. --> ソースファイル <tt/file_1.f , file_2.f , file_3.f/ と メインプログラムのソー ス <tt/myprog.f/ があるとしましょう。これらのプログラムを手作業でコンパ イルするとなると、ソースファイルのどれか一つを変更した場合、それと依存関 係にあるファイルがどれかを考えて、一つ一つ再コンパイルしなければなりません。 <!-- Instead of getting mad, you can write a `makefile'. This is a text file containing the dependencies between your sources: when one is modified, only the ones that depend on the modified file will be recompiled. In our example, you'd write a makefile like this: --> 頭が変になる前に「 makefile 」を作るべきです。これはソースファイル相互の 依存関係を記述したテキストファイルです - ソースが変更されたら、変更されたファ イルに依存するファイルだけを再コンパイルしてくれます。 我々の例では、こんな風に makefile を作ります。 <!-- <code> # This is makefile # Press the <TAB> key where you see <TAB>! # It's important: don't use spaces instead. myprog: myprog.o file_1.o file_2.o file_3.o <TAB>g77 -o myprog myprog.o file_1.o file_2.o file_3.o # myprog depends on four object files myprog.o: myprog.f <TAB>g77 -c myprog.f # myprog.o depends on its source file file_1.o: file_1.f <TAB>g77 -c file_1.f # file_1.o depends on its source file file_2.o: file_2.f file_1.o <TAB>g77 -c file_2.f file_1.o # file_2.o depends on its source file and an object file file_3.o: file_3.f file_2.o <TAB>g77 -c file_3.f file_2.o # file_3.o depends on its source file and an object file # end of makefile. </code> --> <code> # makefile の例です。 # <TAB> と書いてあるところでは <TAB> キーを押してください! # 大切なことです:スペースはダメですよ。 myprog: myprog.o file_1.o file_2.o file_3.o <TAB>g77 -o myprog myprog.o file_1.o file_2.o file_3.o # myprog は四つのオブジェクトファイルに依存します。 myprog.o: myprog.f <TAB>g77 -c myprog.f # myprog.o はそれ自身のソースファイルに依存します。 file_1.o: file_1.f <TAB>g77 -c file_1.f # file_1.o はそれ自身のソースファイルに依存します。 file_2.o: file_2.f file_1.o <TAB>g77 -c file_2.f file_1.o # file_2.o はそれ自身のソースファイルとオブジェクトファイルに依存します。 file_3.o: file_3.f file_2.o <TAB>g77 -c file_3.f file_2.o # file_3.o はそれ自身のソースファイルとオブジェクトファイルに依存します。 # end of makefile. </code> <!-- Save this file as <tt/Makefile/ and type <tt/make/ to compile your program; alternatively, save it as <tt/myprog.mak/ and type <tt/make -f myprog.mak/. And of course, RMP. --> これを <tt/Makefile/ の名で保存し、<tt/make/ とタイプすればコンパイルできます。 代わりに、ファイル名を <tt/myprog.mak/ として保存したなら、<tt/make -f myprog.mak/ でコンパイルできます。もちろん RMP(訳注:man ページを参照の 意)。 <sect1><!-- Shell Scripts--> シェルスクリプト <p> <!-- Shell scripts are the equivalent of VMS' command files, and allow for very powerful constructs. To write a script, all you have to do is write a standard ASCII file containing the commands, save it, then make it executable with the command <tt/chmod +x <scriptfile>/. To execute it, type its name. --> シェルスクリプトは VMS コマンドファイルと同じものですが、より強力な構文を備えています。 スクリプトを書くには、しなければならないこと全てをコマンドで記述して、標準 の ASCII ファイルに保存します。実行できるようにするために、<tt/chmod +x <スクリプトファイル名>/ コマンドを実行しておいてください。 スクリプトファイル名をタイプすれば実行できます。 <!-- Writing scripts under <tt/bash/ is such a vast subject it would require a book by itself, and I will not delve into the topic any further. I'll just give you a more-or-less comprehensive and (hopefully) useful example you can extract some basic rules from. --> <tt/bash/ でスクリプトを書くには、広範な機能を網羅した解説本が必要になる ので、あまり深くは言及しません。ここでは多少包括的で、(望むらくは)役に立つサンプルから幾つかの基本的なルールを読みとってください。 <!--EXAMPLE: sample.sh--> サンプル:sample.sh <!-- <code> #!/bin/sh # sample.sh # I am a comment # don't change the first line, it must be there echo "This system is: `uname -a`" # use the output of the command echo "My name is $0" # built-in variables echo "You gave me the following $# parameters: "$* echo "First parameter is: "$1 echo -n "What's your name? " ; read your_name echo notice the difference: "hi $your_name" # quoting with " echo notice the difference: 'hi $your_name' # quoting with ' DIRS=0 ; FILES=0 for file in `ls .` ; do if [ -d ${file} ] ; then # if file is a directory DIRS=`expr $DIRS + 1` # this means DIRS = DIRS + 1 elif [ -f ${file} ] ; then FILES=`expr $FILES + 1` fi case ${file} in *.gif|*jpg) echo "${file}: graphic file" ;; *.txt|*.tex) echo "${file}: text file" ;; *.c|*.f|*.for) echo "${file}: source file" ;; *) echo "${file}: generic file" ;; esac done echo "there are ${DIRS} directories and ${FILES} files" ls | grep "ZxY--!!!WKW" if [ $? != 0 ] ; then # exit code of last command echo "ZxY--!!!WKW not found" fi echo "enough... type 'man bash' if you want more info." </code> --> <code> #!/bin/sh # sample.sh # コメント行です。 # 最初の行は消さないで、必ずそこになければなりせん。 echo "This system is: `uname -a`" # use the output of the commad echo "My name is $0" # built-in variables echo "You gave me the following $# parameters: "$* echo "First parameter is: "$1 echo -n "What's your name? " ; read your_name echo notice the difference: "hi $your_name" # quoting with " echo notice the difference: 'hi $your_name' # quoting with ' DIRS=0 ; FILES=0 for file in `ls .` ; do if [ -d ${file} ] ; then # if file is a directory DIRS=`expr $DIRS + 1` # this means DIRS = DIRS + 1 elif [ -f ${file} ] ; then FILES=`expr $FILES + 1` fi case ${file} in *.gif|*jpg) echo "${file}: graphic file" ;; *.txt|*.tex) echo "${file}: text file" ;; *.c|*.f|*.for) echo "${file}: source file" ;; *) echo "${file}: generic file" ;; esac done echo "there are ${DIRS} directories and ${FILES} files" ls | grep "ZxY--!!!WKW" if [ $? != 0 ] ; then # exit code of last command echo "ZxY--!!!WKW not found" fi echo "enough... type 'man bash' if you want more info." </code> <sect1> C <label id="C"> <p> <!-- Linux is an excellent environment to program in C. Taken for granted that you know C, here are a couple of guidelines. To compile your standard <tt/hello.c/ you'll use the <tt/gcc/ compiler, which comes as part of Linux and has the same syntax as <tt/g77/: --> Linux は、C でプログラムを開発するにはすばらしい環境です。C につ いてはご存知だと思いますので、ここではガイドラインについて述べましょう。 定番の <tt/hello.c/ を Linux の一部とも言える <tt/gcc/ でコンパイルするには、 <tt/g77/ と同じ構文を使います。 <tscreen><verb> $ gcc -O2 -o hello hello.c </verb></tscreen> <!-- To link a library to a program, add the switch <tt>-l<libname></tt>. For example, to link the math library and optimize do --> プログラムにライブラリをリンクするには、スイッチ <tt>-l<libname></tt> を加えます。例えば、数学ライブラリと最適 化オプションを付けてリンクするには、 <tscreen><verb> $ gcc -O2 -o mathprog mathprog.c -lm </verb></tscreen> のようにします。 <!-- (The <tt>-l<libname></tt> switch forces <tt/gcc/ to link the library <tt>/usr/lib/lib<libname>.a</tt>; so <tt/-lm/ links <tt>/usr/lib/libm.a</tt>). --> ( <tt>-l<libname></tt> スイッチは、 <tt>/usr/lib/lib<libname>.a</tt> を一緒にリンクしろということで、 従って <tt/-lm/ は <tt>/usr/lib/libm.a</tt> と同じ意味になります)。 <!-- When your program is made of several source files, you'll need to use the utility <tt/make/ described above. Just use <tt/gcc/ and C source files in the makefile. You can invoke some help about the C functions, that are covered by man pages, section 3; for example, --> プログラムが複数のファイルから構成される場合は、前述したように <tt/make/ ユーティリティが必要となるでしょう。当然、makefile に記述されたソー スファイルと <tt/gcc/ を使います。 man ページのセクション 3 に記載されている C の関数についてのヘルプを呼び 出すことができます。例えば次のようにします。 <tscreen><verb> $ man 3 printf </verb></tscreen> <!-- There are lots of libraries available out there; among the first you'll want to use are <tt/ncurses/, to handle text mode effects, and <tt/svgalib/, to do graphics. --> 使用可能なライブラリは山ほどありますが、中でも、テキストモードで各種の効 果を出すための <tt/ncurses/ と、グラフィックス描画用の <tt/svgalib/ など を最初に使いたいのではないですか。 <sect><!-- Graphics-->グラフィックス <label id="Graphics"> <p> <!-- Among the scores of graphic packages available, <tt/gnuplot/ stands out for its power and ease of use. Go to X and type <tt/gnuplot/, and have two sample data files ready: <tt/2D-data.dat/ (two data per line), and <tt/3D-data.dat/ (three data per line). --> 数ある利用可能なグラフィックスパッケージの中でも <tt/gnuplot/ は、その強力な機能と使いやすさで突出しています。X を起動して、<tt/gnuplot/ とタイプしてみてく ださい。あらかじめ、二つのファイル - <tt/2D-data.dat/ (一行当たり二つの データ)と <tt/3D-data.dat/ (一行当たり三つのデータ)- が準備されているものとします。 <!--Examples of 2-D graphs:-->2 次元グラフの例: <tscreen><verb> gnuplot> set title "my first graph" gnuplot> plot '2D-data.dat' gnuplot> plot '2D-data.dat' with linespoints gnuplot> plot '2D-data.dat', sin(x) gnuplot> plot [-5:10] '2D-data.dat' </verb></tscreen> <!-- Example of 3-D graphs (each `row' of X values is followed by a blank line): --> 3 次元グラフの例 (X の各行の値は空白行です): <tscreen><verb> gnuplot> set parametric ; set hidden3d ; set contour gnuplot> splot '3D-data.dat' using 1:2:3 with linespoints </verb></tscreen> <!-- A single-column datafile (e.g., a time series) can also be plotted as a 2-D graph: --> 単一列のデータファイル(例えば、時系列など)は 2-D グラフとしてプロットで きます。 <tscreen><verb> gnuplot> plot [-5:15] '2D-data-1col.dat' with linespoints </verb></tscreen> <!-- or as a 3-D graph (blank lines in the datafile, as above): --> あるいは 3-D グラフとしても(上記のようにデータファイルに空白行を含めるこ とで)プロット可能です。 <tscreen><verb> gnuplot> set noparametric ; set hidden3d gnuplot> splot '3D-data-1col.dat' using 1 with linespoints </verb></tscreen> <!-- To print a graph: if the command to print on your Postscript printer is <tt/lpr -Pps file.ps/, issue: --> グラフを印刷する:ポストスクリプトプリンタを使っているのなら、 <tt/lpr -Pps file.ps/ とします。 <tscreen><verb> gnuplot> set term post gnuplot> set out '| lpr -Pps' gnuplot> replot </verb></tscreen> <!-- then type <tt/set term x11/ to restore. Don't get confused---the last print will come out only when you quit <tt/gnuplot/. For more info, type <tt/help/ or see the examples in directory <tt>/usr/lib/gnuplot/demos/</tt>, if you have it. --> もとに戻すには <tt/set term x11/ とタイプします。混乱しないでくださいね。 最後の印刷物は <tt/gnuplot/ を終了した時だけ印刷されるでしょう。 より詳しい情報は、<tt/help/ とタイプするか、 <tt>/usr/lib/gnuplot/demos/</tt> ディレクトリを御覧ください。 <sect><!-- Mail and Internet Tools --> メールとインターネットツール <label id="Mail and Internet Tools"> <p> <!-- Since Internet was born on UNIX machines, you find plenty of nice and easy-to-use applications under Linux. Here are just some: --> インターネットは UNIX 機で誕生したものなので、Linux 用にも素敵で使いやすいアプリケーションが豊富に提供されてきました。これらはほんの一部です: <itemize> <!-- <item> <bf/Mail/: use <tt/elm/ or <tt/pine/ to handle your email; both programs have on-line help. For short messages, you could use <tt/mail/, as in <tt/mail -s "hello mate" user@somewhere < msg.txt/. You may like programs like <tt/xmail/ or some such. <item> <bf/Newsgroups/: use <tt/tin/ or <tt/slrn/, both very intuitive and self-explanatory. <item> <bf/ftp/: apart from the usual character-based <tt/ftp/, ask your sysadm to install the full-screen <tt/ncftp/ or a graphical ftp client like <tt/xftp/. <item> <bf/WWW/: the ubiquitous <tt/netscape/, or <tt/xmosaic/, <tt/chimera/, and <tt/arena/ are graphical web browsers; a character-based one is <tt/lynx/, quick and effective. --> <item> <bf/Mail/ : 電子メールの送受信には <tt/elm/ か <tt/pine/ を使いま す - 両方ともオンラインヘルプがあります。短いメッセージには、 <tt/mail/ を使うといいでしょう。 <tt/mail -s "hello mate" user@somewhere < msg.txt/ などとします。 多分、<tt/xmail/ かそのようなプログラムを好むと思います。 <item> <bf/Newsgroups/ : <tt/tin/ と <tt/slrn/ はどちらも、直観的で自明な操作性を提供します。 <item> <bf/ftp/ : お決まりのキャラクタベースの <tt/ftp/ は別にして、 フルスクリーン版の <tt/ncftp/ や <tt/xftp/ のようなグラフィカルな ftp ク ライアントがインストールされていないか、システム管理者に尋ねてみてください。 <item> <bf/WWW/ : よくみかける <tt/netscape/ あるいは <tt/xmosaic/ 、<tt/chimera/ それに <tt/arena/ はグラフィカルな web ブラウザです。 キャラクタベースなら <tt/lynx/ があります。こっちの方が速いし、効果的です。 </itemize> 訳注:以下に日本語利用可能なツールの名前と url を列挙しておきます。 mail リーダ <itemize> <item>mew <url url="http://www.mew.org/index.html"> <item>mutt-ja <url url="http://kondara.sdri.co.jp/~kikutani/mutt.html"> <item>cmail <url url="http://www.st.rim.or.jp/~fuku/cmail/index.html"> <item>MH-JP <url url="http://www.chem.eng.himeji-tech.ac.jp/~hayashi/internet/mh-plus.html"> <item>wonderlust <url url="http://www.gohome.org/wl/index.html" > </itemize> news リーダ <itemize> <item>mnews <url url="ftp://ftp.mei.co.jp/free/news/readers/" > <item>semi-gnus (兼 MUA ) <url url="http://www.mdcnet.co.jp/~keiichi/semi-gnus-faq-ja.shtml"> <item>t-gnus <url url="http://www.jpl.org/elips/INSTALL-SEMI-ja.html"> </itemize> web ブラウザ <itemize> <item>lynx <url url="http://lynx.browser.org/index.html" > <item>w3m <url url="http://ei5nazha.yz.yamagata-u.ac.jp/~aito/w3m/"> <item>w3-mode on xemacs <url url="http://www.cs.indiana.edu/elisp/w3/docs.html"> <item>mmm <url url="http://pauillac.inria.fr/~furuse/jmmm/030/index.html" > </itemize> <sect><!-- Advanced Topics -->高度な話題<label id="Advanced Topics"> <p> <!-- Here the game gets tough. Learn these features, then you'll be ready to say that you `know something about Linux' ;-) --> この章は少し手ごわい内容にふれます。ここで述べる特徴を学べば、 「 Linux について何かを知り得た」と言えると思いますよ。 <sect1><!-- Permissions and Ownership-->パーミッションと所有権 <label id="Permissions"> <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: --> ファイルとディレクトリには、VMS と同じようにパーミッション(保護)と所有権が 存在します。許可されていなければ、プログラムを走らせたり、ファイルを 修正したり、あるいはディレクトリにアクセスすることもできません。ファイル があなたの権限下にないからです。つぎの例を見てみましょう。 <tscreen><verb> $ ls -l /bin/ls -rwxr-xr-x 1 root bin 27281 Aug 15 1995 /bin/ls* </verb></tscreen> <!-- The first field shows the permissions of the file <tt/ls/ (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. --> 最初のフィールドは、ファイル <tt/ls/ のパーミッションを表示しています(オーナは root でグループは bin)。所有権には オーナ (owner) 、グループ (group) 、その他 (other) の3種類があります (VMS の owner,group,world に似てますね)。 パーミッションには 読み取り許可 (read) 、書き込み許可 (write 、削除許可も含む)、 実行許可 (execute) の3種類があります。 <!-- > From left to right, <tt/-/ is the file type (<tt/-/ = ordinary file, <tt/d/ = directory, <tt/l/ = link, etc); <tt/rwx/ are the permissions for the file owner (read, write, execute); <tt/r-x/ are the permissions for the group of the file owner (read, execute); <tt/r-x/ are the permissions for all other users (read, execute). To change a file's permissions: --> 左から右に見ていきましょう。<tt/-/ はファイルの種類です( <tt/-/ は一般ファ イル、<tt/d/ はディレクトリ、<tt/l/ はリンク等を示します)。 <tt/rwx/ はファイルの所有者に対するパーミッション( read, write, execute )で す。次の <tt/r-x/ はファイル所有者の属するグループに対するパーミッション(read, execute) で、最後の <tt/r-x/ はそれ以外のユーザに対するパーミッションを(read, execute)を表しています。 ファイルのパーミッションを変更するには、 <tscreen><verb> $ chmod <whoXperm> <file> </verb></tscreen> <!-- where who is <tt/u/ (user, that is owner), <tt/g/ (group), <tt/o/ (other), X is either <tt/+/ or <tt/-/, perm is <tt/r/ (read), <tt/w/ (write), or <tt/x/ (execute). Examples: --> とし、who には <tt/u/ (user、オーナのこと)、<tt/g/ (group) あるいは <tt/o/ (other) を指定し、X には <tt/+/ か <tt/-/ のどちらかを指定します。また、 perm には <tt/r/ (read), <tt/w/ (write), あるいは <tt/x/ (execute) を指 定します。例えば、 <tscreen><verb> $ chmod u+x file </verb></tscreen> <!-- this sets the execute permission for the file owner. Shortcut: <tt/chmod +x file/. --> は、ファイルの所有者に実行許可を与えるもので 、<tt/chmod +x file/ と短縮できます。 <tscreen><verb> $ chmod go-wx file </verb></tscreen> <!-- this removes write and execute permission for everyone except the owner. --> これは、ファイルの所有者以外から書き込み許可と実行許可を取り消します。 <tscreen><verb> $ chmod ugo+rwx file </verb></tscreen> <!-- this gives everyone read, write, and execute permission. --> これは全てのユーザに読み込み許可、書き込み許可、実行許可を与えています。 <!-- A shorter way to refer to permissions is with numbers: <tt/rwxr-xr-x/ can be expressed as 755 (every letter corresponds to a bit: <tt/---/ is 0, <tt/--x/ is 1, <tt/-w-/ is 2...). --> パーミッションは、短縮して数字で示すことがあります。<tt/rwxr-xr-x/ は手っ取り早く、755 と指定できます(各文字はビットに対応します。<tt/---/ は0、<tt/--x/ は 1、<tt/-w-/ は 2 などのように)。 <!-- For a directory, <tt/rx/ means that you can <tt/cd/ to that directory, and <tt/w/ 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. To change a file's owner: --> ディレクトリに対する <tt/rx/ は、 <tt/cd/ を使ってそのディレクトリに移 動できることを意味し、<tt/w/ はディレクトリ内のファイルの削除(もちろん、 ファイルのパーミッションに従いますが)や、そのディレクトリ自体を削除できることを意味します。これらのことは、ほんの一部です - RMP。 ファイルの所有者を変更するには: <tscreen><verb> $ chown username file </verb></tscreen> <!--To sum up, a table:-->要約すれば、次の表になります。 <tscreen><verb> 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/ </verb></tscreen> <sect1><!-- Multitasking: Processes and Jobs-->マルチタスク:プロセスとジョブ <label id="Multitasking"> <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: --> プログラムの実行についてさらに説明しましょう。これまで使ってきた「バッチキュー」は Linux には存在せず、違った方法で扱われます。再び、典型的なコマンドラインを示します。 <tscreen><verb> $ command -s1 -s2 ... -sn par1 par2 ... parn < input > output & </verb></tscreen> <!-- where <tt>-s1</tt>, ..., <tt>-sn</tt> are the program switches, <tt/par1/, ..., <tt/parn/ are the program parameters. Now let's see how multitasking works. Programs, running in foreground or background, are called `processes'. --> <tt>-s1</tt>, ..., <tt>-sn</tt> はプログラムスイッチで、<tt/par1/, ..., <tt/parn/ はプログラムに渡される引数です。 マルチタスク処理がどのように働くか見ていきましょう。フォアグランドやバッ クグランドで動くプログラムを「プロセス」と呼びます。 <itemize> <!-- <item> To launch a process in background: --> <item>プロセスをバックグランドで起動するには: <tscreen><verb> $ progname [-switches] [parameters] [< input] [> output] & [1] 234 </verb></tscreen> <!-- 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. --> シェルはプロセスの「ジョブNo」(最初の数字です:以下を参照)とプロセスの PID (プロセスID) を通知します。各プロセスは PID で一意に識別できます。 <!-- <item> To see how many processes there are: --> <item>プロセスがいくつ動いているか調べるには: <tscreen><verb> $ ps -ax </verb></tscreen> <!-- This will output a list of currently running processes. --> 今現在実行中プロセスの一覧を出力します。 <item><!-- To kill a process:--> プロセスを終了するには: <tscreen><verb> $ kill <PID> </verb></tscreen> <!-- 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: --> プロセスを正規の手段で終了させる方法が判らなくても、あなたはプロセスを終 了させる必要があると思います ... ;-) 時々、以下のどちらかでのみ終了させる場合があるでしょう(訳注:数字はシグナル番号で、9 は kill シグナル、15 は終了シグナルとして定義されています。 killall なら プロセス名を指定して終了させることができます)。 <tscreen><verb> $ kill -15 <PID> $ kill -9 <PID> </verb></tscreen> </itemize> <!-- 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'. --> 付け加えると、シェルはプロセスの終了や一時停止、また、プロセスをバックグ ランドへ移したり、フォアグランドへ戻したりすることができます。このような 環境下で、プロセスを「ジョブ」と呼びます。 <itemize> <!-- <item> To see how many jobs there are: --> <item> ジョブがいくつあるか調べるには: <tscreen><verb> $ jobs </verb></tscreen> <!-- jobs are identified by the numbers the shell gives them, not by their PID. --> ジョブはシェルによって採番された番号で識別され、PID では識別されません。 <!-- <item> To stop a process running in foreground: --> <item>フォアグランドプロセスを終了するには: <tscreen><verb> $ CTRL-C </verb></tscreen> <!--(it doesn't always work)--> (いつも効果があるとは限りません) <!-- <item> To suspend a process running in foreground: --> <item>フォアグランドプロセスを一時停止するには: <tscreen><verb> $ CTRL-Z </verb></tscreen> <!--(ditto)--> (同上) <!-- <item> To send a suspended process into background (it becomes a job): --> <item>停止状態にあるプロセスをバックグランドに移すには(それはジョブとな る): <tscreen><verb> $ bg <job> </verb></tscreen> <!-- <item> To bring a job to foreground: --> <item>ジョブをフォアグランドに戻すには: <tscreen><verb> $ fg <job> </verb></tscreen> <!-- <item> To kill a job: --> <item>ジョブを終らせるには: <tscreen><verb> $ kill <%job> </verb></tscreen> </itemize> <sect1><!-- Files, Revisited--> 再度、ファイルについて <p> <!-- More information about files. --> ファイルについてのさらに詳しい情報です。 <itemize> <!-- <item> <bf/stdin, stdout, stderr/: under UNIX, every system component is treated as if it were a file. Commands and programs get their input from a `file' called <tt/stdin/ (standard input; usually, the keyboard), put their output on a `file' called <tt/stdout/ (usually, the screen), and error messages go to a `file' called <tt/stderr/ (usually, the screen). Using <tt/</ and <tt/>/ you redirect input and output to a different file. Moreover, <tt/>>/ appends the output to a file instead of overwriting it; <tt/2>/ redirects error messages (stderr); 2>&1 redirects stderr to stdout, while 1>&2 redirects stdout to stderr. There's a `black hole' called <tt>/dev/null</tt>: everything redirected to it disappears; --> <item><bf/stdin, stdout, stderr/: UNIX において、全てのシステムコンポー ネントはファイルとして取り扱います。コマンドやプログラムは、 <tt/stdin/ (標準入力 - 通常はキーボード)と呼ぶ「ファイル」から入力を得 て、<tt/stdout/ (標準出力 - 通常は画面)と呼ぶ「ファイル」へ出力し、エラー メッセージは <tt/stderr/ (通常は画面)と呼ぶ「ファイル」へ出力します。 <tt/</ と <tt/>/ を使えば、入出力を別なファイルにリダイレクトできま す。さらに、<tt/>>/ は上書きする代りにファイルを追記します。 <tt/2>/ はエラーメッセージ( stderr )をリダイレクトします。2>&1 は stderr を stdout にリダイレクトし、1>&2 は stdout を stderr に リダイレクトします。<tt>/dev/null</tt> はブラックホールと呼ばれ、ここに リダイレクトすると、どんなものも消えてしまいます。 <!-- <item> <bf/wildcards/: '<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/%/' becomes '<tt/?/'. There is another wildcard: the <tt/[]/. Usage: <tt/[abc]*/ matches files starting with a, b, c; <tt/*[I-N,1,2,3]/ matches files ending with I, J, K, L, M, N, 1, 2, 3; --> <item><bf/wildcards/: '<tt/*/' はほぼ同じ働きです。用法: * は、隠しファ イルを除く全てのファイルにマッチします。.* は全ての隠しファイルにマッチ します。*.* は文字列中に . を含む文字にマッチします。p*r は「peter」や 「piper」にマッチします。*c* は「picked」と「peck」にマッチします。 「<tt/%/」は「<tt/?/」になります(訳注:一文字のみにマッチ)。ワイ ルドカードとして他に、<tt/[]/ があります。用法:<tt/[abc]*/ は a か b か c で始まる文字列にマッチします。<tt/*[I-N,1,2,3]/ は最後が I, J, K, L, M, N, 1, 2, 3 で終るファイルにマッチします。 <!-- <item> <tt/mv/ ( <tt/RENAME/ ) doesn't work for multiple files; that is, <tt/mv *.xxx *.yyy/ won't work; <item> use <tt/cp -i/ and <tt/mv -i/ to be warned when a file is going to be overwritten. --> <item> <tt/mv/ ( <tt/RENAME/ ) は複数のファイルに対して使えません。 <tt/mv *.xxx *.yyy/ は思った通りに動かないでしょう。 <item><tt/cp -i/ と <tt/mv -i/ はファイルが上書きされることを警告してく れます。 </itemize> <sect1><!-- Print Queues-->プリンターキュー <label id="Print Queues"> <p> <!-- Your prints are queued, like under VMS. When you issue a print command, you may specify a printer name. Example: --> VMS でもそうだったように、印刷要求はキューイングされます。プリントコマン ドを発行する場合、プリンタ名を指定しても構いません。例: <tscreen><verb> $ lpr file.txt # this goes to the standard printer $ lpr -Plaser file.ps # this goes to the printer named 'laser' </verb></tscreen> <!-- To handle the print queues, you use the following commands: --> プリンタキューを扱うために、次のようなコマンドがあります。 <tscreen><verb> 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 <item> </verb></tscreen> <sect><!-- Configuring -->設定 <label id="Configuring"> <p> <!-- Your sysadm has already provided you with a number of configuration files like <tt/.xinitrc/, <tt/.bash_profile/, <tt/.inputrc/, and many others. The ones you may want to edit are: --> システム管理者が、すでに幾つかの設定ファイル - <tt/.xinitrc/, <tt/.bash_profile/, <tt/.inputrc/ 等のような - を準備していることでしょ う。これらのファイルは編集可能だと思います。 <itemize> <!-- <item> <tt/ .bash_profile/ or <tt/.profile/: read by the shell at login time. It's like <tt/LOGIN.COM/; --> <item><tt/ .bash_profile/ か <tt/.profile/ : ログインしたときにシェルが 読み込みます。<tt/LOGIN.COM/ のようなものです。 <!-- <item> <tt/ .bash_logout/: read by the shell at logout. It's like <tt/LOGOUT.COM/; --> <item><tt/ .bash_logout/: ログアウトの時にシェルが読み込みます。 <tt/LOGOUT.COM/ のようなものです。 <!-- <item> <tt/ .bashrc/: read by non--login shells. --> <item><tt/ .bashrc/: 非ログインシェルが実行します。 <!-- <item> <tt/ .inputrc/: this file customises the key bindings and the behaviour of the shell. --> <item><tt/ .inputrc/: キーの割り付けやシェルの動作をカスタマイズします。 </itemize> <!-- To give you an example, I'll include my <tt/.bash_profile/ (abridged): --> サンプルを示しましょう。これは私が使っている <tt/.bash_profile/ の一部で す(省略しています)。 <!-- <code> # $HOME/.bash_profile # don't redefine the path if not necessary echo $PATH | grep $LOGNAME > /dev/null if [ $? != 0 ] then export PATH="$PATH:/home/$LOGNAME/bin" # add my dir to the PATH fi export PS1='LOGNAME:\w\$ ' export PS2='Continued...>' # aliases alias bin="cd ~/bin" ; alias cp="cp -i" ; alias d="dir" alias del="delete" ; alias dir="/bin/ls $LS_OPTIONS --format=vertical" alias ed="jed" ; alias mv='mv -i' alias u="cd .." ; alias undel="undelete" # A few useful functions inst() # Install a .tar.gz archive in current directory. { gzip -dc $1 | tar xvf - } cz() # List the contents of a .zip archive. { unzip -l $* } ctgz() # List the contents of a .tar.gz archive. { for file in $* ; do gzip -dc ${file} | tar tf - done } tgz() # Create a .tgz archive a la zip. { name=$1 ; tar -cvf $1 ; shift tar -rf ${name} $* ; gzip -S .tgz ${name} } </code> --> <code> # $HOME/.bash_profile # 不必要にパスを再定義しないこと。 echo $PATH | grep $LOGNAME > /dev/null if [ $? != 0 ] then export PATH="$PATH:/home/$LOGNAME/bin" # add my dir to the PATH fi export PS1='LOGNAME:\w\$ ' export PS2='Continued...>' # aliases alias bin="cd ~/bin" ; alias cp="cp -i" ; alias d="dir" alias del="delete" ; alias dir="/bin/ls $LS_OPTIONS --format=vertical" alias ed="jed" ; alias mv='mv -i' alias u="cd .." ; alias undel="undelete" # 役に立つ関数 inst() # カレントディレクトリに .tar.gz アーカイブをインストールする。 { gzip -dc $1 | tar xvf - } cz() # .zip アーカイブの内容を一覧する。 { unzip -l $* } ctgz() # .tar.gz アーカイブの内容を一覧する。 { for file in $* ; do gzip -dc ${file} | tar tf - done } tgz() # zip 風に .tgz アーカイブを生成する。 { name=$1 ; tar -cvf $1 ; shift tar -rf ${name} $* ; gzip -S .tgz ${name} } </code> <!-- And this is my <tt/.inputrc/: --> そして、これは <tt/.inputrc/ です。 <!-- <code> # $HOME/.inputrc # Last modified: 16 January 1997. # # This file is read by bash and defines key bindings to be used by the shell; # what follows fixes the keys END, HOME, and DELETE, plus accented letters. # For more information, man readline. "\e[1~": beginning-of-line "\e[3~": delete-char "\e[4~": end-of-line set bell-style visible set meta-flag On set convert-meta Off set output-meta On set horizontal-scroll-mode On set show-all-if-ambiguous On # (F1 .. F5) are "\e[[A" ... "\e[[E" "\e[[A": "info " </code> --> <code> # $HOME/.inputrc # Last modified: 16 January 1997. # # このファイルは bash で読まれ、シェルで使われるキーの割り付けを定義したものです。 # 以下では、END、HOME、DELETE とアクセント文字キーは固定です。 # より詳しい情報は man readline を御覧ください。 "\e[1~": beginning-of-line "\e[3~": delete-char "\e[4~": end-of-line set bell-style visible set meta-flag On set convert-meta Off set output-meta On set horizontal-scroll-mode On set show-all-if-ambiguous On # (F1 .. F5) are "\e[[A" ... "\e[[E" "\e[[A": "info " </code> <sect> <!--Useful Programs-->役に立つプログラム <label id="Useful Programs"> <p> <sect1><!-- Browsing Files:-->ファイルのブラウズ <tt/less/ <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/less/ so as it can display not only plain text files, but also compressed files, archives, and so on. Like recent versions of <tt>TYPE</tt>, <tt/less/ lets you browse files in both directions. It also accepts several commands that are issued pressing a key. The most useful are: --> このファイルブラウザを毎日使うはずですから、使いこなせるよう、少しコツを お教えしましょう。一番最初に、<tt/less/ がプレーンテキスト以外の圧縮ファ イルやアーカイブも表示できるようになっていることをシステム管理者に確認して おいてください。 最近のバージョンの <tt>TYPE</tt> のように, <tt/less/ もファイルを両方向にブ ラウズします。また、キー入力により数種類のコマンドを受け付けます。最も役 に立つものは: <itemize> <!-- <item> first of all, press <tt/q/ to leave the browser; <item> <tt/h/ gives you extensive help; <item> <tt/g/ to go to beginning of file, <tt/G/ to the end, number+<tt/g/ to go to line `number' (e.g. <tt/125g/), number+<tt/%/ to move to that percentage of the file; <item> <tt>/pattern</tt> searches forwards for `pattern'; <tt/n/ searches forwards for the next match; <tt>?pattern</tt> and <tt/N/ search backwards; <item> <tt/m/+letter marks current position (e.g. <tt/ma/); <tt/'/+letter go to the marked position. <item> <tt/:e/ examines a new file; <item> <tt/!command/ executes the shell command. --> <item>最初に、<tt/q/ を押せば終了します。 <item><tt/h/ で拡張ヘルプを表示します。 <item><tt/g/ でファイルの先頭に移動します。<tt/G/ はファイルの末尾への移 動です。番号+<tt/g/ は番号で指定した行への移動(例えば、<tt/125g/ は125行 へ移動)、数値+<tt/%/ は数値で示した割合でファイルを分割した行に移動します。 <item><tt>/pattern</tt> は「pattern」を前方検索し、<tt/n/ は次にマッ チする文字列を探します。<tt>?pattern</tt> と <tt/N/ は後方検索です。 <item><tt/m/+文字 は現在の位置をマークします(例 <tt/ma/)。<tt/'/+文字 は マークした位置にジャンプします。 <item><tt/!command/ はシェルのコマンドを実行します。 </itemize> <sect1><!-- Numbered Backups Under Linux-->Linux での付番によるバックアップ <label id="Numbered Backups Under Linux"> <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'' (<url url="http://sunsite.unc.edu/mdw/HOWTO/mini/RCS.html">). The second way is to use an editor that knows how to deal with numbered backups; <tt>emacs</tt> and <tt>jed</tt> are OK. In <tt>emacs</tt>, add these lines in your <tt>.emacs</tt>: --> 悲しいことに、Linux ではまだファイルのバージョン番号がサポートされてい ませんが、二通りの方法でこの制約を克服することができます。一つ目の方法 は RCS ( Revision ControlSystem )を使うことで、これは変更前ファイルを 保存しておくことができます。 RCS は「 RCS MINI-HOWTO 」で解説されていま す。(<url url="http://sunsite.unc.edu/mdw/HOWTO/mini/RCS.html">) (訳注:<url url="http://www.linux.or.jp/JF/JFdocs/RCS.html" name="RCS MINI-HOWTO 日本語訳">はここ) 二つ目の方法は、付番してバックアップすることのできるエディタを使うことで す。<tt>emacs</tt> や <tt>jed</tt> なら OK です。<tt>emacs</tt> は、 <tt>.emacs</tt> に次のコードを追加します。 <tscreen><verb> (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) </verb></tscreen> <!-- In <tt>jed</tt>, make sure you have version 0.98.7 or newer; the patch for numbered backups is available on <tt> <url url="http://ibogeo.df.unibo.it/guido/slang/backups.sl"> </tt>. --> <tt>jed</tt> の 0.98.7 以降のバージョンをお持ちの方は、<url url="http://ibogeo.df.unibo.it/guido/slang/backups.sl">から入手できるパッ チをあてれば可能になります。 <sect1><!-- Archiving: tar & gzip-->アーカイブ:tar と gzip <p> <!-- Under UNIX there are some widely used applications to archive and compress files. <tt/tar/ is used to make archives, that is collections of files. To make a new archive: --> UNIX では、ファイルを圧縮してアーカイブに納めることが広く行なわれていま す。<tt/tar/ はファイルを集めて、アーカイブを作ります。新しいアーカイブ の作り方: <tscreen><verb> $ tar -cvf <archive_name.tar> <file> [file...] </verb></tscreen> <!--To extract files from an archive:--> アーカイブからファイルを取り出すには: <tscreen><verb> $ tar -xpvf <archive_name.tar> [file...] </verb></tscreen> <!--To list the contents of an archive:--> アーカイブの内容を一覧するには: <tscreen><verb> $ tar -tf <archive_name.tar> | less </verb></tscreen> <!-- Files can be compressed to save disk space using <tt/compress/, which is obsolete and shouldn't be used any more, or <tt/gzip/: --> ディスクスペースを節約するために、<tt/compress/ か <tt/gzip/ を使ってファイルを圧縮します。 <tt/compress/ はもはや旧式なので使うべきでありません。 <tscreen><verb> $ compress <file> $ gzip <file> </verb></tscreen> <!-- that creates a compressed file with extension .Z (<tt/compress/) or .gz (<tt/gzip/). These programs don't make archives, but compress files individually. To decompress, use: --> これによって .Z (<tt/compress/)や .gz (<tt/gzip/) などの拡張子付きのファイルが 生成されます。これらのプログラムではアーカイブは作られず、ファイルは個別 に圧縮されます。伸長するには: <tscreen><verb> $ compress -d <file.Z> $ gzip -d <file.gz> </verb></tscreen> RMP. <!-- The <tt/unarj/, <tt/zip/ and <tt/unzip/ utilities are also available. Files with extension <tt/.tar.gz/ or <tt/.tgz/ (archived with <tt/tar/, then compressed with <tt/gzip/) are very common in the UNIX world. Here's how to list the contents of a <tt/.tar.gz/ archive: --> <tt/unarj/, <tt/zip/ や <tt/unzip/ ユーティリティなども使用可能です。拡 張子 <tt/.tar.gz/ か <tt/.tgz/ がついたファイル( <tt/gzip/ で圧縮し、 <tt/tar/ でアーカイブにしたもの)は、UNIX ではかなり一般的です。 <tt/.tar.gz/ アーカイブの内容を一覧するには、 <tscreen><verb> $ tar -ztf <file.tar.gz> | less </verb></tscreen> とします。 <!--To extract the files from a <tt/.tar.gz/ archive:--> <tt/.tar.gz/ アーカイブからファイルを取り出すには、 <tscreen><verb> $ tar -zxf <file.tar.gz> </verb></tscreen> とします。 <sect><!-- Real Life Examples-->実生活での例 <label id="Examples"> <p> <!-- UNIX' core idea is that there are many simple commands that can linked together via piping and redirection to accomplish even really complex tasks. Have a look at the following examples. I'll only explain the most complex ones; for the others, please study the above sections and the man pages. --> UNIX の核となるアイデアは、単純なコマンドをパイプやリダイレクトにより結 合して、本当に複雑な作業でさえ行なえるようにすることです。以下の例を御覧ください。 最も混みいった問題についてのみ説明しましょう。他のことについては、これまでの 章や man ページを参考にしてみてください。 <!--<bf/Problem/: <tt/ls/ is too quick and the file names fly away.--> <bf/問題/ : <tt/ls/ を使うとファイルの一覧がスクロールして、画面から消えてしまう。 <!--<bf/Solution/:--><bf/解答/ : <tscreen><verb> $ ls | less </verb></tscreen> <!--<bf/Problem/: I have a file containing a list of words. I want to sort it in reverse order and print it. --> <bf/問題/ : 単語のリストを含んだファイルがあります。それを逆順でソートし、印刷したいのですが。 <!--<bf/Solution/:--><bf/解答/: <tscreen><verb> $ cat myfile.txt | sort -r | lpr </verb></tscreen> <!--<bf/Problem/: my data file has some repeated lines! How do I get rid of them?--> <bf/問題/ : データファイル内に同じデータを含む行が幾つもあります。 それを切り詰める方法はありますか。 <!--<bf/Solution/:--><bf/解答/: <tscreen><verb> $ sort datafile.dat | uniq > newfile.dat </verb></tscreen> <!--<bf/Problem/: I have a file called 'mypaper.txt' or 'mypaper.tex' or some such somewhere, but I don't remember where I put it. How do I find it? --> <bf/問題/ : 「mypaper.txt」か「mypaper.tex」か、それに似た名前のファイ ルがあるのですが、どこにあるのか思い出せません。見つける方法は? <!--<bf/Solution/:--><bf/解答/: <tscreen><verb> $ find ~ -name "mypaper*" </verb></tscreen> <!--Explanation: <tt/find/ is a very useful command that lists all the files in a directory tree (starting from <tt/˜/ in this case). Its output can be filtered to meet several criteria, such as <tt/-name/. --> 説明 : <tt/find/ はディレクトリツリー(この例では、<tt/˜/ 以降)の 全てのファイルを一覧するすごく便利なコマンドです。<tt/-name/ を使いフィ ルターをかけて出力することができます。 <!-- <bf/Problem/: I have a text file containing the word 'entropy' in this directory, is there anything like <tt/SEARCH/? --> <bf/問題/ : 「entropy」を含んだファイルがディレクトリ中にあります。 <tt/SEARCH/ コマンドのようにそれがどのファイルにあるか探す方法はありますか? <!--<bf/Solution/: yes, try--><bf/解決方法/:はい、このようにします。 <tscreen><verb> $ grep -l 'entropy' * </verb></tscreen> <!-- <bf/Problem/: somewhere I have text files containing the word 'entropy', I'd like to know which and where they are. Under VMS I'd use <tt/search entropy [...]*.*;*/, but <tt/grep/ can't recurse subdirectories. Now what? --> <bf/問題/ : どこかに「entropy」を含んだテキストファイルがあると思うんで すが、それがどこのなんていうファイルか知りたい。VMS では <tt/search entropy [...]*.*;*/ を使いましたが、<tt/grep/ ではサブディレクトリ以下を再 帰的に探すことができません。いい考えありますか? <!--<bf/Solution/:--><bf/解答/: <tscreen><verb> $ find . -exec grep -l "entropy" {} \; 2> /dev/null </verb></tscreen> <!-- Explanation: <tt/find ./ outputs all the file names starting from the current directory, <tt/-exec grep -l "entropy"/ is an action to be performed on each file (represented by <tt/{}/), <tt/\/ terminates the command. If you think this syntax is awful, you're right. In alternative, write the following script: --> 説明:<tt/find ./ はカレントディレクトリから始めて、全てのファイル一覧を出力し、 <tt/-exec grep -l "entropy"/ は各ファイルを対象に実行します (<tt/{}/ により表される)。<tt/\/ はコマンドを終了させます。 当然、この構文が面倒だと感じるでしょうね。 代わりに、次のようなスクリプトファイルを書くと良いでしょう。 (訳注:私は <tt/find . -type f |xargs grep 'entropy'/ のようにしています) <!-- <code> #!/bin/sh # rgrep: recursive grep if [ $# != 3 ] then echo "Usage: rgrep --switches 'pattern' 'directory'" exit 1 fi find $3 -name "*" -exec grep $1 $2 {} \; 2> /dev/null </code> --> <code> #!/bin/sh # rgrep: 再帰的な grep if [ $# != 3 ] then echo "Usage: rgrep --switches 'pattern' 'directory'" exit 1 fi find $3 -name "*" -exec grep $1 $2 {} \; 2> /dev/null </code> <!-- Explanation: <tt/grep/ works like <tt/search/, and combining it with <tt/find/ we get the best of both worlds. --> 説明: <tt/search/ のような <tt/grep/ と <tt/find/ とを組み合わせれば、 両方の世界で最も使いやすいものになると思います。 <!-- <bf/Problem/: I have a data file that has two header lines, then every line has 'n' data, not necessarily equally spaced. I want the 2nd and 5th data value of each line. Shall I write a Fortran program...? --> <bf/問題/ : 2 行のヘッダーで始まるデータファイルがあり、各行には不要なスペー スで区切られた n 個のデータがあります。各行の 2 番目と 5 番目のデータが欲 しいのですが、Fortran でプログラムを書いた方がいいでしょうか? <!--<bf/Solution/: nope. This is quicker:--><bf/解答/ : いいえ、こっちの方が早い。 <tscreen><verb> $ awk 'NL > 2 {print $2, "\t", $5}' datafile.dat > newfile.dat </verb></tscreen> <!-- Explanation: the command <tt/awk/ is actually a programming language: for each line starting from the third in <tt/datafile.dat/, print out the second and fifth field, separated by a tab. Learn some <tt/awk/---it saves a lot of time. --> 説明:コマンド <tt/awk/ は実際はプログラム言語で、データファイルの 3 行目 から開始して、各行の 2 番目と 5 番目をタブで区切ってプリントします。 <tt/awk/ を学びなさい --- 多くの時間を節約できますよ。 <!--<bf/Problem/: I've downloaded an FTP site's <tt/ls-lR.gz/ to check its contents. For each subdirectory, it contains a line that reads "total xxxx", where xxxx is size in kbytes of the dir contents. I'd like to get the grand total of all these xxxx values. --> <bf/問題/ : FTP サイトからダウンロードした <tt/ls-lR.gz/ の内容を調べた い。サブディレクトリ毎に「計 xxxx 」の行が含まれています。xxxx はディレ クトリ内容を KB 単位のサイズで表したものです。この xxxx の集計を行ないたいのですが。 <!--<bf/Solution/:--><bf/解答/: <tscreen><verb> $ zcat ls-lR.gz | awk ' $1 == "total" { i += $2 } END {print i}' </verb></tscreen> <!-- Explanation: <tt/zcat/ outputs the contents of the <tt/.gz/ file and pipes to <tt/awk/, whose man page you're kindly requested to read ;-) --> 説明:<tt/zcat/ は <tt/.gz/ ファイルの内容を出力し、<tt/awk/ にパイプし ます。<tt/awk/ は man ページに丁寧にのっていますよ ;-) <!-- <bf/Problem/: I've written a Fortran program, <tt/myprog/, to calculate a parameter from a data file. I'd like to run it on hundreds of data files and have a list of the results, but it's a nuisance to ask each time for the file name. Under VMS I'd write a lengthy command file, and under Linux? --> <bf/問題/:データファイルの値を計算する Fortran プログラム <tt/myprog/ が あります。数百のファイルを読み込ませて結果を出力したいのですが、データファ イル名をいちいち打つのが面倒です。VMS では長いコマンドファイルを書くと 思いますが、Linux ではどうすればいいのでしょう? <!-- <bf/Solution/: a very short script. Make your program look for the data file '<tt/mydata.dat/' and print the result on the screen (stdout), then write the following script: --> <bf/解答/: すごく短いスクリプトでできますよ。<tt/myprog/ が常に「 <tt/mydata.dat/ 」を読み、結果を標準出力( stdout )に表示するようにしておいて、次のスクリプト を書きます。 <!-- <code> #!/bin/sh # myprog.sh: run the same command on many different files # usage: myprog.sh *.dat for file in $* # for all parameters (e.g. *.dat) do # append the file name to result.dat echo -n "${file}: " >> results.dat # copy current argument to mydata.dat, run myprog # and append the output to results.dat cp ${file} mydata.dat ; myprog >> results.dat done </code> --> <code> #!/bin/sh # myprog.sh: 多くの異なるファイルに対して同じコマンドを実行します。 # 使用方法: myprog.sh *.dat for file in $* # for all parameters (e.g. *.dat) do # ファイル名を result.dat に追加していきます。 echo -n "${file}: " >> results.dat # 現在の引数を mydata.dat にコピーして、myprog を実行します。 # そして、出力を results.dat に追加します。 cp ${file} mydata.dat ; myprog >> results.dat done </code> <!-- <bf/Problem/: I want to replace `geology' with `geophysics' in all my text files. Shall I edit them all manually? --> <bf/問題/ : 私のテキストファイル内の「geology」を全て「geophysics」に置 き換えたいのですが、手作業でしなけれならないのでしょうか? <!--<bf/Solution/: nope. Write this shell script:--> <bf/解答/:いいえ、このシェルスクリプトを書いてください。 <!-- <code> #!/bin/sh # replace $1 with $2 in $* # usage: replace "old-pattern" "new-pattern" file [file...] OLD=$1 # first parameter of the script NEW=$2 # second parameter shift ; shift # discard the first 2 parameters: the next are the file names for file in $* # for all files given as parameters do # replace every occurrence of OLD with NEW, save on a temporary file sed "s/$OLD/$NEW/g" ${file} > ${file}.new # rename the temporary file as the original file /bin/mv ${file}.new ${file} done </code> --> <code> #!/bin/sh # $* の $1 を $2 に置き換えます。 # 使用方法:replace "old-pattern" "new-pattern" file [file...] OLD=$1 # スクリプトの最初のパラメータ NEW=$2 # 2 番目のパラメータ shift ; shift # 最初の二つのパラメータを捨てる。次はファイル名です。 for file in $* # パラメータとして与えられた全てのファイルでループします。 do # OLD を NEW に置換して、テンポラリファイルに保存します。 sed "s/$OLD/$NEW/g" ${file} > ${file}.new # テンポラリファイルをオリジナルファイル名にリネームします。 /bin/mv ${file}.new ${file} done </code> <!-- <bf/Problem/: I have some data files, I don't know their length and have to remove their last but one and last but two lines. Er... manually? --> <bf/問題/ : 幾つかデータファイルがあって、その長さは判らないんですが、 最後から 1 つ前の行と 2 つ前の行を削除するには 、えーと...手作業ですか? <!-- <bf/Solution/: no, of course. Write this script: --> <bf/解答/: もちろん、ノー。スクリプトを書いてください。 <!-- <code> #!/bin/sh # prune.sh: removes n-1th and n-2th lines from files # usage: prune.sh file [file...] for file in $* # for every parameter do LINES=`wc -l $file | awk '{print $1}'` # number of lines in file LINES=`expr $LINES - 3` # LINES = LINES - 3 head -n $LINES $file > $file.new # output first LINES lines tail -n 1 $file >> $file.new # append last line done </code> --> <code> #!/bin/sh # prune.sh は n-1番目と n-2 番目の行をファイルから削除します。 # 使用方法: prune.sh file [file...] for file in $* # 全てのパラメータでループします。 do LINES=`wc -l $file | awk '{print $1}'` # ファイルの行番号 LINES=`expr $LINES - 3` # LINES = LINES - 3 head -n $LINES $file > $file.new # 最初 KINES 行を出力します。 tail -n 1 $file >> $file.new # 最終行を加えます。 done </code> <!-- I hope these examples whetted your appetite... --> これらの例があなたの興味をそそりますように... <sect><!-- Tips You Can't Do Without-->これなしではやってゆけない秘訣 <p> <itemize> <!-- <item> <bf/Command completion/: pressing <TAB> when issuing a command will complete the command line for you. Example: you have to type <tt>less this_is_a_long_name</tt>; typing in <tt>less thi<TAB></tt> will suffice. (If you have other files that start with the same characters, supply enough characters to resolve any ambiguity.) --> <item><bf/コマンドの補完/:コマンドを発行してる途中で <TAB> を押 せば、コマンドラインの補完をしてくれます。例えば、<tt>less this_is_a_long_name</tt> とタイプしなければならないとき、<tt>less thi<TAB></tt> と打つだけで十分です(同じ単語で始まるファイルが他 にもあるなら、曖昧さを解決するための文字を補ってください)。 <!-- <item> <bf/Back-scrolling/: pressing SHIFT--PAG UP (the grey key) allows you to backscroll a few pages, depending on your PC's video memory. --> <item><bf/バックスクロール/:SHIFT--Page Up (灰色のキー)を押せ ば、数ページ分バックスクロールします。あなたの PC のビデオメモリ容量にも よりますが。 <!-- <item> <bf/Resetting the screen/: if you happen to <tt/more/ or <tt/cat/ a binary file, your screen may end up full of garbage. To fix things, blind type <tt/reset/ or this sequence of characters: <tt/echo CTRL-V ESC c RETURN/. --> <item><bf/画面のリセット/:<tt/more/ や <tt/cat/ でバイナリファイルを開 いてしまったら、画面上はゴミだらけの状態になるでしょう。これを直すには、 <tt/reset/ か、文字列 <tt/echo CTRL-V ESC c RETURN/ を画面を見ずにタイプしてくだ さい。 <!-- <item> <bf/Pasting text/: in console, see below; in X, click and drag to select the text in an <tt/xterm/ window, then click the middle button (or the two buttons together if you have a two-button mouse) to paste. --> <item><bf/テキストの張り付け/:コンソールモードなら次項を御覧ください。 X では、<tt/xterm/ ウインドウでクリックとドラッグによりテキストを選択し て、真中のボタン( 2 ボタンマウスなら、二つのボタンを同時に)を押して張り付 けます。 <!-- <item> <bf/Using the mouse/: ask your sysadm to install <tt/gpm/, a mouse driver for the console. Click and drag to select text, then right click to paste the selected text. It works across different VCs. --> <item><bf/マウスの使用/:コンソール用のマウスドライバ <tt/gpm/ がインス トールされているか、システム管理者に尋ねてください。クリックとドラッグに よりテキストを選択し、右ボタンをクリックしてテキストを張り付けます。これ は異なる VC 間でも動作します。 </itemize> <sect><!-- Reading VMS tapes from Linux--> Linux で VMS のテープを読むには <p> <!--(This section was written by Mike Miller)-->(この章は Mike Miller に よって書かれたものです) <sect1><!-- Introduction--> はじめに <p> <!-- > From time to time you may want to read tapes made on a VMS machine (or tapes that are made to be readable by VMS and *nix systems). In general, this is quite easy for DECFILES11A tapes. --> 時々、VMS マシンで書き込んだテープ(あるいは、VMS と *nix システムで読み取 り可能なように作成したもの)を読み込みたいことがあるでしょう。概して、こ れが DECFILES11A テープならまったく簡単です。 <!-- Although you may be reading this as part of a Linux mini-HOWTO, I believe that the information here is applicable to any *nix system - I've done this on Linux, HP, Sun and DEC *nix systems. The main platform dependences that I know are device names, which can differ on different systems, and the options to mt for specifying the device name (for example, mt -f on Linux and mt -t on HPUX 9). --> Linux mini-HOWTO の一部としてこれを読んだことがあるかも知れませんが、こ こでの情報はどの *nix システムでも適用可能だと信じます - 私は、Linux、HP、 Sun それに DEC *nix システム上で行ないました。私が知っている主なプラットフォー ム依存点は、異なるシステム毎にデバイス名が違うことと、デバイス名を指定する mt のオプションです(例えば、Linux では mt -f 、HPUX 9なら mt -t)。 <!-- Caveat - I've only tried this with Exabyte 8mm SCSI tape drives. If you've read other formats (still got those 9-tracks lying around?) let me know and I'll add a note here. --> 警告 - これは Exabyte 8mm SCSI テープ装置のみで試しました。他のフォーマッ ト形式(まだ 9 トラックはあるのかしら)で読み込むことができたら、私に知らせてください。ここに加えておきます。 <sect1><!-- The Basics-->基礎 <p> <!-- When reading a tape that has been made with the VMS ``copy'' command (or has at least been made to look like it was made with copy) all you need to know is there will be three files on the tape for each actual data file - a header, the data, and a trailer. The header and trailer are interesting in that they contain info on the file as it existed under VMS. The data is, well, the data. Each of these files can be extracted from the tape with the dd command. The tape can be positioned by skipping around with the mt command. --> VMS の「 copy 」コマンドで作成されたテープ(あるいは、ともかく copy で作成されたのと同じように作られたもの)を読むときに、実際のデータファイル毎にテープ上にあ る三つファイル - ヘッダー、データ、トレイラーのことを知っておく 必要があります。ヘッダーとトレイラーは VMS 上にあったときのファイル情報 を格納したものに関係あります。データは、もちろんデータのことです。めいめ いのファイルは dd コマンドでテープから取り出すことができます。mt コマンドでテープの位置をあちこちに移動させることができます。 <!-- Example: I've got VMS tape with a series of files on it. The first two were originally named ce66-2.evt and ce66-3.evt on a VMS system. The tape label is c66a2. If I execute these commands: --> 例:連続してファイルが書き込まれている VMS のテープがあります。最初の二 つは、VMS システムでのオリジナルの名前が ce66-2.evt と ce66-3.evt です。 テープラベルは c66a2 です。 もしこれらのコマンドを実行したなら、 <tscreen><verb> > dd if=$TAPE bs=16k of=header1 > dd if=$TAPE bs=16k of=data1 > dd if=$TAPE bs=16k of=trailer1 > dd if=$TAPE bs=16k of=header2 > dd if=$TAPE bs=16k of=data2 > dd if=$TAPE bs=16k of=trailer2 </verb></tscreen> <!-- I'm left with six files: header1, data1, trailer1, header2, data2 and trailer2. The syntax here is if="input file", bs="block size" and of="output file". TAPE is expected to be a variable containing the device name of your tape drive - for example, /dev/nts0 if you are using the first SCSI tape on Linux. If you wanted to read the second file, but not the first, you didn't care about the header, and you wanted to use the original file name, do this: --> 6つのファイル - header1, data1, trailer1, header2, data2 と trailer2 を 取り出せます。ここでの構文は、if="入力ファイル", bs="ブロックサイズ" そして、of="出力ファイル"です。TAPE はあなたのテープ装置の装置名称 に応じて変更されることでしょう。 - 例えば、Linux での一番目の SCSI テー プは /dev/nts0 です。 最初のファイルじゃなく 2 番目のファイルを読みたいときに、ヘッダーにつ いては気にせずによくて、さらにオリジナルのファイル名を使いたければ、このよう にします。 <tscreen><verb> > mt -f $TAPE fsf 4 > dd if=$TAPE bs=16k of=ce66-2.evt > mt -f $TAPE fsf 1 </verb></tscreen> <!--Note the 4 - skip three files for the first file on the tape and one for the next header. The second mt skips the second file's trailer and positions the tape at the beginning of the next file - the third VMS header. You can also use mt to skip backwards (bsf), rewind (rewind) and rewind and unload the tape (offline, rewoffl). --> 4 は最初のファイルから 3 つのファイルと、次のヘッダの一つをスキップするた めにあることに注意してください。二つ目の mt は 2 番目のファイルのトレイラーをスキップして、次のファイル - 3 番目の VMS ヘッダー の先頭にテープの位置を移し ます。mt を使って、後方( bsf )にスキップしたり、巻き戻したり ( rewind )、巻き戻してアンロード( offline, rewoffl )することもまたできます。 <sect1><!-- Some details-->詳細 <p> <!-- The header and trailer files contain uppercase ASCII data used by VMS to store file information such as block size. They also contain the file name, which can be handy if you want to build scripts that automate read files or search for a particular file. The first header on a tape volume is slightly different than subsequent headers. --> ヘッダーとトレイラーファイルは、ブロックサイズなどのファイル情報を保存す るために VMS で使われる大文字の ASCII データを含んだものです。それらはま たファイル名も含んでおり、自動でファイルを読み込んだり、特定のファイルを サーチするスクリプトを作るのに便利です。テープボリュームの一番目のヘッダー は、それ以降のヘッダーとはわずかに異なっています。 <!-- For a file that is the first file on the tape, as in header1 of the above example, the first four characters will be "VOL1" followed by the volume name. In the example, header1 starts with "VOL1C66A2". This is followed by a series of spaces terminated with a numeral. After that is the string "HDR1" which indicates that this is a file header. The characters immediately following the HDR1 string are the VMS file name. In in the example, this is "HDR1CE66-2.EVT". The next field is the volume name again. --> 上記の例で header1 に相当するテープ上の最初のファイルは、初めの4文字が 「VOL1」で始まり、その後にボリューム名が続きます。例では、header1 は VOL1C66A2 で始まります。数字で終る連続したスペースが続きます。その後に、 ファイルヘッダーであることを示す「 HDR1 」があります。HDR1 に続く文字列が VMS ファイル名です。例では、HDR1CE66-2.EVT です。次のフィールドは、再びボリューム名となります。 <!-- For files that are not the first file on the tape, the initial VOL1 field is not present. Other than that the header has the same structure as for the initial file. Another useful field is the 7th field, which will end with "DECFILES11A". This must be present on tapes that conform to the DEC Files11A standard. --> テープ上の最初のファイル以外のファイルには、語頭に VOL1 フィールドはありません。 VOL1 フィールドがないことを除けば、ヘッダーの構造は最初のファイルとそれ 以外のファイルも同じです。他に便利なフィールドは7番目のフィールドで、 「 DECFILES11A 」で終るでしょう。これは DEC Files11A 規格に適合している テープには、このフィールドがあるはずです。 <!-- <tscreen><verb> field initial header subsequent headers ===== ============= ================== 1 VOL1 + volume name HDR1 + file name 2 3HDR1 + file name volume name 3 volume name 6 ...DECFILES11A 7 ...DECFILES11A </verb></tscreen> --> <tscreen><verb> フィールド 最初のヘッダー 次のヘッダー ========= ================== ================== 1 VOL1 + ボリューム名 HDR1 + ファイル名 2 3HDR1 + ファイル名 ボリューム名 3 ボリューム名 6 ...DECFILES11A 7 ...DECFILES11A </verb></tscreen> <!-- For full details on the header and trailer format, see the DEC FILES11A documentation (on the orange/grey wall - ask your local VMS folks :-). --> ヘッダーやトレイラーの完全なフォーマットの詳細については、DEC FILES11A ドキュメントを御覧ください(オレンジやグレイの壁の上にあります - 身近にい る VMS 信奉者に尋ねてください :-)。 <sect1><!-- Comment on Block Size -->ブロックサイズについての解説 <p> <!-- In the example, I used a block size of 16k. On a *nix system, there is no block size associated with a file on disk while, under VMS, each file has a specific block size. That means that block size doesn't matter too much on the Linux end... unless it makes it hard to read the tape. If you have difficulty figuring out the block size and reading a tape, you can try setting the hardware block size on your tape drive using `mt -f $TAPE setblk 0'. The exact form of the setblk option (and its availability) may depend on the version of mt, the tape drive hardware interface and on your particular flavor of *nix. (Thanks to Wojtek Skulski (<url url="skulski@nsrlc6.nsrl.rochester.edu">) for pointing out setblk.) --> 例では、16k のブロックサイズを使いました。*nix システムでは、ディスク上 のファイルに関連づけたブロックサイズはありませんが、VMS での各ファ イルには、固有のブロックサイズがあります。これは、テープを読むことさえ難 しくなければ、ブロックサイズは、Linux 界において大した問題ではないこと意味します。 もしブロックサイズを算出してテープを読むことが難しければ、mt -f $TAPE setblk 0 を使って、ハードウェアブロックサイズを設定することができます。setblk オプションの正確な形式(と、使用可能かどうか)は mt のバージョンと、あなた が使用する特定の *nix の種類に依ります。 ( setblk について指摘してくれた Wojtek Skulski に感謝 (<url url="mailto:skulski@nsrlc6.nsrl.rochester.edu">)) <sect> <!--The End-->終りに <p> <sect1> Copyright <p> Unless otherwise stated, Linux HOWTO documents are copyrighted by their respective authors. Linux HOWTO documents may be reproduced and distributed in whole or in part, in any medium physical or electronic, as long as this copyright notice is retained on all copies. Commercial redistribution is allowed and encouraged; however, the author would like to be notified of any such distributions. 特に断らない限り、Linux HOWTO ドキュメントはそれぞれの著者の著作物です。Linux HOWTO ドキュメントは、全てのコピーにおいて copyright が保持されている限り、どのような物理的あるいは電子的なメディアによっても、全部あるいはその一部を複製し、配布することができます。商用の再配布についても許可や奨励をされていますが、そのようないかなる配布に関しても、著者は通知されることを望んでいます。 All translations, derivative works, or aggregate works incorporating any Linux HOWTO documents must be covered under this copyright notice. That is, you may not produce a derivative work from a HOWTO and impose additional restrictions on its distribution. Exceptions to these rules may be granted under certain conditions; please contact the Linux HOWTO coordinator at the address given below. 全ての翻訳、派生的な著作物、あるいはいずれかの Linux HOWTO 文書の内容を取り入れて集合的な著作物はこの copyright の下で保護される必要があります。つまり、いずれかの HOWTO をもとにした著作物を作ってもその配布に制限を追加してはいけません。ある条件の下では、これらの規則に対する例外が認められる場合があります。下記のアドレスの Linux HOWTO のコーディネーターに連絡を取ってください。 In short, we wish to promote dissemination of this information through as many channels as possible. However, we do wish to retain copyright on the HOWTO documents, and would like to be notified of any plans to redistribute the HOWTOs. 要するに、私たちは可能な限り多くの経路を通じてこの情報の普及を促進することを望んでいます。しかし、私たちは HOWTO の文書の著作権を保持することも強く望んでいますし、またそれら HOWTO の文書を再配布するどんな計画も私たちに知らせていただければ幸甚に思います。 If you have questions, please contact Tim Bynum, the Linux HOWTO coordinator, at <url url="mailto:linux-howto@sunsite.unc.edu"> via email. 疑問があれば、Linux HOWTO のコーディネータである Tim Bynum <url url="mailto:linux-howto@sunsite.unc.edu"> まで e-mail で連絡してください。 <sect1> Disclaimer <p> This work was written following the experience we had at the Settore di Geofisica of the Universita' di Bologna (Italy), where a VAX 4000 has been superseded and replaced by Linux-based Pentium PCs. Most of my colleagues are VMS users, and some of them have switched to Linux. この仕事は、Settore di Geofisica of the Universita' di Bologna (Italy) に おいて VAX 4000 を Linux ベースの Pentium PC にリプレースした経験に基づ いて書いたものです。私の同僚のほとんどは VMS ユーザで、そのうちの数人が Linux に転向しました。 ``From VMS to Linux HOWTO'' was written by Guido Gonzato, <url url="mailto:guido ``at'' ibogeo.df.unibo.it">, and Mike Miller, <url url="mailto:miller5@uiuc.edu"> who contributed the section on reading VMS tapes. Many thanks to my colleagues and friends who helped me define the needs and habits of the average VMS user, especially to Dr. Warner Marzocchi. 「 From VMS to Linux HOWTO 」は Guido Gonzato <url url="mailto:guido@ibogeo.df.unibo.it"> と、Mike Miller <url url="mailto:miller5@uiuc.edu"> (彼は VMS のテープを読むには の章で寄与しました)により書かれたものです。私の同 僚であり友人の Dr. Warner Marzocchi に多大なる感謝の念を捧げたい。彼は平 均的な VMS ユーザが求めているものや、やってしまいがちなことについて私にアドバイスしてくれました。 Please help me improve this HOWTO. I'm not a VMS expert and never will be, so your suggestions and bug reports are more than welcome. この HOWTO を改善する手助けをしてください。私は 今後とも VMS のエキスパー トではないので、あなたの提案やバグリポートを歓迎します。 Enjoy, Guido <tt/=8-)/ <sect1>日本語版謝辞 <p> 翻訳にあたって下記の皆さんからアドバイスやコメントをいただきました。どうもありがとうございました。 <verb> 佐野武俊さん 佐藤亮一さん 中谷千絵さん 武井伸光さん 高城正平さん 山崎@トロントさん Akihiro Kodaさん 大森保英さん 菊谷誠さん 福島於修さん </verb> </article>