Using Bash Shell
2/19 20:13:11 CST 2004
==============================
Get Your Information
echo display a line of text
type get the path of a command
finger user information lookup program
pwd print working directory
[eg] echo $SHELL
finger -l username
Setup Your Shell
Some important setup files are:
/etc/profile
/etc/bashrc
~/.bash_profile
~/.bashrc
~/.bash_logout
You can setup prompt characers, add enviroment varialbes, and add alias.
[eg] alias p='pwd; ls -CF'
alias rm='rm -i'
By default, the bash shell command line editor is based on emacs. If you want to use vi as the command line editor, you need only add the follow statement in the .bashrc file:
set -o vi
Some examples of using enviromental variables:
[eg] AB=/usr/dog; export AB
cd $AB
[example:] export PATH=$PATH:/home/xyz
You can use "unset" command to cancel an enviromental variable.
Command History
Command history is stored in .bash_history file. Commands are:
history
!n
!!
!?string?
fc using text editor to edit history command.
Some Special Characters
#
& running in background
' [eg] alias dir='ls-al'
*
?
[ and ]
-
!
/
[eg] ls [xyz]*
ls *[!0-9]
.
..
; seperate several commands
[eg] date; troff -me largedoc | lpr; date
>
>>
| [eg] cat /etc/password | sort | more
~ home direcroty
@
$
$(command)
'command' treat the command output as arguments of another command.
[eg] vi $(find /home -print | grep xyzzy)
Manage Running Jobs
Programs can running background or foreground.
&
at
Ctrl+z pause running program
Ctrl+c cancel running program
fg [eg] fg %5
bg resume suspended job background
jobs list the programs running background
ps
[eg] pasue the running program, and make it running background:
find / -name SCSI -print
Ctrl+z
bg
2/19 20:13:11 CST 2004
==============================
Get Your Information
echo display a line of text
type get the path of a command
finger user information lookup program
pwd print working directory
[eg] echo $SHELL
finger -l username
Setup Your Shell
Some important setup files are:
/etc/profile
/etc/bashrc
~/.bash_profile
~/.bashrc
~/.bash_logout
You can setup prompt characers, add enviroment varialbes, and add alias.
[eg] alias p='pwd; ls -CF'
alias rm='rm -i'
By default, the bash shell command line editor is based on emacs. If you want to use vi as the command line editor, you need only add the follow statement in the .bashrc file:
set -o vi
Some examples of using enviromental variables:
[eg] AB=/usr/dog; export AB
cd $AB
[example:] export PATH=$PATH:/home/xyz
You can use "unset" command to cancel an enviromental variable.
Command History
Command history is stored in .bash_history file. Commands are:
history
!n
!!
!?string?
fc using text editor to edit history command.
Some Special Characters
#
& running in background
' [eg] alias dir='ls-al'
*
?
[ and ]
-
!
/
[eg] ls [xyz]*
ls *[!0-9]
.
..
; seperate several commands
[eg] date; troff -me largedoc | lpr; date
>
>>
| [eg] cat /etc/password | sort | more
~ home direcroty
@
$
$(command)
'command' treat the command output as arguments of another command.
[eg] vi $(find /home -print | grep xyzzy)
Manage Running Jobs
Programs can running background or foreground.
&
at
Ctrl+z pause running program
Ctrl+c cancel running program
fg [eg] fg %5
bg resume suspended job background
jobs list the programs running background
ps
[eg] pasue the running program, and make it running background:
find / -name SCSI -print
Ctrl+z
bg
本文介绍了BashShell的基础使用技巧,包括获取系统信息、设置个性化提示符、利用环境变量简化命令输入等。此外,还提供了如何管理和查看运行中的任务的方法。
171

被折叠的 条评论
为什么被折叠?



