Advanced Shell Features

If useful shell features such as command history and completion intrigue you, just wait! This section highlights some of the other powerful capabilities that are built into the bash shell. Most of these features are present in the other shells discussed earlier in this chapter, but this section focuses on bash because it is the standard shell used on Linux systems.

| f - - r You may want to skip over this section if you are new to Linux and are just trying to learn how to perform some standard tasks. When you have become more experienced with Linux, you can always come back and read this section to find out how to get even more power out of the Linux command line.

Environment Variables

As you can guess from the discussion of command history in the previous section, the bash shell maintains a significant amount of information about the commands that it has executed, the settings for various configuration parameters, the environment in which it is operating, and so on. Much of this information is stored in variables in the shell environment, which are therefore known as environment variables. You can display all of the environment variables set within your current shell and their definitions by typing the env command, as in the following example (partial output shown):

LESSKEY=/etc/lesskey.bin

INFODIR=/usr/local/info:/usr/share/info:/usr/info

MANPATH=/usr/local/man:/usr/share/man

HOSTNAME=flamingo

XKEYSYMDB=/usr/share/X11/XKeysymDB

HOST=flamingo

TERM=xterm

SHELL=/bin/bash

PROFILEREAD=true

HISTSIZE=1000

MORE=-sl

USER=roger

ENV=/etc/bash.bashrc

HOSTTYPE=i386

PAGER=less

PATH=/home/roger/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:

/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/jvm/jre/bin

CPU=i686

JAVA_BINDIR=/usr/lib/jvm/jre/bin

INPUTRC=/home/roger/.inputrc

PWD=/home/roger

LANG=en_GB.UTF-8

HOME=/home/roger

WINDOWMANAGER=/usr/bin/kde

LOGNAME=roger

INFOPATH=/usr/local/info:/usr/share/info:/usr/info

DISPLAY=localhost:0.0

COLORTERM=1

The names of environment variables are normally in uppercase, sometimes including underscores. For example, the HOME environment variable represents the current user's home directory.

To get the value of HOME, use the following:

Was this article helpful?

0 0

Post a comment