Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > 965e33040dd61030a94f0eb89877aee8 > files > 7218

howto-html-en-20080722-2mdv2010.1.noarch.rpm

<HTML
><HEAD
><TITLE
>X and the Command Line</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="The X Window User HOWTO"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="Window Managers and Desktops"
HREF="windowman.html"><LINK
REL="NEXT"
TITLE="X Networking and Security"
HREF="xsecurity.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>The X Window User HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="windowman.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="xsecurity.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="CLI">7. X and the Command Line</H1
><P
> What would a Unix-like operating system be without a command line 
 interface?  The command line can be useful, and is readily available with
 <SPAN
CLASS="APPLICATION"
>X</SPAN
>. In fact, for many it is an integral part 
 of their <SPAN
CLASS="APPLICATION"
>X</SPAN
> working environment. &#13;</P
><P
> Any <SPAN
CLASS="APPLICATION"
>X</SPAN
> program can be started directly from the
 command line just by typing the program name at a shell prompt in an
 <B
CLASS="COMMAND"
>xterm</B
>, or other terminal window. Most applications will
 have a very rich set of command line <SPAN
CLASS="QUOTE"
>"options"</SPAN
>, such as
 background color, font, geometry (screen placement), etc, etc. Command line
 options over-ride compiled in defaults, or other system enabled
 <SPAN
CLASS="QUOTE"
>"resources"</SPAN
>.
 </P
><P
> Many traditional <SPAN
CLASS="APPLICATION"
>X</SPAN
> programs will use the same
 basic names for command line options. All applications written using the 
 MIT X Toolkit Intrinsics (Xt) (such as those included with XFree86)
 automatically accept the following options. Some non-Xt applications also use
 these, or something similar. For instance, <SPAN
CLASS="QUOTE"
>"geometry"</SPAN
> is close 
 to a universally accepted option.</P
><P
> <P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>-display <EM
>[host]:display[.screen]</EM
></DT
><DD
><P
>    This option specifies the X server display to use. This is often used 
    where applications are run on one system, and displayed on another. The 
    application needs to know <EM
>where</EM
> to display. This 
    is sometimes also accomplished by setting the <SPAN
CLASS="QUOTE"
>"$DISPLAY"</SPAN
> 
    variable, which uses the same syntax.
   </P
></DD
><DT
>-geometry <EM
>geometry</EM
></DT
><DD
><P
>    The initial size and location of the window, in a format such as
    <TT
CLASS="LITERAL"
>width x height +horz_offset +vert_offset</TT
> or
    <TT
CLASS="LITERAL"
>+horz_offset -vert_offset</TT
>. Note that if you put in a
    negative horizontal or vertical offset, the window will be placed counting
    backward from the right or the bottom of the screen, respectively, instead
    of from the top left corner.
   </P
></DD
><DT
>-font <EM
>fontname</EM
></DT
><DD
><P
>    The font to use for displaying the text in your window (see font section
    below).
   </P
></DD
><DT
>-bg <EM
>color</EM
></DT
><DD
><P
>    The color to use for the window background. Typically this is a
    <SPAN
CLASS="QUOTE"
>"color name"</SPAN
> (see below).
   </P
></DD
><DT
>-fg <EM
>color</EM
></DT
><DD
><P
>    The color to use for the window foreground (i.e. fonts, etc).
   </P
></DD
><DT
>-name <EM
>resource-name</EM
></DT
><DD
><P
>    Useful for specifying the name under which the resources for this
    application will be found (e.g. as specified in
    <TT
CLASS="FILENAME"
>.Xdefaults</TT
>). This is useful to distinguish between
    invocations of the same application. For example, two
    <B
CLASS="COMMAND"
>xterms</B
> can be <SPAN
CLASS="QUOTE"
>"named"</SPAN
> differently so that
    they may inherit different resources based upon the specified names in
    the resource database.
   </P
></DD
><DT
>-title <EM
>string</EM
></DT
><DD
><P
>    This is the title to be used for the window on your display, generally used
    by the Window Manager to put a descriptive title at the top of the window.
    Not to be confused with the <SPAN
CLASS="QUOTE"
>"-name"</SPAN
> option.
   </P
></DD
><DT
>-iconic</DT
><DD
><P
>    Open window in an iconified state.
   </P
></DD
><DT
>-xrm <EM
>resource-string</EM
></DT
><DD
><P
>    This option specifies a resource name and value to override any defaults
    that may already be set (i.e. via <TT
CLASS="FILENAME"
>.Xresources</TT
> or
    similar). Also useful for setting <SPAN
CLASS="APPLICATION"
>X</SPAN
> resources
    that do not have explicit command line options. For example, the command
    line <SPAN
CLASS="QUOTE"
>"xterm -xrm xterm*background: blue &#38;"</SPAN
> is
    functionally the same as <SPAN
CLASS="QUOTE"
>"xterm -bg blue &#38;"</SPAN
>.
   </P
></DD
></DL
></DIV
></P
><P
> These are the most noteworthy. There are others. Many programs will have
 their own additional options that are application specific. Many newer
 applications today don't necessarily adhere to the Xt standards, and will use
 their own options, or those provided by their respective toolkit.
 If nothing else, man pages are a good reference for command syntax, and are
 your friends here. Or, the application will have a <SPAN
CLASS="QUOTE"
>"--usage"</SPAN
> or 
 <SPAN
CLASS="QUOTE"
>"--help"</SPAN
> command line switch to list available options:
 </P
