1265 lines
18 KiB
HTML
1265 lines
18 KiB
HTML
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Shell Tips</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
|
|
REL="HOME"
|
|
TITLE="GNU/Linux Command-Line Tools Summary"
|
|
HREF="book1.htm"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="The Unix Tools Philosophy"
|
|
HREF="c1089.htm"><LINK
|
|
REL="NEXT"
|
|
TITLE="The command-line history"
|
|
HREF="x1712.htm"></HEAD
|
|
><BODY
|
|
CLASS="CHAPTER"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
SUMMARY="Header navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>GNU/Linux Command-Line Tools Summary</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="c1089.htm"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
></TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x1712.htm"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="CHAPTER"
|
|
><H1
|
|
><A
|
|
NAME="SHELL-TIPS"
|
|
></A
|
|
>Chapter 4. Shell Tips</H1
|
|
><DIV
|
|
CLASS="TOC"
|
|
><DL
|
|
><DT
|
|
><B
|
|
>Table of Contents</B
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="c1195.htm#GENERAL-SHELL-TIPS"
|
|
>General Shell Tips</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1712.htm"
|
|
>The command-line history</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x1877.htm"
|
|
>Other Key combinations</A
|
|
></DT
|
|
><DT
|
|
><A
|
|
HREF="x2005.htm"
|
|
>Virtual Terminals and screen</A
|
|
></DT
|
|
></DL
|
|
></DIV
|
|
><P
|
|
>The shell <A
|
|
NAME="AEN1198"
|
|
></A
|
|
>tips chapter provides handy tricks that you may wish to use when you are using a GNU/Linux shell (the command-line<A
|
|
NAME="AEN1200"
|
|
></A
|
|
> interface). This information includes handy <A
|
|
NAME="AEN1202"
|
|
></A
|
|
>shortcut <A
|
|
NAME="AEN1204"
|
|
></A
|
|
>key combinations,<A
|
|
NAME="AEN1206"
|
|
></A
|
|
> the shell's command history<A
|
|
NAME="AEN1208"
|
|
></A
|
|
> and information on virtual terminals.<A
|
|
NAME="AEN1210"
|
|
></A
|
|
></P
|
|
><DIV
|
|
CLASS="TIP"
|
|
><BLOCKQUOTE
|
|
CLASS="TIP"
|
|
><P
|
|
><B
|
|
>If you can't boot into your system: </B
|
|
>If your having problems booting into your system you may like to use a shell so you can boot into your system and attempt to fix things up again.</P
|
|
><P
|
|
>To do this you need to pass the “init=/bin/sh” to your system before you boot up.</P
|
|
><P
|
|
>If you don't know how to do this please see <A
|
|
HREF="c9295.htm"
|
|
>Chapter 14</A
|
|
><A
|
|
NAME="AEN1218"
|
|
></A
|
|
>, the technique is the same except this time you pass "init=bin/sh" rather than "single".</P
|
|
></BLOCKQUOTE
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT1"
|
|
><H1
|
|
CLASS="SECT1"
|
|
><A
|
|
NAME="GENERAL-SHELL-TIPS"
|
|
></A
|
|
>General Shell Tips</H1
|
|
><P
|
|
></P
|
|
><DIV
|
|
CLASS="VARIABLELIST"
|
|
><DL
|
|
><DT
|
|
>Automatic Command Completion</DT
|
|
><DD
|
|
><P
|
|
><A
|
|
NAME="AEN1227"
|
|
></A
|
|
>Use the TAB <A
|
|
NAME="AEN1229"
|
|
></A
|
|
>key and bash <A
|
|
NAME="AEN1231"
|
|
></A
|
|
>will attempt <A
|
|
NAME="AEN1233"
|
|
></A
|
|
>to complete<A
|
|
NAME="AEN1235"
|
|
></A
|
|
> the command for you automatically.<A
|
|
NAME="AEN1237"
|
|
></A
|
|
> You can use it to complete command (tool) names. You can also use it when working with the file-system,<A
|
|
NAME="AEN1239"
|
|
></A
|
|
> when changing directories, copying <A
|
|
NAME="AEN1241"
|
|
></A
|
|
>files et cetera.</P
|
|
><P
|
|
>There are also other lesser <A
|
|
NAME="AEN1244"
|
|
></A
|
|
>known ways to use automatic command completion<A
|
|
NAME="AEN1246"
|
|
></A
|
|
> (for example completing user names):<A
|
|
NAME="AEN1248"
|
|
HREF="#FTN.AEN1248"
|
|
><SPAN
|
|
CLASS="footnote"
|
|
>[1]</SPAN
|
|
></A
|
|
></P
|
|
><P
|
|
></P
|
|
><DIV
|
|
CLASS="VARIABLELIST"
|
|
><DL
|
|
><DT
|
|
><B
|
|
CLASS="KEYCAP"
|
|
>ESC</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>Y</B
|
|
>
|
|
<A
|
|
NAME="AEN1257"
|
|
></A
|
|
>
|
|
(Y: special character)</DT
|
|
><DD
|
|
><P
|
|
>testing autoindexing Will attempt to complete the command name for you. If it fails it will either list <A
|
|
NAME="AEN1261"
|
|
></A
|
|
>the possible completions <A
|
|
NAME="AEN1263"
|
|
></A
|
|
>(if they exist). If there are none <A
|
|
NAME="AEN1265"
|
|
></A
|
|
>it will simply beep <A
|
|
NAME="AEN1267"
|
|
></A
|
|
>(and/or) flash <A
|
|
NAME="AEN1269"
|
|
></A
|
|
>the screen.<A
|
|
NAME="AEN1271"
|
|
></A
|
|
> </P
|
|
></DD
|
|
><DT
|
|
><B
|
|
CLASS="KEYCAP"
|
|
>CTRL</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>X</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>Y</B
|
|
>
|
|
<A
|
|
NAME="AEN1279"
|
|
></A
|
|
>
|
|
(Y: special character)</DT
|
|
><DD
|
|
><P
|
|
>Lists the possible completions (it won't attempt<A
|
|
NAME="AEN1283"
|
|
></A
|
|
> to complete it for you) or beep <A
|
|
NAME="AEN1285"
|
|
></A
|
|
>if there are no possible <A
|
|
NAME="AEN1287"
|
|
></A
|
|
>completions.</P
|
|
></DD
|
|
></DL
|
|
></DIV
|
|
><P
|
|
>Special-characters:</P
|
|
><P
|
|
>Use the following <A
|
|
NAME="AEN1291"
|
|
></A
|
|
>special characters<A
|
|
NAME="AEN1293"
|
|
></A
|
|
> combined with either
|
|
<B
|
|
CLASS="KEYCAP"
|
|
>ESC</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>Y</B
|
|
>
|
|
<A
|
|
NAME="AEN1298"
|
|
></A
|
|
>
|
|
or
|
|
<B
|
|
CLASS="KEYCAP"
|
|
>CTRL</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>X</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>Y</B
|
|
>
|
|
<A
|
|
NAME="AEN1304"
|
|
></A
|
|
>
|
|
, where Y is some special characters. For example
|
|
<B
|
|
CLASS="KEYCAP"
|
|
>ESC</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>$</B
|
|
>
|
|
<A
|
|
NAME="AEN1309"
|
|
></A
|
|
>
|
|
or
|
|
<B
|
|
CLASS="KEYCAP"
|
|
>CTRL</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>X</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>$</B
|
|
>
|
|
<A
|
|
NAME="AEN1315"
|
|
></A
|
|
>
|
|
to complete an environment variable<A
|
|
NAME="AEN1317"
|
|
></A
|
|
> name.</P
|
|
><P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
>~ (tilde)<A
|
|
NAME="AEN1322"
|
|
></A
|
|
><A
|
|
NAME="AEN1324"
|
|
></A
|
|
> complete a user name<A
|
|
NAME="AEN1326"
|
|
></A
|
|
></P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>@ (at sign)<A
|
|
NAME="AEN1330"
|
|
></A
|
|
> complete a machine name<A
|
|
NAME="AEN1332"
|
|
></A
|
|
></P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>$ (dollars sign)<A
|
|
NAME="AEN1336"
|
|
></A
|
|
> complete an environment variable<A
|
|
NAME="AEN1338"
|
|
></A
|
|
> name</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>! (exclamation mark)<A
|
|
NAME="AEN1342"
|
|
></A
|
|
> a magic character<A
|
|
NAME="AEN1344"
|
|
></A
|
|
> for completing a command name<A
|
|
NAME="AEN1346"
|
|
></A
|
|
> or a file name.<A
|
|
NAME="AEN1348"
|
|
></A
|
|
> The ! special character <A
|
|
NAME="AEN1350"
|
|
></A
|
|
>has the same function <A
|
|
NAME="AEN1352"
|
|
></A
|
|
>as the TAB <A
|
|
NAME="AEN1354"
|
|
></A
|
|
>key. It works in some other situations; for example when completing man page<A
|
|
NAME="AEN1356"
|
|
></A
|
|
> names.</P
|
|
></LI
|
|
></UL
|
|
></DD
|
|
><DT
|
|
>alias</DT
|
|
><DD
|
|
><P
|
|
><A
|
|
NAME="AEN1362"
|
|
></A
|
|
>The <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>alias</I
|
|
></SPAN
|
|
> command will list your current aliases.<A
|
|
NAME="AEN1365"
|
|
></A
|
|
> You can use <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>unalias</I
|
|
></SPAN
|
|
> <A
|
|
NAME="AEN1368"
|
|
></A
|
|
>to remove <A
|
|
NAME="AEN1370"
|
|
></A
|
|
>the alias (to disable <A
|
|
NAME="AEN1372"
|
|
></A
|
|
>it just for one command add a “\”<A
|
|
NAME="AEN1374"
|
|
></A
|
|
> (back-slash) before the command)...</P
|
|
><P
|
|
>An alias allows one command to be substituted <A
|
|
NAME="AEN1377"
|
|
></A
|
|
>for another. This is used to make a command do something else or to automatically <A
|
|
NAME="AEN1379"
|
|
></A
|
|
>add<A
|
|
NAME="AEN1381"
|
|
></A
|
|
> certain options.<A
|
|
NAME="AEN1383"
|
|
></A
|
|
> This can be either be done during one session <A
|
|
NAME="AEN1385"
|
|
></A
|
|
>using the alias command (see below) or the information <A
|
|
NAME="AEN1387"
|
|
></A
|
|
>can be added to the <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>.bashrc</I
|
|
></SPAN
|
|
> file (found in the users home directory).</P
|
|
><P
|
|
>Below is an example of what an alias section (within your <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>.bashrc</I
|
|
></SPAN
|
|
> file) might look like:</P
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
># my personal aliases
|
|
alias cp='cp -vi' #to prompt when copying if you want to overwrite and will tell you where information is going
|
|
alias rm='rm -i' #Prompts you if you really want to remove it.
|
|
alias mv='mv -i' #Prompts you if you are going to overwrite something</PRE
|
|
><P
|
|
>On any Mandriva GNU/Linux system the global aliases <A
|
|
NAME="AEN1394"
|
|
></A
|
|
>(for all users) are all in /etc/profile.d/alias.sh. The above listed <A
|
|
NAME="AEN1396"
|
|
></A
|
|
>commands already have aliases,<A
|
|
NAME="AEN1398"
|
|
></A
|
|
> as well as several <A
|
|
NAME="AEN1400"
|
|
></A
|
|
>other commonly <A
|
|
NAME="AEN1402"
|
|
></A
|
|
>used commands.</P
|
|
></DD
|
|
><DT
|
|
>set -x</DT
|
|
><DD
|
|
><P
|
|
><A
|
|
NAME="AEN1408"
|
|
></A
|
|
><SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
> set <A
|
|
NAME="AEN1411"
|
|
></A
|
|
></I
|
|
></SPAN
|
|
>is one of bash's inbuilt <A
|
|
NAME="AEN1413"
|
|
></A
|
|
>commands, try looking in the bash <A
|
|
NAME="AEN1415"
|
|
></A
|
|
>manual for its many usage <A
|
|
NAME="AEN1417"
|
|
></A
|
|
>options.</P
|
|
><P
|
|
>Using <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>set</I
|
|
></SPAN
|
|
> with the<SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
> -x</I
|
|
></SPAN
|
|
> option <A
|
|
NAME="AEN1422"
|
|
></A
|
|
>will make bash <A
|
|
NAME="AEN1424"
|
|
></A
|
|
>print out each command it is going to run <A
|
|
NAME="AEN1426"
|
|
></A
|
|
>before it runs it. </P
|
|
><P
|
|
>This can be useful to find <A
|
|
NAME="AEN1429"
|
|
></A
|
|
>out what is happening with certain commands such as things being quoted <A
|
|
NAME="AEN1431"
|
|
></A
|
|
>that contain wildcards <A
|
|
NAME="AEN1433"
|
|
></A
|
|
>or special symbols <A
|
|
NAME="AEN1435"
|
|
></A
|
|
>that could cause <A
|
|
NAME="AEN1437"
|
|
></A
|
|
>problems, or complex <A
|
|
NAME="AEN1439"
|
|
></A
|
|
>aliases. Use<SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
> set +x</I
|
|
></SPAN
|
|
> to turn <A
|
|
NAME="AEN1442"
|
|
></A
|
|
>this back off.<A
|
|
NAME="AEN1444"
|
|
></A
|
|
></P
|
|
><P
|
|
>Examples</P
|
|
><P
|
|
>After using <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
> set -x</I
|
|
></SPAN
|
|
> you can run the command:</P
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
>ls</PRE
|
|
><P
|
|
><A
|
|
NAME="AEN1451"
|
|
></A
|
|
><A
|
|
NAME="AEN1453"
|
|
></A
|
|
><A
|
|
NAME="AEN1455"
|
|
></A
|
|
>The output <A
|
|
NAME="AEN1457"
|
|
></A
|
|
>printed <A
|
|
NAME="AEN1459"
|
|
></A
|
|
>before the command runs (for example):</P
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
>+ ls -F --color=auto </PRE
|
|
><P
|
|
>Which means that the command is really an alias to run <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>ls</I
|
|
></SPAN
|
|
> with the <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>-F</I
|
|
></SPAN
|
|
> and <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>--color=auto</I
|
|
></SPAN
|
|
> options. Use a “\” (backslash) before the command to run <A
|
|
NAME="AEN1466"
|
|
></A
|
|
>it without the alias.</P
|
|
></DD
|
|
><DT
|
|
>\ (backslash)</DT
|
|
><DD
|
|
><P
|
|
><A
|
|
NAME="AEN1472"
|
|
></A
|
|
>The backslash <A
|
|
NAME="AEN1474"
|
|
></A
|
|
>escape character <A
|
|
NAME="AEN1476"
|
|
></A
|
|
>can be used before a shell command to override <A
|
|
NAME="AEN1478"
|
|
></A
|
|
>any aliases.</P
|
|
><P
|
|
>For example if <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>rm</I
|
|
></SPAN
|
|
> was made into an alias for<SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
> rm -i<A
|
|
NAME="AEN1483"
|
|
></A
|
|
><A
|
|
NAME="AEN1485"
|
|
></A
|
|
></I
|
|
></SPAN
|
|
> then typing “rm” would actually run<SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
> rm -i</I
|
|
></SPAN
|
|
>. </P
|
|
><P
|
|
>However, typing <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>\rm</I
|
|
></SPAN
|
|
> lets the shell ignore the alias <A
|
|
NAME="AEN1490"
|
|
></A
|
|
>and just run <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>rm</I
|
|
></SPAN
|
|
> (its runs exactly <A
|
|
NAME="AEN1493"
|
|
></A
|
|
>what you type), this way it won't confirm <A
|
|
NAME="AEN1495"
|
|
></A
|
|
>if you want to delete <A
|
|
NAME="AEN1497"
|
|
></A
|
|
>things.</P
|
|
><DIV
|
|
CLASS="CAUTION"
|
|
><P
|
|
></P
|
|
><TABLE
|
|
CLASS="CAUTION"
|
|
BORDER="1"
|
|
WIDTH="90%"
|
|
><TR
|
|
><TD
|
|
ALIGN="CENTER"
|
|
><B
|
|
>Using rm</B
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
><P
|
|
>Please note that the alias for the remove command is there for a reason. Using it incorrectly could remove files which you don't want removed.</P
|
|
><P
|
|
>Only use <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>\rm</I
|
|
></SPAN
|
|
> if you know exactly what you are doing (recovering files is not easy, <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>rm</I
|
|
></SPAN
|
|
> does not send things to a recycle bin).</P
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
><P
|
|
>The “\” character <A
|
|
NAME="AEN1506"
|
|
></A
|
|
>can be used before special characters<A
|
|
NAME="AEN1508"
|
|
></A
|
|
> (such as a space <A
|
|
NAME="AEN1510"
|
|
></A
|
|
>or a wildcard<A
|
|
NAME="AEN1512"
|
|
></A
|
|
>), to stop <A
|
|
NAME="AEN1514"
|
|
></A
|
|
>bash <A
|
|
NAME="AEN1516"
|
|
></A
|
|
>from trying to expand <A
|
|
NAME="AEN1518"
|
|
></A
|
|
>them. You can make a directory <A
|
|
NAME="AEN1520"
|
|
></A
|
|
>name with a space<A
|
|
NAME="AEN1522"
|
|
></A
|
|
> in it using a backslash before the space. For example you could type <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>cd</I
|
|
></SPAN
|
|
> <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>My</I
|
|
></SPAN
|
|
>\<SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
> Directory</I
|
|
></SPAN
|
|
>\<SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
> With</I
|
|
></SPAN
|
|
>\<SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
> Spaces</I
|
|
></SPAN
|
|
> which normally wouldn't work. </P
|
|
><P
|
|
>The “\” character <A
|
|
NAME="AEN1530"
|
|
></A
|
|
>can also be used to stop <A
|
|
NAME="AEN1532"
|
|
></A
|
|
>bash <A
|
|
NAME="AEN1534"
|
|
></A
|
|
>from expanding <A
|
|
NAME="AEN1536"
|
|
></A
|
|
>certain symbols<A
|
|
NAME="AEN1538"
|
|
></A
|
|
> (as an alternative <A
|
|
NAME="AEN1540"
|
|
></A
|
|
>you could use single quotation <A
|
|
NAME="AEN1542"
|
|
></A
|
|
>marks, although you may need to use both).</P
|
|
><DIV
|
|
CLASS="TIP"
|
|
><BLOCKQUOTE
|
|
CLASS="TIP"
|
|
><P
|
|
><B
|
|
>The TAB Key<A
|
|
NAME="AEN1546"
|
|
></A
|
|
>: </B
|
|
>Please note that using the TAB key (automatic-command-completion) will automatically use escapes for spaces (so you don't have to type them manually).</P
|
|
></BLOCKQUOTE
|
|
></DIV
|
|
></DD
|
|
><DT
|
|
>script</DT
|
|
><DD
|
|
><P
|
|
><A
|
|
NAME="AEN1553"
|
|
></A
|
|
>The “<SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>script</I
|
|
></SPAN
|
|
>” command creates a typescript,<A
|
|
NAME="AEN1556"
|
|
></A
|
|
> or "capture log" of a shell session - it writes a copy <A
|
|
NAME="AEN1558"
|
|
></A
|
|
>of your session <A
|
|
NAME="AEN1560"
|
|
></A
|
|
>to a file, including <A
|
|
NAME="AEN1562"
|
|
></A
|
|
>commands you type and their output.</P
|
|
></DD
|
|
><DT
|
|
>~ (tilde character)</DT
|
|
><DD
|
|
><P
|
|
><A
|
|
NAME="AEN1568"
|
|
></A
|
|
>The tilde <A
|
|
NAME="AEN1570"
|
|
></A
|
|
>character <A
|
|
NAME="AEN1572"
|
|
></A
|
|
>is used as an alias to a users home directory. </P
|
|
><P
|
|
>For example, if your user-name <A
|
|
NAME="AEN1575"
|
|
></A
|
|
>was “fred”, instead of typing<SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
> cd /home/fred </I
|
|
></SPAN
|
|
>you could simply type<SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
> cd <A
|
|
NAME="AEN1579"
|
|
></A
|
|
>~. </I
|
|
></SPAN
|
|
>Or to get to fred's tmp directory (under his home <A
|
|
NAME="AEN1581"
|
|
></A
|
|
>directory) you could type<SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
> cd <A
|
|
NAME="AEN1584"
|
|
></A
|
|
>~/tmp.</I
|
|
></SPAN
|
|
></P
|
|
><DIV
|
|
CLASS="TIP"
|
|
><BLOCKQUOTE
|
|
CLASS="TIP"
|
|
><P
|
|
><B
|
|
>Home directory shortcut: </B
|
|
>~ (tilde) can also be used as a shortcut to other users home directories, simply type: <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>~user_name</I
|
|
></SPAN
|
|
> and it will take you to the users home directory. Note that you need to spell the username exactly correct, no wildcards.</P
|
|
></BLOCKQUOTE
|
|
></DIV
|
|
></DD
|
|
><DT
|
|
></DT
|
|
><DD
|
|
><P
|
|
> </P
|
|
></DD
|
|
><DT
|
|
>set bell-style none</DT
|
|
><DD
|
|
><P
|
|
><A
|
|
NAME="AEN1598"
|
|
></A
|
|
>This particular <A
|
|
NAME="AEN1600"
|
|
></A
|
|
><SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>set</I
|
|
></SPAN
|
|
> command will turn off <A
|
|
NAME="AEN1603"
|
|
></A
|
|
>the system bell<A
|
|
NAME="AEN1605"
|
|
></A
|
|
> from the command-line <A
|
|
NAME="AEN1607"
|
|
></A
|
|
>(use xset <A
|
|
NAME="AEN1609"
|
|
></A
|
|
>-b for X windows). If you want the bell <A
|
|
NAME="AEN1611"
|
|
></A
|
|
>to stay off pernamently (no audible <A
|
|
NAME="AEN1613"
|
|
></A
|
|
>bell) then you can add this command to your “.bashrc” or “.bash_profile” (just add it to the same one you have your alises in...).</P
|
|
></DD
|
|
><DT
|
|
>reset</DT
|
|
><DD
|
|
><P
|
|
><A
|
|
NAME="AEN1619"
|
|
></A
|
|
>The <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>reset</I
|
|
></SPAN
|
|
> command re-initializes your current terminal.<A
|
|
NAME="AEN1622"
|
|
></A
|
|
> This can be useful when the text <A
|
|
NAME="AEN1624"
|
|
></A
|
|
>from your terminal <A
|
|
NAME="AEN1626"
|
|
></A
|
|
> becomes garbled,<A
|
|
NAME="AEN1628"
|
|
></A
|
|
> simply type “reset” and this will fix <A
|
|
NAME="AEN1630"
|
|
></A
|
|
>your terminal.</P
|
|
></DD
|
|
><DT
|
|
>exit</DT
|
|
><DD
|
|
><P
|
|
><A
|
|
NAME="AEN1636"
|
|
></A
|
|
>Closes your current terminal (with x-terminals) or logs-out.<A
|
|
NAME="AEN1638"
|
|
></A
|
|
> Also try
|
|
<B
|
|
CLASS="KEYCAP"
|
|
>CTRL</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>D</B
|
|
>
|
|
<A
|
|
NAME="AEN1643"
|
|
></A
|
|
>
|
|
.</P
|
|
></DD
|
|
><DT
|
|
>logout</DT
|
|
><DD
|
|
><P
|
|
><A
|
|
NAME="AEN1649"
|
|
></A
|
|
>Logs out of a terminal, also try
|
|
<B
|
|
CLASS="KEYCAP"
|
|
>CTRL</B
|
|
>-<B
|
|
CLASS="KEYCAP"
|
|
>D</B
|
|
>
|
|
<A
|
|
NAME="AEN1654"
|
|
></A
|
|
>
|
|
.</P
|
|
></DD
|
|
><DT
|
|
>echo</DT
|
|
><DD
|
|
><P
|
|
><A
|
|
NAME="AEN1660"
|
|
></A
|
|
>A little command that repeats <A
|
|
NAME="AEN1662"
|
|
></A
|
|
>anything you type.</P
|
|
><P
|
|
>Example:</P
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
>echo “hello world”</PRE
|
|
><P
|
|
>Simply displays “ hello world”. </P
|
|
><P
|
|
>Example:</P
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
>echo rm -R *</PRE
|
|
><P
|
|
>This will output what will be passed <A
|
|
NAME="AEN1670"
|
|
></A
|
|
>to the <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>rm<A
|
|
NAME="AEN1673"
|
|
></A
|
|
></I
|
|
></SPAN
|
|
> command (and therefore what would be deleted), putting <A
|
|
NAME="AEN1675"
|
|
></A
|
|
>echo before a command renders <A
|
|
NAME="AEN1677"
|
|
></A
|
|
>it harmless <A
|
|
NAME="AEN1679"
|
|
></A
|
|
>(it just expands <A
|
|
NAME="AEN1681"
|
|
></A
|
|
>wildcards so you know what it will do).</P
|
|
><P
|
|
>Also try using the<SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
> -e <A
|
|
NAME="AEN1685"
|
|
></A
|
|
></I
|
|
></SPAN
|
|
> option <A
|
|
NAME="AEN1687"
|
|
></A
|
|
>with echo.<A
|
|
NAME="AEN1689"
|
|
></A
|
|
> This will allow <A
|
|
NAME="AEN1691"
|
|
></A
|
|
>you to use the escape <A
|
|
NAME="AEN1693"
|
|
></A
|
|
>character sequences<A
|
|
NAME="AEN1695"
|
|
></A
|
|
> to format <A
|
|
NAME="AEN1697"
|
|
></A
|
|
>the output of a line.<A
|
|
NAME="AEN1699"
|
|
></A
|
|
> Such as '\t' for tab,<A
|
|
NAME="AEN1701"
|
|
></A
|
|
> '\n' for newline <A
|
|
NAME="AEN1703"
|
|
></A
|
|
>etc.</P
|
|
><DIV
|
|
CLASS="TIP"
|
|
><BLOCKQUOTE
|
|
CLASS="TIP"
|
|
><P
|
|
><B
|
|
>Using echo to prevent accidents: </B
|
|
>Typing: <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>echo command(s) </I
|
|
></SPAN
|
|
>could<SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
> </I
|
|
></SPAN
|
|
>save you the trouble of accidentally doing something you didn't expect.</P
|
|
><P
|
|
>
|
|
Using <SPAN
|
|
CLASS="emphasis"
|
|
><I
|
|
CLASS="EMPHASIS"
|
|
>echo</I
|
|
></SPAN
|
|
> allows you to expand the wildcards to understand what will happen before you actually run the command. </P
|
|
></BLOCKQUOTE
|
|
></DIV
|
|
></DD
|
|
></DL
|
|
></DIV
|
|
></DIV
|
|
></DIV
|
|
><H3
|
|
CLASS="FOOTNOTES"
|
|
>Notes</H3
|
|
><TABLE
|
|
BORDER="0"
|
|
CLASS="FOOTNOTES"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
VALIGN="TOP"
|
|
WIDTH="5%"
|
|
><A
|
|
NAME="FTN.AEN1248"
|
|
HREF="c1195.htm#AEN1248"
|
|
><SPAN
|
|
CLASS="footnote"
|
|
>[1]</SPAN
|
|
></A
|
|
></TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
VALIGN="TOP"
|
|
WIDTH="95%"
|
|
><P
|
|
>This information was adopted (with editing) from Mandrakesoft's Command Line Manual, see [7] in the <A
|
|
HREF="b12722.htm"
|
|
><I
|
|
>Bibliography</I
|
|
></A
|
|
> for further information.</P
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
SUMMARY="Footer navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="c1089.htm"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="book1.htm"
|
|
ACCESSKEY="H"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x1712.htm"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>The Unix Tools Philosophy</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
> </TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>The command-line history</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |