rhl10.htm

来自「linux的初学电子书」· HTM 代码 · 共 1,898 行 · 第 1/4 页

HTM
1,898 行
字号
<BR>

<BR>

<PRE>

<FONT COLOR="#000080">02:16:30\</FONT></PRE>

<P>In this case, there would be a space following the prompt because there was a space within the quotation marks.

<BR>

<BR>

<A NAME="E69E174"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Job Control</B></FONT></CENTER></H4>

<BR>

<P>Job control refers to the ability to control the execution behavior of a currently running process. Specifically, you can suspend a running process and cause it to resume running at a later time. bash keeps track of all of the processes that it started 
(as a result of user input), and you can suspend a running process or restart a suspended one at any time during the life of that process.

<BR>

<P>Pressing Ctrl-Z suspends a running process. The bg command restarts a suspended process in the background, whereas the fg command restarts a process in the foreground.

<BR>

<P>These commands are most often used when a user wants to run a command in the background but by accident starts it in the foreground. When a command is started in the foreground, it locks the shell from any further user interaction until the command 
completes execution. This is usually no problem because most commands only take a few seconds to execute. If the command you are running is going to take a long time, though, you would typically start the command in the background so that you could 
continue to use bash to enter other commands in the foreground.

<BR>

<P>For example, if you started the command find / -name &quot;test&quot; &gt; find.out (which will scan the entire filesystem for files named test and store the results in a file called find.out) in the foreground, your shell may be tied up for many 
seconds or even minutes, depending on the size of the filesystem and the number of users on the system. If you had issued this command and wanted to continue executing in the background so you could use the system again, you would enter the following:

<BR>

<PRE>

<FONT COLOR="#000080">control-z

bg</FONT></PRE>

<P>This would first suspend the find command, then restart it in the background. The find command would continue to execute, and you would have bash back again.

<BR>

<BR>

<A NAME="E68E65"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Customizing </B><B>bash</B></FONT></CENTER></H3>

<BR>

<P>Many ways of customizing bash have already been described in this chapter. Until now, the changes that you made affected only the current bash session. As soon as you quit, all of the customizations that you made will be lost. You can make the 
customizations more permanent by storing them in a bash initialization file.

<BR>

<P>You can put any commands that you want to be executed each time bash is started into this initialization file. Commands that are typically found in this file are alias commands and variable initializations.

<BR>

<P>The bash initialization file is named profile. Each user who uses bash has a .profile file in his home directory. This file is read by bash each time it starts, and all of the commands contained within it are executed.

<BR>

<P>The following code shows the default .profile file. This file is located in the /etc directory and is read when you start bash. If you want to add your own customizations to bash, you must copy this file into your home directory (if it is not already 
there) and call it .profile.

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE>Some setup programs make a copy of the .profile file in your home directory for you automatically when they create your login. However, not all routines do this, so you should check your home directory first. Remember that all files starting with a 
period are hidden and can only be displayed with the ls -A or ls -a command.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<PRE>

<FONT COLOR="#000080"># commands common to all logins

export OPENWINHOME=/usr/openwin

export MINICOM=&quot;-c on&quot;

export MANPATH=/usr/local/man:/usr/man/preformat:/usr/man:/X11/man:/usr/openwin/man

export HOSTNAME=&quot;'cat /etc/HOSTNAME'&quot;

PATH=&quot;$PATH:/usr/X11/bin:$OPENWINHOME/bin:/usr/games:.&quot;

LESS=-MM

# I had problems using 'eval test' instead of 'TERM=', but you might want to

<BR># try it anyway. I think with the right /etc/termcap it would work great. 

<BR># eval 'tset -sQ &quot;$TERM&quot;'if [ &quot;$TERM&quot; = &quot;&quot; -o &quot;$TERM&quot; = &quot;unknown&quot;]; then

TERM=linux

fi

#PS1=''hostname':'pwd'# '

if [ &quot;$SHELL&quot; = &quot;/bin/pdksh&quot; -o &quot;$SHELL&quot; = &quot;/bin/ksh&quot; ]; then

PS1=&quot;! $&quot;

elif [ &quot;$SHELL&quot; = &quot;/bin/zsh&quot; ]; then

PS1=&quot;%m:%~%# &quot;

elif [ &quot;$SHELL&quot; = &quot;/bin/ash&quot; ]; then

PS1=&quot;$ &quot;

else

PS1='\h:\w\$ '

fi

PS2='&gt; '

ignoreeof=10

export PATH DISPLAY LESS TERM PS1 PS2 ignoreeof

umask 022

# set up the color-ls environment variables:

if [ &quot;$SHELL&quot; = &quot;/bin/zsh&quot; l; then

eval 'dircolors -z'

elif [ &quot;$SHELL&quot; = &quot;/bin/ash&quot; l; then

eval 'dircolors -s'

else

eval 'dircolors -b'

fi

echo

fortune

echo

export TAPE=&quot;/dev/nftape&quot;</FONT></PRE>

<BR>

<A NAME="E68E66"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>bash</B><B> Command Summary</B></FONT></CENTER></H3>

<BR>

<P>Here are some of the most useful commands built into the bash shell:

<BR>

<UL>

<UL>

<P>alias: Used to set bash aliases (command nicknames that can be defined by the user).

<BR>

</UL></UL>

<UL>

<UL>

<P>bg: Background command. Forces a suspended process to continue to execute in the background.

<BR>

</UL></UL>

<UL>

<UL>

<P>cd: Change working directory. This command changes the current working directory to the directory specified as an argument.

<BR>

</UL></UL>

<UL>

<UL>

<P>exit: Terminates the shell.

<BR>

</UL></UL>

<UL>

<UL>

<P>export: Causes the value of a variable to be made visible to all subprocesses that belong to the current shell.

<BR>

</UL></UL>

<UL>

<UL>

<P>fc: Fix command. Used to edit the commands in the current history list.

<BR>

</UL></UL>

<UL>

<UL>

<P>fg: Foreground command. Forces a suspended process to continue to execute in the foreground.

<BR>

</UL></UL>

<UL>

<UL>

<P>help: Displays help information for bash built-in commands.

<BR>

</UL></UL>

<UL>

<UL>

<P>history: Brings up a list of the last n commands that were entered at the command prompt, where n is a configurable variable specifying the number of commands to remember.

<BR>

</UL></UL>

<UL>

<UL>

<P>kill: Used to terminate another process.

<BR>

</UL></UL>

<UL>

<UL>

<P>pwd: Print working directory. Prints the directory in which the user is currently working.

<BR>

</UL></UL>

<UL>

<UL>

<P>unalias: Used to remove aliases that have been defined using the alias command.

<BR>

</UL></UL>

<P>bash has many more commands than are listed here, but these are the most frequently used ones. To see the other commands bash offers and for more details of the commands listed, refer to the bash man page (type man bash).

<BR>

<BR>

<A NAME="E68E67"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>bash</B><B> Variables</B></FONT></CENTER></H3>

<BR>

<P>Here are some of the most useful bash variables, including the variable name and a brief description:

<BR>

<UL>

<UL>

<P>EDITOR, FCEDIT: The default editor for the fc bash command.

<BR>

</UL></UL>

<UL>

<UL>

<P>HISTFILE: The file used to store the command history.

<BR>

</UL></UL>

<UL>

<UL>

<P>HISTSIZE: The size of the history list.

<BR>

</UL></UL>

<UL>

<UL>

<P>HOME: The HOME directory of the current user

<BR>

</UL></UL>

<UL>

<UL>

<P>OLDPWD: The previous working directory (the one that was current before the current directory was entered).

<BR>

</UL></UL>

<UL>

<UL>

<P>PATH: The search path that bash uses when looking for executable files

<BR>

</UL></UL>

<UL>

<UL>

<P>PS1: The first-level prompt that is displayed on the command line

<BR>

</UL></UL>

<UL>

<UL>

<P>PS2: The second-level prompt that is displayed when a command is expecting more input

<BR>

</UL></UL>

<UL>

<UL>

<P>PWD: The current working directory

<BR>

</UL></UL>

<UL>

<UL>

<P>SECONDS: The number of seconds that have elapsed since the current bash session was started

<BR>

</UL></UL>

<P>bash has many more variables than are listed here, but the most commonly used ones are shown. To find out what other variables bash offers, call the man page with the command man bash.

<BR>

<BR>

<A NAME="E68E68"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Summary</B></FONT></CENTER></H3>

<BR>

<P>In this chapter you looked at some of the useful features of the Bourne Again Shell, bash. You have seen how command completion, aliasing, and job control can all combine to make you more productive and efficient when working with bash.

<BR>

<P>In the next chapter you will look at another popular Linux shell, the Public Domain Korn Shell (pdksh). It offers many useful features, too, providing you with a choice of shells.<A NAME="I2"></A>

<P ALIGN=LEFT>

<A HREF="rhl09.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl09.htm" TARGET="_self"><IMG SRC="purprev.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>

<A HREF="#I0" TARGET="_self"><IMG SRC="purtop.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtop.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Page Top"></A>

<A HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm" TARGET="_self"><IMG SRC="purtoc.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>

<A HREF="rhl11.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl11.htm" TARGET="_self"><IMG SRC="purnext.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>


</BODY></HTML>



⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?