><P
> <TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>&#13; $ gnome-terminal --usage
 Usage: gnome-terminal [-?] [--disable-sound] [--enable-sound]
   [--espeaker=HOSTNAME:PORT] [--version] [--usage] [--gdk-debug=FLAGS]
   [--gdk-no-debug=FLAGS] [--display=DISPLAY] [--sync] [--no-xshm]
   [--name=NAME] [--class=CLASS] [--gxid_host=HOST] [--gxid_port=PORT]
   [--xim-preedit=STYLE] [--xim-status=STYLE] [--gtk-debug=FLAGS]
   [--gtk-no-debug=FLAGS] [--g-fatal-warnings] [--gtk-module=MODULE]
   [--disable-crash-dialog] [--sm-client-id=ID] [--sm-config-prefix=PREFIX]
   [--sm-disable] [--tclass=TCLASS] [--font=FONT] [--nologin] [--login]
   [--geometry=GEOMETRY] [-e COMMAND] [-x COMMAND] [--foreground=COLOR]
   [--background=COLOR] [--solid] [--pixmap=PIXMAP] [--bgscroll]
   [--bgnoscroll] [--shaded] [--noshaded] [--transparent] [--utmp]
   [--noutmp] [--wtmp] [--nowtmp] [--lastlog] [--nolastlog] [-t TITLE]
   [--icon=ICON] [--termname=TERMNAME] [--start-factory-server]
   [--use-factory]

 </PRE
></FONT
></TD
></TR
></TABLE
></P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1133">7.1. xterm and friends</H2
><P
> Sooner or later, most of us need to access the <SPAN
CLASS="QUOTE"
>"command line"</SPAN
> 
 for one reason or another. For some, this might even be a common way of
 working in <SPAN
CLASS="APPLICATION"
>X</SPAN
>. In addition to being able to launch 
 <SPAN
CLASS="APPLICATION"
>X</SPAN
> applications from the command prompt, there
 is also a wealth of programs that run in <SPAN
CLASS="QUOTE"
>"text mode"</SPAN
> for
 Linux. &#13;</P
><P
> This is possible via <SPAN
CLASS="QUOTE"
>"terminal emulators"</SPAN
> such as
 <B
CLASS="COMMAND"
>xterm</B
>. The closest counterpart from Microsoft is the
 so-called DOS-box, which is child's play by comparison. Linux terminals support
 color, full mouse copy/paste (and some wheeled mice), pseudo-transparency and
 pixmap backgrounds, scrollbars, menus and generally a slew of other 
 features. While <B
CLASS="COMMAND"
>xterm</B
> is the best known such terminal 
 emulator, there are many similar programs. To name a few:
 <B
CLASS="COMMAND"
>Eterm</B
>, <B
CLASS="COMMAND"
>rxvt</B
>,
 <B
CLASS="COMMAND"
>aterm</B
>, <B
CLASS="COMMAND"
>konsole</B
>
 (<SPAN
CLASS="APPLICATION"
>KDE</SPAN
>) and <B
CLASS="COMMAND"
>gnome-terminal</B
>.&#13;</P
><P
>  In typical usage, when a terminal emulator window is opened, a shell is
  started for the user to interact with. The default for essentially all
  Linuxes, is the <SPAN
CLASS="APPLICATION"
>bash</SPAN
> shell. So when all is said
  and done, the user is interacting with <SPAN
CLASS="APPLICATION"
>X</SPAN
>, the
  terminal, and the shell all at once. Each may have it's own influence. For
  example, how keystrokes are handled since they move from hardware to X
  server to terminal to the shell and finally echoed back to the user.&#13;</P
><P
> 
 Quick and easy terminal configuration is done via the <SPAN
CLASS="QUOTE"
>"$TERM"</SPAN
> 
 variable, which is typically set in one of the user's shell configuration
 files. Or the terminal itself will have a compiled in default. The default
 value for this is most often <SPAN
CLASS="QUOTE"
>"xterm"</SPAN
>:&#13;</P
><P
> <TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>&#13; $ echo $TERM
 xterm

 </PRE
></FONT
></TD
></TR
></TABLE
></P
><P
> Normally this is sufficient, as your vendor has already set this up in a
 reasonable way. The <SPAN
CLASS="QUOTE"
>"$TERM"</SPAN
> variable is actually a reference to
 an entry in the <SPAN
CLASS="QUOTE"
>"termcap"</SPAN
> database (man termcap), which is
 typically installed as <TT
CLASS="FILENAME"
>/etc/termcap</TT
>. Unless you are
 doing something really unusual, you probably won't need to change this.
 Some additional terminal configuration can be done with the
 <B
CLASS="COMMAND"
>stty</B
> command (see man page). Terminal configuration is
 really beyond the scope of this document.&#13;</P
><P
> The terminal application itself (e.g. <B
CLASS="COMMAND"
>xterm</B
>) will also
 have various configuration options. Permanent settings are best stored in 
 a <TT
CLASS="FILENAME"
>~/.Xdefaults</TT
> or similar file for those applications 
 that support this. Generally speaking, applications with a GUI configuration 
 (such as <B
CLASS="COMMAND"
>gnome-terminal</B
>), will be configured by their own
 menu driven configuration instead.&#13;</P
><P
> Also, you are interacting with the shell too, which can have it's own impact,
 particularly on how keystrokes are handled at the shell prompt. For
 <SPAN
CLASS="APPLICATION"
>bash</SPAN
>, this can be adjusted in
 <TT
CLASS="FILENAME"
>~/.inputrc</TT
>. Again, this is beyond the scope of this
 document, but check with either local or on-line
 <SPAN
CLASS="APPLICATION"
>bash</SPAN
> (or other shell) references.&#13;</P
><P
> Terminal emulators like <B
CLASS="COMMAND"
>xterm</B
> require a monospaced font.
 So forget about TrueType or Type 1 fonts. &#13;</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="windowman.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="xsecurity.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Window Managers and Desktops</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><SPAN
CLASS="APPLICATION"
>X</SPAN
> Networking and Security</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>