old-www/HOWTO/XWindow-User-HOWTO/cli.html

580 lines
12 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>X and the Command Line</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><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"
></A
>7. X and the Command Line</H1
><P
>&#13; 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.
</P
><P
>&#13; 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
>&#13; 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
>&#13; <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
>-display <EM
>[host]:display[.screen]</EM
></DT
><DD
><P
>&#13; 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
>&#13; 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
>&#13; 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
>&#13; 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
>&#13; The color to use for the window foreground (i.e. fonts, etc).
</P
></DD
><DT
>-name <EM
>resource-name</EM
></DT
><DD
><P
>&#13; 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
>&#13; 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
>&#13; Open window in an iconified state.
</P
></DD
><DT
>-xrm <EM
>resource-string</EM
></DT
><DD
><P
>&#13; 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
>&#13; 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
>&#13; <TABLE
BORDER="0"
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="AEN1177"
></A
>7.1. xterm and friends</H2
><P
>&#13; 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.
</P
><P
>&#13; 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
>.
</P
><P
>&#13; 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.
</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
>:
</P
><P
>&#13; <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;
$ echo $TERM
xterm
</PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>&#13; 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 will not 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.
</P
><P
>&#13; 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.
</P
><P
>&#13; 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.
</P
><P
>&#13; Terminal emulators like <B
CLASS="command"
>xterm</B
> require a monospaced font.
So forget about TrueType or Type 1 fonts.
</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
>