1403 lines
50 KiB
HTML
1403 lines
50 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
||
|
||
<html>
|
||
|
||
<head>
|
||
|
||
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
|
||
|
||
<title>Debian Tutorial (Obsolete Documentation) - The Basics</title>
|
||
|
||
<link href="index.html" rel="start">
|
||
<link href="ch-start.html" rel="prev">
|
||
<link href="ch-docs.html" rel="next">
|
||
<link href="index.html#contents" rel="contents">
|
||
<link href="index.html#copyright" rel="copyright">
|
||
<link href="ch-about.html" rel="chapter" title="1 About this manual">
|
||
<link href="ch-introduction.html" rel="chapter" title="2 Introduction">
|
||
<link href="ch-start.html" rel="chapter" title="3 Getting started">
|
||
<link href="ch-basics.html" rel="chapter" title="4 The Basics">
|
||
<link href="ch-docs.html" rel="chapter" title="5 Reading documentation and getting help">
|
||
<link href="ch-shell.html" rel="chapter" title="6 Using the shell">
|
||
<link href="ch-files.html" rel="chapter" title="7 More on files">
|
||
<link href="ch-editor.html" rel="chapter" title="8 Creating and editing text files">
|
||
<link href="ch-custom_shell.html" rel="chapter" title="9 Customizing the shell">
|
||
<link href="ch-X.html" rel="chapter" title="10 The X Window System">
|
||
<link href="ch-text_tools.html" rel="chapter" title="11 Text tools">
|
||
<link href="ch-file_tools.html" rel="chapter" title="12 File tools">
|
||
<link href="ch-disks.html" rel="chapter" title="13 Using disks">
|
||
<link href="ch-dpkg.html" rel="chapter" title="14 Removing and installing software">
|
||
<link href="ch-troubleshooting.html" rel="chapter" title="15 Troubleshooting">
|
||
<link href="ch-advanced.html" rel="chapter" title="16 Advanced topics">
|
||
<link href="ch-next.html" rel="chapter" title="17 Where to from here?">
|
||
<link href="ch-helping.html" rel="chapter" title="18 Contributing to Debian: How can I help?">
|
||
<link href="ap-apps_appendix.html" rel="appendix" title="A A brief survey of available applications">
|
||
<link href="ap-components_appendix.html" rel="appendix" title="B Summary of GNU/Linux system components">
|
||
<link href="ap-booting_appendix.html" rel="appendix" title="C Appendix C: Booting the system">
|
||
<link href="ap-misc_appendix.html" rel="appendix" title="D Miscellaneous">
|
||
<link href="ch-about.html#s-acknowldgements" rel="section" title="1.1 Acknowledgements">
|
||
<link href="ch-introduction.html#s-introduction-debian" rel="section" title="2.1 What is Debian?">
|
||
<link href="ch-introduction.html#s-introduction-DFSG" rel="section" title="2.2 What's free software?">
|
||
<link href="ch-introduction.html#s-introduction-how" rel="section" title="2.3 How to Read This Book">
|
||
<link href="ch-introduction.html#s-introduction-ldp" rel="section" title="2.4 The Linux Documentation Project">
|
||
<link href="ch-start.html#s-start-multi" rel="section" title="3.1 A multiuser, multitasking operating system">
|
||
<link href="ch-start.html#s-start-login" rel="section" title="3.2 Logging in">
|
||
<link href="ch-start.html#s-start-keys" rel="section" title="3.3 Keys">
|
||
<link href="ch-start.html#s-start-commandline" rel="section" title="3.4 Command history and editing the command line">
|
||
<link href="ch-start.html#s-start-root" rel="section" title="3.5 Logging in as root">
|
||
<link href="ch-start.html#s-start-VC" rel="section" title="3.6 Virtual consoles">
|
||
<link href="ch-start.html#s-start-shutdown" rel="section" title="3.7 Shutting down">
|
||
<link href="ch-basics.html#s-basics-commandline" rel="section" title="4.1 The command line and <samp>man</samp> pages">
|
||
<link href="ch-basics.html#s-basics-files" rel="section" title="4.2 Files and Directories">
|
||
<link href="ch-basics.html#s-basics-processes" rel="section" title="4.3 Processes">
|
||
<link href="ch-basics.html#s-basics-shell" rel="section" title="4.4 The shell">
|
||
<link href="ch-basics.html#s-basics-jobs" rel="section" title="4.5 Managing processes with Bash">
|
||
<link href="ch-basics.html#s-basics-bash" rel="section" title="4.6 A few Bash features">
|
||
<link href="ch-basics.html#s-basics-identity" rel="section" title="4.7 Managing your identity">
|
||
<link href="ch-docs.html#s-docs-sources" rel="section" title="5.1 Kinds of documentation">
|
||
<link href="ch-docs.html#s-docs-info" rel="section" title="5.2 Using info">
|
||
<link href="ch-docs.html#s-docs-textfiles" rel="section" title="5.3 Viewing text files with more and less">
|
||
<link href="ch-docs.html#s-docs-howtos" rel="section" title="5.4 HOWTOs">
|
||
<link href="ch-docs.html#s-docs-support" rel="section" title="5.5 Getting help from a person">
|
||
<link href="ch-docs.html#s-docs-sysinfo" rel="section" title="5.6 Getting information from the system">
|
||
<link href="ch-shell.html#s-shell-variables" rel="section" title="6.1 Environment variables">
|
||
<link href="ch-shell.html#s-shell-path" rel="section" title="6.2 Where commands live: the <samp>PATH</samp> variable">
|
||
<link href="ch-shell.html#s-custom_shell-aliases" rel="section" title="6.3 Aliases and shell functions">
|
||
<link href="ch-shell.html#s-shell-io" rel="section" title="6.4 Controlling input and output">
|
||
<link href="ch-shell.html#s-shell-modifiers" rel="section" title="6.5 Specifying how and when to run commands">
|
||
<link href="ch-shell.html#s-shell-wildcards" rel="section" title="6.6 Filename expansion ("Wildcards")">
|
||
<link href="ch-shell.html#s6.7" rel="section" title="6.7 Interactive/non-interactive">
|
||
<link href="ch-files.html#s-files-permissions" rel="section" title="7.1 Permissions">
|
||
<link href="ch-files.html#s-files-tour" rel="section" title="7.2 What files are on my system? Where can I put my own files?">
|
||
<link href="ch-files.html#s-file-manager" rel="section" title="7.3 Using a filemanager">
|
||
<link href="ch-editor.html#s-editor-textfile" rel="section" title="8.1 What's a text file?">
|
||
<link href="ch-editor.html#s-editor-editor" rel="section" title="8.2 Text editors">
|
||
<link href="ch-editor.html#s-editor-vi" rel="section" title="8.3 Creating and editing a text file with <code>vi</code>">
|
||
<link href="ch-custom_shell.html#s-custom_shell-dotfiles" rel="section" title="9.1 .rc files and <samp>ls -a</samp>">
|
||
<link href="ch-custom_shell.html#s-custom_shell-etc" rel="section" title="9.2 System-wide vs. user-specific configuration">
|
||
<link href="ch-X.html#s-X-starting" rel="section" title="10.1 Starting the X environment">
|
||
<link href="ch-X.html#s-X-intro" rel="section" title="10.2 Intro: What is X">
|
||
<link href="ch-X.html#s-X-basics" rel="section" title="10.3 Basic X operations">
|
||
<link href="ch-X.html#s-X-startup" rel="section" title="10.4 Customizing your X startup">
|
||
<link href="ch-text_tools.html#s-text_tools-regexps" rel="section" title="11.1 Regular expressions">
|
||
<link href="ch-file_tools.html#s-file_tools-backup" rel="section" title="12.1 Backup tools">
|
||
<link href="ch-file_tools.html#s-file_tools-compression" rel="section" title="12.2 File compression with <samp>gzip</samp>">
|
||
<link href="ch-file_tools.html#s-file_tools-split" rel="section" title="12.3 Splitting files into smaller pieces">
|
||
<link href="ch-file_tools.html#s-file_tools-find" rel="section" title="12.4 Finding files">
|
||
<link href="ch-file_tools.html#s-file_tools-file" rel="section" title="12.5 Determining a file's contents">
|
||
<link href="ch-disks.html#s-disks-concepts" rel="section" title="13.1 Concepts">
|
||
<link href="ch-disks.html#s-disks-mount" rel="section" title="13.2 <samp>mount</samp> and <samp>/etc/fstab</samp>">
|
||
<link href="ch-disks.html#s-network-ppp" rel="section" title="13.3 PPP">
|
||
<link href="ch-dpkg.html#s-dpkg-dpkg" rel="section" title="14.1 The <code>dpkg</code> package utility">
|
||
<link href="ch-dpkg.html#s-dpkg-what" rel="section" title="14.2 What a package maintenance utility does">
|
||
<link href="ch-dpkg.html#s-dpkg-apt" rel="section" title="14.3 Apt">
|
||
<link href="ch-dpkg.html#s-dpkg-dselect" rel="section" title="14.4 Using dselect.">
|
||
<link href="ch-dpkg.html#s-dpkg-commandline" rel="section" title="14.5 Using dpkg manually">
|
||
<link href="ch-dpkg.html#s-dpkg-compiling" rel="section" title="14.6 Compiling software yourself">
|
||
<link href="ch-dpkg.html#s-dpkg-proprietary" rel="section" title="14.7 Proprietary software not in .deb format">
|
||
<link href="ch-troubleshooting.html#s-troubleshooting-frozen" rel="section" title="15.1 Debian is frozen or crashed!">
|
||
<link href="ch-troubleshooting.html#s-troubleshooting-termgarbage" rel="section" title="15.2 My terminal isn't behaving properly">
|
||
<link href="ch-troubleshooting.html#s-troubleshooting-vi" rel="section" title="15.3 The computer beeps when I press a key, and my screen shows a text file and/or a lot of <samp>~</samp> symbols.">
|
||
<link href="ch-advanced.html#s-advanced-scripting" rel="section" title="16.1 Introduction to shell scripting">
|
||
<link href="ch-advanced.html#s-advanced-files" rel="section" title="16.2 Advanced files">
|
||
<link href="ch-advanced.html#s-advanced-kernel" rel="section" title="16.3 Compiling the kernel">
|
||
<link href="ch-advanced.html#s-advanced-security" rel="section" title="16.4 A few words on security">
|
||
<link href="ch-advanced.html#s-advanced-programming" rel="section" title="16.5 Programming on Linux">
|
||
<link href="ch-next.html#s-next-manuals" rel="section" title="17.1 Other Debian manuals to read">
|
||
<link href="ch-next.html#s-next-resources" rel="section" title="17.2 Other resources">
|
||
<link href="ch-helping.html#s-helping-bugs" rel="section" title="18.1 Submit bug reports">
|
||
<link href="ch-helping.html#s-helping-other" rel="section" title="18.2 Other things">
|
||
<link href="ap-apps_appendix.html#s-A_apps-whatever" rel="section" title="A.1 (Subheadings could copy the structure of the menu system)">
|
||
<link href="ap-misc_appendix.html#s-unix-history" rel="section" title="D.1 Unix History">
|
||
<link href="ap-misc_appendix.html#sD.2" rel="section" title="D.2 GNU/Linux History">
|
||
<link href="ap-misc_appendix.html#sD.3" rel="section" title="D.3 The Linux kernel's version numbering">
|
||
<link href="ch-introduction.html#s-introduction-debian-os" rel="subsection" title="2.1.1 What's an operating system, and what sort of operating system is Debian?">
|
||
<link href="ch-introduction.html#s-introduction-debian-how" rel="subsection" title="2.1.2 Who creates Debian?">
|
||
<link href="ch-basics.html#s-basics-commandline-description" rel="subsection" title="4.1.1 Describing the command line">
|
||
<link href="ch-basics.html#s-basics-files-intro" rel="subsection" title="4.2.1 Introduction to files">
|
||
<link href="ch-basics.html#s-basics-files-using" rel="subsection" title="4.2.2 Using files: a tutorial">
|
||
<link href="ch-basics.html#s-basics-bash-completion" rel="subsection" title="4.6.1 Tab Completion">
|
||
<link href="ch-docs.html#s-docs-support-posting" rel="subsection" title="5.5.1 Dos and Don'ts of asking a question">
|
||
<link href="ch-shell.html#s-shell-variables-parents" rel="subsection" title="6.1.1 Parent and child processes">
|
||
<link href="ch-shell.html#s-interactive-shells" rel="subsection" title="6.7.1 Interactive shells">
|
||
<link href="ch-files.html#s-files-permissions-groups" rel="subsection" title="7.1.1 File Ownership">
|
||
<link href="ch-files.html#s-files-permissions-mode" rel="subsection" title="7.1.2 Mode">
|
||
<link href="ch-files.html#s-files-permissions-tutorial" rel="subsection" title="7.1.3 Permissions in practice">
|
||
<link href="ch-editor.html#s-editor-vi-creating" rel="subsection" title="8.3.1 Creating a file">
|
||
<link href="ch-editor.html#s-editor-vi-editing" rel="subsection" title="8.3.2 Editing an existing file">
|
||
<link href="ch-editor.html#s-editor-vi-editing-movement" rel="subsection" title="8.3.2.1 Moving around in a file">
|
||
<link href="ch-editor.html#s-editor-vi-editing-deletion" rel="subsection" title="8.3.2.2 Deleting text">
|
||
<link href="ch-editor.html#s-editor-vi-editing-moremoving" rel="subsection" title="8.3.2.3 Sophisticated movement">
|
||
<link href="ch-editor.html#s-editor-vi-editing-numbers" rel="subsection" title="8.3.2.4 Repeating commands">
|
||
<link href="ch-editor.html#s-editor-vi-editing-advanced" rel="subsection" title="8.3.2.5 Advanced reference">
|
||
<link href="ch-X.html#s-X-basics-mouse" rel="subsection" title="10.3.1 The mouse">
|
||
<link href="ch-X.html#s-X-basics-clients" rel="subsection" title="10.3.2 X clients">
|
||
<link href="ch-X.html#s-X-basics-trouble" rel="subsection" title="10.3.3 Troubleshooting">
|
||
<link href="ch-X.html#s-X-basics-leaving" rel="subsection" title="10.3.4 Leaving the X environment">
|
||
<link href="ch-disks.html#s-disks-mount-mounting" rel="subsection" title="13.2.1 Mounting a filesystem">
|
||
<link href="ch-disks.html#s-disks-mount-cdromexample" rel="subsection" title="13.2.2 Example: Mounting a CD-ROM">
|
||
<link href="ch-disks.html#s-disks-mount-fstab" rel="subsection" title="13.2.3 <samp>/etc/fstab</samp>: Automating the mount process">
|
||
<link href="ch-disks.html#s-disks-mount-removable" rel="subsection" title="13.2.4 Removable disks (floppies, Zip disks, etc.)">
|
||
<link href="ch-disks.html#s-network-ppp-introduction" rel="subsection" title="13.3.1 Introduction">
|
||
<link href="ch-disks.html#s-network-ppp-preparation" rel="subsection" title="13.3.2 Preparation">
|
||
<link href="ch-disks.html#s-network-ppp-wvdial" rel="subsection" title="13.3.3 The Easy Way: <samp>wvdial</samp>">
|
||
<link href="ch-disks.html#s-network-ppp-pppd" rel="subsection" title="13.3.4 Doing It Manually">
|
||
<link href="ch-dpkg.html#s-apt-config" rel="subsection" title="14.3.1 Configuring Apt">
|
||
<link href="ch-dpkg.html#s-apt-usage" rel="subsection" title="14.3.2 Using apt-get.">
|
||
<link href="ch-advanced.html#s-advanced-scripting-why" rel="subsection" title="16.1.1 What and why">
|
||
<link href="ch-advanced.html#s-advanced-scripting-example" rel="subsection" title="16.1.2 A simple example">
|
||
<link href="ch-advanced.html#s-advanced-files-hardlinks" rel="subsection" title="16.2.1 The real nature of files: hard links and inodes">
|
||
<link href="ch-advanced.html#s-advanced-files-types" rel="subsection" title="16.2.2 Types of files">
|
||
<link href="ch-advanced.html#s-advanced-files-types-symlinks" rel="subsection" title="16.2.2.1 Symbolic links">
|
||
<link href="ch-advanced.html#s-files-misc-types-devices" rel="subsection" title="16.2.2.2 Device files">
|
||
<link href="ch-advanced.html#s-advanced-files-types-devices-null" rel="subsection" title="16.2.2.2.1 <samp>/dev/null</samp>">
|
||
<link href="ch-advanced.html#s-advanced-files-types-pipes" rel="subsection" title="16.2.2.3 Named pipes (FIFOs)">
|
||
<link href="ch-advanced.html#s-advanced-files-types-sockets" rel="subsection" title="16.2.2.4 Sockets">
|
||
<link href="ch-advanced.html#s-advanced-files-proc" rel="subsection" title="16.2.3 The <samp>proc</samp> filesystem">
|
||
<link href="ch-advanced.html#s-advanced-files-permissions" rel="subsection" title="16.2.4 Advanced aspects of file permissions">
|
||
<link href="ch-advanced.html#s-advanced-files-permissions-absolute" rel="subsection" title="16.2.4.1 Using numeric arguments with <samp>chmod</samp>">
|
||
<link href="ch-advanced.html#s-advanced-files-chattr" rel="subsection" title="16.2.5 chattr">
|
||
<link href="ch-advanced.html#s-advanced-files-copying" rel="subsection" title="16.2.6 Large-scale copying">
|
||
<link href="ch-advanced.html#s-advanced-files-undocumented" rel="subsection" title="16.2.7 Other concepts not yet covered, but should be">
|
||
|
||
</head>
|
||
|
||
<body>
|
||
|
||
<p><a name="ch-basics"></a></p>
|
||
<hr>
|
||
|
||
<p>
|
||
[ <a href="ch-start.html">previous</a> ]
|
||
[ <a href="index.html#contents">Contents</a> ]
|
||
[ <a href="ch-about.html">1</a> ]
|
||
[ <a href="ch-introduction.html">2</a> ]
|
||
[ <a href="ch-start.html">3</a> ]
|
||
[ 4 ]
|
||
[ <a href="ch-docs.html">5</a> ]
|
||
[ <a href="ch-shell.html">6</a> ]
|
||
[ <a href="ch-files.html">7</a> ]
|
||
[ <a href="ch-editor.html">8</a> ]
|
||
[ <a href="ch-custom_shell.html">9</a> ]
|
||
[ <a href="ch-X.html">10</a> ]
|
||
[ <a href="ch-text_tools.html">11</a> ]
|
||
[ <a href="ch-file_tools.html">12</a> ]
|
||
[ <a href="ch-disks.html">13</a> ]
|
||
[ <a href="ch-dpkg.html">14</a> ]
|
||
[ <a href="ch-troubleshooting.html">15</a> ]
|
||
[ <a href="ch-advanced.html">16</a> ]
|
||
[ <a href="ch-next.html">17</a> ]
|
||
[ <a href="ch-helping.html">18</a> ]
|
||
[ <a href="ap-apps_appendix.html">A</a> ]
|
||
[ <a href="ap-components_appendix.html">B</a> ]
|
||
[ <a href="ap-booting_appendix.html">C</a> ]
|
||
[ <a href="ap-misc_appendix.html">D</a> ]
|
||
[ <a href="ch-docs.html">next</a> ]
|
||
</p>
|
||
|
||
<hr>
|
||
|
||
<h1>
|
||
Debian Tutorial (Obsolete Documentation)
|
||
<br>Chapter 4 - The Basics
|
||
</h1>
|
||
|
||
<hr>
|
||
|
||
<h2><a name="s-basics-commandline"></a>4.1 The command line and <samp>man</samp> pages</h2>
|
||
|
||
<p>
|
||
We've already discussed the <em>command line</em>, that is commands you type
|
||
after the shell prompt. This section describes the structure of more
|
||
complicated command lines.
|
||
</p>
|
||
|
||
<p>
|
||
A minimal command line contains just a command name, such as
|
||
<samp>whoami</samp>. But other things are possible. For example, you might
|
||
type:
|
||
</p>
|
||
|
||
<pre>
|
||
man whoami
|
||
</pre>
|
||
|
||
<p>
|
||
This command requests the online manual for the <samp>whoami</samp> program
|
||
(you may have to press the space bar to scroll through the documentation, or
|
||
press <samp>q</samp> to quit). A more complicated example:
|
||
</p>
|
||
|
||
<pre>
|
||
man -k Postscript
|
||
</pre>
|
||
|
||
<p>
|
||
This command line has three parts. It begins with the command name,
|
||
<samp>man</samp>. Then it has an <em>option</em> or <em>switch</em>,
|
||
<samp>-k</samp>, followed by an <em>argument</em>, <samp>Postscript</samp>.
|
||
Some people refer to everything except the command name as the
|
||
<em>parameters</em> of the command. So, options and arguments are both
|
||
parameters.
|
||
</p>
|
||
|
||
<p>
|
||
Options change the behavior of a command, switching on particular features or
|
||
functionality. They usually have a <samp>-</samp> before them. The GNU
|
||
utilities also have "long forms" for the options; the long form of
|
||
<samp>-k</samp> is <samp>--apropos</samp>. Enter <samp>man -h</samp> or
|
||
<samp>man --help</samp> to get a full list of options for the <samp>man</samp>
|
||
command. Every command will have its own set of options, though most have
|
||
<samp>--help</samp> and <samp>--version</samp> options. Some commands are
|
||
bizarre; <samp>tar</samp>, for example, does not require the <samp>-</samp>
|
||
before its options, for historical reasons.
|
||
</p>
|
||
|
||
<p>
|
||
Anything which isn't an option and isn't the command name is an
|
||
<em>argument</em>. In this case, <samp>Postscript</samp>. Arguments can serve
|
||
many purposes; most commonly, they are filenames that the command should
|
||
operate on. In this case, <samp>Postscript</samp> is the word you want
|
||
<code>man</code> to search for. In the case of <samp>man whoami</samp>, the
|
||
argument was the command you wanted information about.
|
||
</p>
|
||
|
||
<p>
|
||
Breaking down the <samp>man -k Postscript</samp> command line:
|
||
</p>
|
||
<ul>
|
||
<li>
|
||
<p>
|
||
<samp>man</samp>, the command name, tells the computer to look at the manual
|
||
pages. These provide documentation for commands. For example, <samp>man
|
||
whoami</samp> will give you documentation on the <samp>whoami</samp> command.
|
||
</p>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li>
|
||
<p>
|
||
<samp>-k</samp>, the option, changes the behavior of <samp>man</samp>.
|
||
Normally <samp>man</samp> expects a command name for an argument, such as
|
||
<samp>whoami</samp>, and looks for documentation of that command. But with the
|
||
<samp>-k</samp> or <samp>--apropos</samp> option, it expects the argument to be
|
||
a keyword. It then gives a list of all manual pages with that keyword in their
|
||
description.
|
||
</p>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li>
|
||
<p>
|
||
<samp>Postscript</samp> is the argument; since we used the <samp>-k</samp>
|
||
option, it's the keyword to search for.
|
||
</p>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li>
|
||
<p>
|
||
<samp>-k</samp> and <samp>Postscript</samp> are both parameters.
|
||
</p>
|
||
</li>
|
||
</ul>
|
||
|
||
<p>
|
||
Go ahead and type <samp>man -k Postscript</samp>, and you will see a list of
|
||
all the manual pages on your system that have something to do with Postscript.
|
||
If you haven't installed much software, you might see <samp>Postscript: nothing
|
||
appropriate</samp> instead.
|
||
</p>
|
||
|
||
<hr>
|
||
|
||
<h3><a name="s-basics-commandline-description"></a>4.1.1 Describing the command line</h3>
|
||
|
||
<p>
|
||
Note: This is a skippable section, if you want to move on.
|
||
</p>
|
||
|
||
<p>
|
||
There's a traditional concise way of describing command <em>syntax</em> [<a
|
||
href="footnotes.html#f4" name="fr4">4</a>] that you should know. For example,
|
||
if you type <samp>man man</samp> to get the manual page about <samp>man</samp>,
|
||
you'll see several syntax descriptions beginning with the command name
|
||
<samp>man</samp>. One of them will look like this:
|
||
</p>
|
||
|
||
<pre>
|
||
man -k [-M path] keyword ...
|
||
</pre>
|
||
|
||
<p>
|
||
Anything in brackets (<samp>[]</samp>) is an optional unit. So you don't have
|
||
to use the <samp>-M</samp> option, but if you do, you must use a
|
||
<samp>path</samp> argument. You must use the <samp>-k</samp> option and the
|
||
<samp>keyword</samp> argument. The <samp>...</samp> means that you could have
|
||
more of whatever came before it, so you could look up several keywords.
|
||
</p>
|
||
|
||
<p>
|
||
Let's look at one of the more complex descriptions from the <samp>man</samp>
|
||
manual page:
|
||
</p>
|
||
|
||
<pre>
|
||
man [-c|-w|-tZT device] [-adhu7V] [-m system[,...]] [-L
|
||
locale] [-p string] [-M path] [-P pager] [-r prompt] [-S
|
||
list] [-e extension] [[section] page ...] ...
|
||
</pre>
|
||
|
||
<p>
|
||
There's no need to go through all of this (and don't worry about what it all
|
||
means), but do pay attention to the organization of the description.
|
||
</p>
|
||
|
||
<p>
|
||
First, clusters of options usually mean you can use one or more of them in
|
||
different combinations, so <samp>-adhu7V</samp> means you can also use
|
||
<samp>-h</samp>. However, you can't always use all combinations; this
|
||
description doesn't make that clear. For example, <samp>-h</samp> is
|
||
incompatible with other options, but you could do <samp>man -du</samp>.
|
||
Unfortunately the description's format does not make this clear.
|
||
</p>
|
||
|
||
<p>
|
||
Second, the <samp>|</samp> symbol means "or". So you can use
|
||
<em>either</em> the <samp>-c</samp>, the <samp>-w</samp>, <em>or</em> the
|
||
<samp>-tZT</samp> options, followed by a <samp>device</samp> argument.
|
||
</p>
|
||
|
||
<p>
|
||
Third, notice that you can nest the brackets, since they indicate an optional
|
||
<em>unit</em>. So if you have a <samp>section</samp>, you must also have a
|
||
<samp>page</samp>, since <samp>page</samp> is not optional within the
|
||
<samp>[[section] page]</samp> unit.
|
||
</p>
|
||
|
||
<p>
|
||
There's no need to memorize any of this, just refer to this section as you read
|
||
documentation.
|
||
</p>
|
||
|
||
<hr>
|
||
|
||
<h2><a name="s-basics-files"></a>4.2 Files and Directories</h2>
|
||
|
||
<hr>
|
||
|
||
<h3><a name="s-basics-files-intro"></a>4.2.1 Introduction to files</h3>
|
||
|
||
<p>
|
||
<em>Files</em> are a facility for storing and organizing information, analagous
|
||
to paper documents. They're organized into <em>directories</em>, which are
|
||
called <em>folders</em> on some other systems. Let's look at the organization
|
||
of files on a Debian system:
|
||
</p>
|
||
<dl>
|
||
<dt><samp>/</samp></dt>
|
||
<dd>
|
||
<p>
|
||
A simple <samp>/</samp> represents the root directory. All other files and
|
||
directories are contained in the root directory. If you are coming from the
|
||
DOS/Windows world, <samp>/</samp> is very similar to what <samp>C:</samp> is
|
||
for DOS, that is the root of the filesystem. A notable difference between DOS
|
||
and Linux however, is that DOS keeps several filesystems: <samp>C:</samp>
|
||
(first hard disk), <samp>A:</samp> (first floppy disk), <samp>D:</samp> (either
|
||
CD-ROM or second hard disk) while Linux has all its files organized above the
|
||
same <samp>/</samp> root. See <a
|
||
href="ch-disks.html#s-disks-mount"><samp>mount</samp> and
|
||
<samp>/etc/fstab</samp>, Section 13.2</a> for more details.
|
||
</p>
|
||
</dd>
|
||
</dl>
|
||
<dl>
|
||
<dt><samp>/home/janeq</samp></dt>
|
||
<dd>
|
||
<p>
|
||
This is the home directory of user "janeq". Reading left to right,
|
||
to get to this directory you start in the root directory, enter directory
|
||
<samp>home</samp>, then enter directory <samp>janeq</samp>.
|
||
</p>
|
||
</dd>
|
||
</dl>
|
||
<dl>
|
||
<dt><samp>/etc/X11/XF86Config</samp></dt>
|
||
<dd>
|
||
<p>
|
||
This is the configuration file for the X Window System. It resides in the
|
||
<samp>X11</samp> subdirectory of the <samp>/etc</samp> directory.
|
||
<samp>/etc</samp> is in turn a subdirectory of the root directory,
|
||
<samp>/</samp>.
|
||
</p>
|
||
</dd>
|
||
</dl>
|
||
|
||
<p>
|
||
Things to note:
|
||
</p>
|
||
<ul>
|
||
<li>
|
||
<p>
|
||
Filenames are case sensitive. That is, <samp>MYFILE</samp> and
|
||
<samp>MyFile</samp> are <em>different</em> files.
|
||
</p>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li>
|
||
<p>
|
||
The root directory is referred to as simply <samp>/</samp>. Don't confuse this
|
||
"root" with the root user, the user on your system with "super
|
||
powers."
|
||
</p>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li>
|
||
<p>
|
||
Every directory has a name which can contain any letters or symbols
|
||
<em>except</em> <samp>/</samp>. The root directory is an exception; its name
|
||
is <samp>/</samp> (pronounced "slash" or "the root
|
||
directory") and it cannot be renamed. [<a href="footnotes.html#f5"
|
||
name="fr5">5</a>]
|
||
</p>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li>
|
||
<p>
|
||
Each file or directory is designated by a <em>fully-qualified filename</em>,
|
||
<em>absolute filename</em>, or <em>path</em>, giving the sequence of
|
||
directories which must be passed through to reach it. The three terms are
|
||
synonymous. All absolute filenames begin with the <samp>/</samp> directory,
|
||
and there's a <samp>/</samp> between each directory or file in the filename.
|
||
The first <samp>/</samp> is the name of a directory, but the others are simply
|
||
separators to distinguish the parts of the filename.
|
||
</p>
|
||
|
||
<p>
|
||
The words used here can be confusing. Take the following example:
|
||
</p>
|
||
|
||
<pre>
|
||
/usr/share/keytables/us.map.gz
|
||
</pre>
|
||
|
||
<p>
|
||
This is a fully-qualified filename; some people call it a <em>path</em>.
|
||
However, people will also refer to <samp>us.map.gz</samp> alone as a filename.
|
||
[<a href="footnotes.html#f6" name="fr6">6</a>]
|
||
</p>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li>
|
||
<p>
|
||
Directories are arranged in a tree structure. All absolute filenames start
|
||
with the root directory. The root directory has a number of branches, such as
|
||
<samp>/etc</samp> and <samp>/usr</samp>. These subdirectories in turn branch,
|
||
into still more subdirectories, such as <samp>/etc/init.d</samp> and
|
||
<samp>/usr/local</samp>. The whole thing together is called the
|
||
"directory tree."
|
||
</p>
|
||
|
||
<p>
|
||
You can think of an absolute filename as a route from the base of the tree
|
||
(<samp>/</samp>) to the end of some branch (a file). You'll also hear people
|
||
talk about the directory tree as if it were a <em>family</em> tree: thus
|
||
subdirectories have "parents," and a path shows the complete ancestry
|
||
of a file.
|
||
</p>
|
||
|
||
<p>
|
||
There are also relative paths that begin somewhere other than the root
|
||
directory. More on this later.
|
||
</p>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li>
|
||
<p>
|
||
There's no directory that corresponds to a physical device, such as your hard
|
||
disk. This differs from DOS and Windows, where all paths begin with a device
|
||
name such as <samp>C:\</samp>. The directory tree is meant to be an
|
||
abstraction of the physical hardware, so you can use the system without knowing
|
||
what the hardware is. All your files could be on one disk --- or you could
|
||
have 20 disks, some of them connected to a different computer elsewhere on the
|
||
network. You can't tell just by looking at the directory tree, and nearly all
|
||
commands work just the same way no matter what physical device(s) your files
|
||
are really on.
|
||
</p>
|
||
</li>
|
||
</ul>
|
||
|
||
<p>
|
||
Don't worry if all this isn't completely clear yet. There are many examples to
|
||
come.
|
||
</p>
|
||
|
||
<hr>
|
||
|
||
<h3><a name="s-basics-files-using"></a>4.2.2 Using files: a tutorial</h3>
|
||
|
||
<p>
|
||
To use your system you'll have to know how to create, move, rename, and delete
|
||
files and directories. This section describes how to do so with the standard
|
||
Debian commands.
|
||
</p>
|
||
|
||
<p>
|
||
The best way to learn is to try things. As long as you aren't root (and
|
||
haven't yet created any important personal files), there's nothing you can mess
|
||
up too seriously. Jump in --- type each of these commands at the prompt and
|
||
press enter:
|
||
</p>
|
||
<ol type="1" start="1" >
|
||
<li>
|
||
<p>
|
||
<samp>pwd</samp>
|
||
</p>
|
||
|
||
<p>
|
||
One directory is always considered the <em>current working directory</em> for
|
||
the shell you're using. You can view this directory with the <samp>pwd</samp>
|
||
command, which stands for Print Working Directory. <samp>pwd</samp> prints the
|
||
name of the directory you're working in --- probably
|
||
<samp>/home/yourname</samp>.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="2" >
|
||
<li>
|
||
<p>
|
||
<samp>ls</samp>
|
||
</p>
|
||
|
||
<p>
|
||
<samp>ls</samp> stands for "list", as in "list files".
|
||
When you type <samp>ls</samp>, the system displays a list of all the files in
|
||
your current working directory. If you've just installed Debian, your home
|
||
directory may well be empty. If your working directory is empty,
|
||
<samp>ls</samp> produces no output, since there are no files to list.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="3" >
|
||
<li>
|
||
<p>
|
||
<samp>cd /</samp>
|
||
</p>
|
||
|
||
<p>
|
||
<samp>cd</samp> means Change Directory. In this case, you've asked to change
|
||
to the root directory.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="4" >
|
||
<li>
|
||
<p>
|
||
<samp>pwd</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Verify that you're working in the root directory.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="5" >
|
||
<li>
|
||
<p>
|
||
<samp>ls</samp>
|
||
</p>
|
||
|
||
<p>
|
||
See what's in <samp>/</samp>.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="6" >
|
||
<li>
|
||
<p>
|
||
<samp>cd</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Typing <samp>cd</samp> with no arguments selects your home directory as the
|
||
current working directory --- <samp>/home/yourname</samp>. Try
|
||
<samp>pwd</samp> to verify this.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
|
||
<p>
|
||
Before continuing, you should know that there are actually two different kinds
|
||
of filename. Some of them begin with <samp>/</samp>, the root directory, such
|
||
as <samp>/etc/profile</samp>. These are called <em>absolute</em> filenames
|
||
because they refer to the same file no matter what your current directory is.
|
||
The other kind of filename is <em>relative</em>.
|
||
</p>
|
||
|
||
<p>
|
||
Two directory names are used <em>only</em> in relative filenames:
|
||
<samp>.</samp> and <samp>..</samp>. The directory <samp>.</samp> refers to the
|
||
current directory and <samp>..</samp> is the parent directory. These are
|
||
"shortcut" directories. They exist in <em>every</em> directory.
|
||
Even the root directory has a parent directory --- it's its own parent!
|
||
</p>
|
||
|
||
<p>
|
||
So filenames which include <samp>.</samp> or <samp>..</samp> are
|
||
<em>relative</em>, because their meaning depends on the current directory. If
|
||
I'm in <samp>/usr/bin</samp> and type <samp>../etc</samp>, then I'm referring
|
||
to <samp>/usr/etc</samp>. If I'm in <samp>/var</samp> and type
|
||
<samp>../etc</samp>, then I'm referring to <samp>/etc</samp>. Note that a
|
||
filename without the root directory at the front implicitly has <samp>./</samp>
|
||
at the front. So you can type <samp>local/bin</samp> or
|
||
<samp>./local/bin</samp> and it means the same thing.
|
||
</p>
|
||
|
||
<p>
|
||
A final handy tip: the tilde <samp>~</samp> is equivalent to your home
|
||
directory. So typing <samp>cd ~</samp> is the same as typing <samp>cd</samp>
|
||
with no arguments. Also, you can type things like <samp>cd
|
||
~/practice/mysubdirectory</samp> to change to the directory
|
||
<samp>/home/yourname/practice/mysubdirectory</samp>. In a similar way,
|
||
<samp>~vincent</samp> is equivalent to the home directory of the user
|
||
"vincent", which is probably something like
|
||
<samp>/home/vincent</samp>; so <samp>~vincent/docs/debian.ps</samp> is
|
||
equivalent to <samp>/home/vincent/doc/debian.ps</samp>.
|
||
</p>
|
||
|
||
<p>
|
||
Here are some more file commands to try out, now that you know about relative
|
||
filenames. <samp>cd</samp> to your home directory before you begin.
|
||
</p>
|
||
<ol type="1" start="1" >
|
||
<li>
|
||
<p>
|
||
<samp>mkdir practice</samp>
|
||
</p>
|
||
|
||
<p>
|
||
In your home directory, make a directory called <samp>practice</samp>. You'll
|
||
use this directory to try out some other commands. You might type
|
||
<samp>ls</samp> to verify that your new directory exists.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="2" >
|
||
<li>
|
||
<p>
|
||
<samp>cd practice</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Change directory to <samp>practice</samp>.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="3" >
|
||
<li>
|
||
<p>
|
||
<samp>mkdir mysubdirectory</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Create a subdirectory of <samp>practice</samp>.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="4" >
|
||
<li>
|
||
<p>
|
||
<samp>cp /etc/profile .</samp>
|
||
</p>
|
||
|
||
<p>
|
||
<samp>cp</samp> is short for "copy." <samp>/etc/profile</samp> is
|
||
just a random file on your system, don't worry about what it is for now. We've
|
||
copied it to <samp>.</samp> --- recall that <samp>.</samp> just means "the
|
||
directory I'm in now", or the current working directory. So we've created
|
||
a copy of <samp>/etc/profile</samp>, and put it in our <samp>practice</samp>
|
||
directory. Try typing <samp>ls</samp> to verify that there's indeed a file
|
||
called <samp>profile</samp> in your working directory, alongside the new
|
||
<samp>mysubdirectory</samp>.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="5" >
|
||
<li>
|
||
<p>
|
||
<samp>more profile</samp>
|
||
</p>
|
||
|
||
<p>
|
||
View the contents of the file <samp>profile</samp>. <samp>more</samp> is used
|
||
to view the contents of text files. It's called <samp>more</samp> because it
|
||
shows a screenfull of the file at a time, and you press the space bar to see
|
||
more. <samp>more</samp> will exit when you get to the end of the file, or when
|
||
you type <samp>q</samp> (quit).
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="6" >
|
||
<li>
|
||
<p>
|
||
<samp>more /etc/profile</samp> Verify that the original looks just like the
|
||
copy you made.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="7" >
|
||
<li>
|
||
<p>
|
||
<samp>mv profile mysubdirectory</samp>
|
||
</p>
|
||
|
||
<p>
|
||
<samp>mv</samp> stands for "move". We've moved the file
|
||
<samp>profile</samp> from the current directory into the subdirectory we
|
||
created earlier.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="8" >
|
||
<li>
|
||
<p>
|
||
<samp>ls</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Verify that <samp>profile</samp> is no longer in the current directory.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="9" >
|
||
<li>
|
||
<p>
|
||
<samp>ls mysubdirectory</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Verify that <samp>profile</samp> has moved to <samp>mysubdirectory</samp>.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="10" >
|
||
<li>
|
||
<p>
|
||
<samp>cd mysubdirectory</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Change to the subdirectory.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="11" >
|
||
<li>
|
||
<p>
|
||
<samp>mv profile myprofile</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Note that unlike some operating systems, there is no difference between moving
|
||
a file and renaming it. Thus there's no separate <samp>rename</samp> command.
|
||
Note that the second argument to <samp>mv</samp> can be a directory to move the
|
||
file or directory into, or a new filename. <samp>cp</samp> works the same way.
|
||
</p>
|
||
|
||
<p>
|
||
As usual, you can type <samp>ls</samp> to see the result of <samp>mv</samp>.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="12" >
|
||
<li>
|
||
<p>
|
||
<samp>mv myprofile ..</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Just as <samp>.</samp> means "the directory I'm in now",
|
||
<samp>..</samp> means "parent of the current directory", in this case
|
||
the <samp>practice</samp> directory we created earlier. Use <samp>ls</samp> to
|
||
verify that that's where <samp>myprofile</samp> is now.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="13" >
|
||
<li>
|
||
<p>
|
||
<samp>cd ..</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Change directories to the parent directory --- in this case
|
||
<samp>practice</samp>, where you just put <samp>myprofile</samp>.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="14" >
|
||
<li>
|
||
<p>
|
||
<samp>rm myprofile</samp>
|
||
</p>
|
||
|
||
<p>
|
||
<samp>rm</samp> means "remove" --- this deletes
|
||
<samp>myprofile</samp>. Be careful! Deleting a file on a GNU/Linux system is
|
||
<em>permanent</em> --- there is no undelete. If you <samp>rm</samp> it, it's
|
||
<em>gone</em>, <em>forever</em>. Be carefull! Deleting a file on a GNU/Linux
|
||
system is <em>permanent</em> --- there is no undelete. If you <samp>rm</samp>
|
||
it, it's <em>gone</em>, <em>forever</em>.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="15" >
|
||
<li>
|
||
<p>
|
||
<samp>rmdir mysubdirectory</samp>
|
||
</p>
|
||
|
||
<p>
|
||
<samp>rmdir</samp> is just like <samp>rm</samp>, only it's for directories.
|
||
Notice that <samp>rmdir</samp> only works on empty directories --- if the
|
||
directory contains files, you must delete those files first, or alternatively
|
||
use <samp>rm -r</samp> in place of <samp>rmdir</samp>.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="16" >
|
||
<li>
|
||
<p>
|
||
<samp>cd ..</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Move out of the current directory, and into its parent directory. Now you can
|
||
type:
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="17" >
|
||
<li>
|
||
<p>
|
||
<samp>rmdir practice</samp>
|
||
</p>
|
||
|
||
<p>
|
||
This will delete the last remnants of your practice session.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
|
||
<p>
|
||
So now you know how to create, copy, move, rename, and delete files and
|
||
directories. You also learned some shortcuts, like typing simply
|
||
<samp>cd</samp> to jump to your home directory, and <samp>.</samp> and
|
||
<samp>..</samp> to refer to the current directory and its parent, respectively.
|
||
You should also remember the concept of the <em>root directory</em>, or
|
||
<samp>/</samp>, and the alias <samp>~</samp> for your home directory.
|
||
</p>
|
||
|
||
<hr>
|
||
|
||
<h2><a name="s-basics-processes"></a>4.3 Processes</h2>
|
||
|
||
<p>
|
||
We mentioned before that GNU/Linux is a <em>multitasking</em> system. It can
|
||
do many tasks at once. Each of these tasks is called a <em>process</em>. The
|
||
best way to get a sense of this is to type <samp>top</samp> at the shell
|
||
prompt. You'll get a list of processes, sorted according to how much of the
|
||
computer's processing time they're using. The order will continuously change
|
||
before your eyes. At the top of the display, there's some information about
|
||
the system: how many users are logged in, how many total processes there are,
|
||
how much memory you have and how much you're using.
|
||
</p>
|
||
|
||
<p>
|
||
In the far left column, you'll see the user owning each process. The far right
|
||
column shows which command invoked the process. You'll probably notice that
|
||
<samp>top</samp> itself, invoked by you, is near the top of the list (since
|
||
anytime <samp>top</samp> checks on CPU usage, it will be active and using CPU
|
||
to do the check).
|
||
</p>
|
||
|
||
<p>
|
||
Note all the commands ending in <samp>d</samp> --- such as <samp>kflushd</samp>
|
||
and <samp>inetd</samp> --- the <samp>d</samp> stands for <em>daemon</em>[<a
|
||
href="footnotes.html#f7" name="fr7">7</a>]. A daemon is a non-interactive
|
||
process, that is, it's run by the system and users never have to worry about
|
||
it. Daemons provide services like internet connectivity, printing, or email.
|
||
</p>
|
||
|
||
<p>
|
||
Now press <samp>u</samp> and give <samp>top</samp> your user name when it asks.
|
||
The <samp>u</samp> command asks to see only those processes belonging to you;
|
||
it allows you to ignore all the daemons and whatever other people are doing.
|
||
You might notice <samp>bash</samp>, the name of your shell. You'll pretty much
|
||
always be running <samp>bash</samp>.
|
||
</p>
|
||
|
||
<p>
|
||
Note that column two of the <samp>top</samp> display shows you the
|
||
<em>PID</em>, or Process IDentification number. Each process is assigned a
|
||
unique PID. You can use the PID to control individual processes --- more on
|
||
that later. Another useful trick: type "?" to get a list of
|
||
<samp>top</samp> commands.
|
||
</p>
|
||
|
||
<p>
|
||
You may wonder about the difference between a "process" and a
|
||
"program" --- in practice people use the terms interchangeably.
|
||
Technically, the <em>program</em> is the set of instructions written by a
|
||
programmer, and kept on disk. The <em>process</em> is the working
|
||
instantiation of the program kept in memory by Linux. But it's not that
|
||
important to keep the terms straight.
|
||
</p>
|
||
|
||
<p>
|
||
Much of your interaction with a computer involves controlling processes.
|
||
You'll want to start them, stop them, and see what they're up to. Your primary
|
||
tool for this is the <em>shell</em>.
|
||
</p>
|
||
|
||
<hr>
|
||
|
||
<h2><a name="s-basics-shell"></a>4.4 The shell</h2>
|
||
|
||
<p>
|
||
The <em>shell</em> is a program that allows you to interact with your computer.
|
||
It's called a shell because it provides an environment for you to work in ---
|
||
sort of a little electronic home for you as you compute. (Think hermit crab.)
|
||
</p>
|
||
|
||
<p>
|
||
The simplest function of the shell is to launch other programs. You type the
|
||
name of the program you want to run, followed by the arguments you want, and
|
||
the shell asks the system to run the program for you.
|
||
</p>
|
||
|
||
<p>
|
||
Of course, graphical windowing systems also fill this need. Technically,
|
||
Windows 95 provides a graphical shell, and the X Window System is another kind
|
||
of graphical shell --- but "shell" is commonly used to mean
|
||
"command line shell."
|
||
</p>
|
||
|
||
<p>
|
||
Needless to say, the hackers who work on shells aren't satisfied with simply
|
||
launching commands. Your shell has a bewildering number of convenient features
|
||
if you want to take advantage of them.
|
||
</p>
|
||
|
||
<p>
|
||
There are countless different shells available; most are based on either the
|
||
<em>Bourne shell</em> or the <em>C shell</em>, two of the oldest shells. The
|
||
original Bourne shell's program name is <code>sh</code> while <code>csh</code>
|
||
is the C shell. Bourne shell variants include the Bourne Again Shell from the
|
||
GNU project (<samp>bash</samp>, the Debian default), the Korn shell
|
||
(<code>ksh</code>), and the Z shell (<code>zsh</code>). There is also
|
||
<code>ash</code>, a traditionalist implementation of the Bourne shell. The
|
||
most common C shell variant is <code>tcsh</code> (the <samp>t</samp> pays
|
||
tribute to the TENEX and TOPS-20 operating systems, which inspired some of
|
||
<samp>tcsh</samp>'s improvements over <samp>csh</samp>).
|
||
</p>
|
||
|
||
<p>
|
||
Bash is probably the best choice for new users. It is the default, and has all
|
||
the features you're likely to need. But all the shells have loyal followings;
|
||
if you want to experiment, install some different shell packages and change
|
||
your shell with the <code>chsh</code> command. Just type <samp>chsh</samp>,
|
||
supply a password when asked, and chose a shell. When you next log in, you'll
|
||
be using the new shell.
|
||
</p>
|
||
|
||
<hr>
|
||
|
||
<h2><a name="s-basics-jobs"></a>4.5 Managing processes with Bash</h2>
|
||
|
||
<p>
|
||
Debian is a multitasking system, so you need a way to do more than one thing at
|
||
once. Graphical environments like X provide a natural way to do this; they
|
||
allow multiple windows on the screen at any one time. Naturally, Bash (or any
|
||
other shell) provides similar facilities.
|
||
</p>
|
||
|
||
<p>
|
||
Earlier you used <code>top</code> to look at the different processes on the
|
||
system. Your shell provides some convenient ways to keep track of only those
|
||
processes you've started from the command line. Each command line starts a
|
||
<em>job</em> (also called a <em>process group</em>) to be carried out by the
|
||
shell. A job can consist of a single process or a set of processes in a
|
||
<em>pipeline</em> --- more on pipelines later.
|
||
</p>
|
||
|
||
<p>
|
||
Entering a command line will start a job. Try typing <samp>man cp</samp> and
|
||
the <samp>cp</samp> manual page will appear on the screen. The shell will go
|
||
into the background, and return when you finish reading the manual page (or
|
||
type <samp>q</samp> to quit rather than scrolling through the whole thing).
|
||
</p>
|
||
|
||
<p>
|
||
But say you're reading the manual page, and you want to do something else for a
|
||
minute. No problem. Type <samp>C-z</samp> while you're reading to
|
||
<em>suspend</em> the currently foregrounded job, and put the shell in the
|
||
foreground. When you suspend a job, Bash will first give you some information
|
||
on it, and then a shell prompt. You will see something like this on the
|
||
screen:
|
||
</p>
|
||
|
||
<pre>
|
||
NAME
|
||
cp - copy files
|
||
|
||
SYNOPSIS
|
||
cp [options] source dest
|
||
cp [options] source... directory
|
||
Options:
|
||
[-abdfilprsuvxPR] [-S backup-suffix] [-V {numbered,exist<73>
|
||
ing,simple}] [--backup] [--no-dereference] [--force]
|
||
[--interactive] [--one-file-system] [--preserve] [--recur<75>
|
||
sive] [--update] [--verbose] [--suffix=backup-suffix]
|
||
[--version-control={numbered,existing,simple}] [--archive]
|
||
[--parents] [--link] [--symbolic-link] [--help] [--ver<65>
|
||
sion]
|
||
|
||
DESCRIPTION
|
||
--More--
|
||
[1]+ Stopped man cp
|
||
$
|
||
</pre>
|
||
|
||
<p>
|
||
Note the last two lines. The next-to-last is the job information, and then you
|
||
have a shell prompt.
|
||
</p>
|
||
|
||
<p>
|
||
Bash assigns a <em>job number</em> to each command line you run from the shell.
|
||
This allows you to refer to the process easily. In this case, <samp>man
|
||
cp</samp> is job number 1, displayed as <samp>[1]</samp>. The <samp>+</samp>
|
||
means that this is the last job you had in the foreground. Bash also tells you
|
||
the current state of the job --- <samp>Stopped</samp> --- and the job's command
|
||
line.
|
||
</p>
|
||
|
||
<p>
|
||
There are many things you can do with jobs. With <samp>man cp</samp> still
|
||
suspended, try this:
|
||
</p>
|
||
<ol type="1" start="1" >
|
||
<li>
|
||
<p>
|
||
<samp>man ls</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Start a new job.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="2" >
|
||
<li>
|
||
<p>
|
||
<samp>C-z</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Suspend the <samp>man ls</samp> job by pressing Control and lowercase
|
||
<samp>z</samp>; you should see its job information.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="3" >
|
||
<li>
|
||
<p>
|
||
<samp>man mv</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Start yet another job.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="4" >
|
||
<li>
|
||
<p>
|
||
<samp>C-z</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Suspend it.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="5" >
|
||
<li>
|
||
<p>
|
||
<samp>jobs</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Ask Bash for a display of current jobs:
|
||
</p>
|
||
|
||
<pre>
|
||
$ jobs
|
||
[1] Stopped man cp
|
||
[2]- Stopped man ls
|
||
[3]+ Stopped man mv
|
||
$
|
||
</pre>
|
||
|
||
<p>
|
||
Notice the <samp>-</samp> and <samp>+</samp>, denoting respectively the
|
||
next-to-last and last foregrounded jobs.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="6" >
|
||
<li>
|
||
<p>
|
||
<samp>fg</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Place the last foregrounded job (<samp>man mv</samp>, the one with the
|
||
<samp>+</samp>) in the foreground again. If you press the spacebar, the man
|
||
page will continue scrolling.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="7" >
|
||
<li>
|
||
<p>
|
||
<samp>C-z</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Re-suspend <samp>man mv</samp>.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="8" >
|
||
<li>
|
||
<p>
|
||
<samp>fg %1</samp>
|
||
</p>
|
||
|
||
<p>
|
||
You can refer to any job by placing a <samp>%</samp> in front of its number.
|
||
If you use <samp>fg</samp> without specifying a job, the last active one is
|
||
assumed.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="9" >
|
||
<li>
|
||
<p>
|
||
<samp>C-z</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Re-suspend <samp>man cp</samp>.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="10" >
|
||
<li>
|
||
<p>
|
||
<samp>kill %1</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Kill off job 1. Bash will report the job information:
|
||
</p>
|
||
|
||
<pre>
|
||
$ kill %1
|
||
[1]- Terminated man cp
|
||
$
|
||
</pre>
|
||
|
||
<p>
|
||
Bash is only asking the job to quit, and sometimes a job will not want to do
|
||
so. If the job doesn't terminate, you can add the <samp>-9</samp> option to
|
||
kill to stop asking and start demanding. For example:
|
||
</p>
|
||
|
||
<pre>
|
||
$ kill -9 %1
|
||
[1]- Killed man mv
|
||
$
|
||
</pre>
|
||
|
||
<p>
|
||
The <samp>-9</samp> option forcibly and unconditionally kills off the job. [<a
|
||
href="footnotes.html#f8" name="fr8">8</a>]
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
<ol type="1" start="11" >
|
||
<li>
|
||
<p>
|
||
<samp>top</samp>
|
||
</p>
|
||
|
||
<p>
|
||
Bring the <samp>top</samp> display back up. Give the <samp>u</samp> command in
|
||
<samp>top</samp> to see only your processes. Look in the right-hand column for
|
||
the <samp>man ls</samp> and <samp>man mv</samp> commands. <samp>man cp</samp>
|
||
won't be there since you killed it. <samp>top</samp> is showing you the system
|
||
processes corresponding to your jobs; notice that the PID on the left of the
|
||
screen does not correspond to the job number.
|
||
</p>
|
||
|
||
<p>
|
||
You may not be able to find your processes because they're off the bottom of
|
||
the screen; if you're using X, you can resize the <samp>xterm</samp> to solve
|
||
this problem.
|
||
</p>
|
||
|
||
<p>
|
||
Even these simple jobs actually consist of multiple processes, including the
|
||
<samp>man</samp> process and the pager <samp>more</samp> which handles
|
||
scrolling a page at a time. You may notice the <samp>more</samp> processes are
|
||
also visible in <samp>top</samp>.
|
||
</p>
|
||
</li>
|
||
</ol>
|
||
|
||
<p>
|
||
You can probably figure out how to clean up the remaining two jobs. You can
|
||
either kill them (with the <samp>kill</samp> command) or foreground each one
|
||
(with <samp>fg</samp>) and exit it. Remember that the <samp>jobs</samp>
|
||
command will tell you the list existing jobs and their status.
|
||
</p>
|
||
|
||
<p>
|
||
One final note: the documentation for Bash is quite good, but it is found in
|
||
the Info help system rather than the man pages. To read it, type <samp>info
|
||
bash</samp>. See <a href="ch-docs.html#s-docs-info">Using info, Section
|
||
5.2</a> for instructions on using the <samp>info</samp> program. Bash also
|
||
contains a very good summary of its commands accessible by the
|
||
<samp>help</samp> command. <samp>help</samp> displays a list of available
|
||
topics; more informations about each of them being accessible with the command
|
||
<samp>help topicname</samp>; Try to type
|
||
</p>
|
||
|
||
<pre>
|
||
help cd
|
||
</pre>
|
||
|
||
<p>
|
||
for example. This will give you details on the <samp>-P</samp> and
|
||
<samp>-L</samp> arguments recognized by <samp>cd</samp>.
|
||
</p>
|
||
|
||
<hr>
|
||
|
||
<h2><a name="s-basics-bash"></a>4.6 A few Bash features</h2>
|
||
|
||
<p>
|
||
This section mentions just a few of the most commonly used Bash features; for a
|
||
more complete discussion see <a href="ch-shell.html">Using the shell, Chapter
|
||
6</a>.
|
||
</p>
|
||
|
||
<hr>
|
||
|
||
<h3><a name="s-basics-bash-completion"></a>4.6.1 Tab Completion</h3>
|
||
|
||
<p>
|
||
The Bash shell can guess what filename or command you are trying to type, and
|
||
automatically finish typing it for you. Just type the beginning of a command
|
||
or filename, and press <samp>TAB</samp>. If Bash finds a single unique
|
||
completion, it will finish the word and put a space after it. If it finds
|
||
multiple possible completions, it will fill out the part all completions have
|
||
in common and beep. You can then enter enough of the word to make it unique,
|
||
and press <samp>TAB</samp> again. If it finds no completions, it will simply
|
||
beep.
|
||
</p>
|
||
|
||
<hr>
|
||
|
||
<h2><a name="s-basics-identity"></a>4.7 Managing your identity</h2>
|
||
|
||
<p>
|
||
Unix-like systems are multiuser, and so you have your own electronic identity
|
||
as a user on the system. Type <samp>finger <var>yourusername</var></samp> to
|
||
have a look at some of the information about you that's publically available.
|
||
To change the name and shell listed there, you can use the commands
|
||
<samp>chfn</samp> and <samp>chsh</samp>. Only the superuser can change your
|
||
login (username) and directory. You'll notice that it says "No plan"
|
||
--- a "plan" is just some information you can make available to
|
||
others. To create a plan, put whatever information you want people to see in a
|
||
file called <samp>.plan</samp> --- to do this you'll use a text editor (see <a
|
||
href="ch-editor.html">Creating and editing text files, Chapter 8</a>). Then
|
||
finger yourself to see your plan. Others can finger you to see your plan, and
|
||
to check whether you've received new mail or read your mail.
|
||
</p>
|
||
|
||
<p>
|
||
Note that this finger information is available to the entire Internet by
|
||
default. If you don't want this, read about configuring <samp>inetd</samp> and
|
||
the file <samp>/etc/services</samp> --- eventually the installation manual will
|
||
describe this configuration, for now you might try the man pages, or just put
|
||
nonsense in for your finger information.
|
||
</p>
|
||
|
||
<hr>
|
||
|
||
<p>
|
||
[ <a href="ch-start.html">previous</a> ]
|
||
[ <a href="index.html#contents">Contents</a> ]
|
||
[ <a href="ch-about.html">1</a> ]
|
||
[ <a href="ch-introduction.html">2</a> ]
|
||
[ <a href="ch-start.html">3</a> ]
|
||
[ 4 ]
|
||
[ <a href="ch-docs.html">5</a> ]
|
||
[ <a href="ch-shell.html">6</a> ]
|
||
[ <a href="ch-files.html">7</a> ]
|
||
[ <a href="ch-editor.html">8</a> ]
|
||
[ <a href="ch-custom_shell.html">9</a> ]
|
||
[ <a href="ch-X.html">10</a> ]
|
||
[ <a href="ch-text_tools.html">11</a> ]
|
||
[ <a href="ch-file_tools.html">12</a> ]
|
||
[ <a href="ch-disks.html">13</a> ]
|
||
[ <a href="ch-dpkg.html">14</a> ]
|
||
[ <a href="ch-troubleshooting.html">15</a> ]
|
||
[ <a href="ch-advanced.html">16</a> ]
|
||
[ <a href="ch-next.html">17</a> ]
|
||
[ <a href="ch-helping.html">18</a> ]
|
||
[ <a href="ap-apps_appendix.html">A</a> ]
|
||
[ <a href="ap-components_appendix.html">B</a> ]
|
||
[ <a href="ap-booting_appendix.html">C</a> ]
|
||
[ <a href="ap-misc_appendix.html">D</a> ]
|
||
[ <a href="ch-docs.html">next</a> ]
|
||
</p>
|
||
|
||
<hr>
|
||
|
||
<p>
|
||
Debian Tutorial (Obsolete Documentation)
|
||
</p>
|
||
|
||
<address>
|
||
29 Dezember 2009<br>
|
||
<br>
|
||
Havoc Pennington <code><a href="mailto:hp@debian.org">hp@debian.org</a></code><br>
|
||
<br>
|
||
</address>
|
||
<hr>
|
||
|
||
</body>
|
||
|
||
</html>
|
||
|