BASHing Your Way Through Linux
What Is A Shell?
Why Do I Care About The Shell?
Shell History
Setting The Default Editor
Customizing The Workspace
Shell Scripts
BASHing Through The Directories
What Is A Shell?
Paraphrased from Learning the Korn Shell by Bill Rosenblatt
A shell is any program that takes input from the user, translates it into instructions that the operating system can understand, and conveys the operating system's output back to the user.
- i.e. Any User Interface
- Character Based vs. Graphics Based
Why Do I Care About The Shell?
- Shell is Not Integral Part of OS
- UNIX Among First to Separate
- Compare to MS-DOS, Mac, Win95, VM/CMS, OS/2?
- GUI is NOT Required (So you can configure your system to fit your work environment. Why have a fancy GUI for a file server?)
- Default Shell Can Be Configured
- chsh -s /bin/bash
- /etc/passwd
- Helps To Customize Environment
Shell History
Common Shells
- Bourne - Steven Bourne ~1979 (sh)
- C - Bill Joy ~1981 (csh)
- Korn - David Korn ~1986 (ksh)
Free Versions
- (bash) Korn
- (tcsh) C
- (pdksh) Korn
Setting The Default Editor
- Why? Familiar Keystrokes for Command Editing
- set -o vi
- set -o emacs
- Demo of vi keystrokes
- ESC
- k,j,l,h
- \ (file completion)
- * (file expansion)
- Refer to vi command set for more
Customizing The Workspace
- Environment Variables
- PWD
- OLDPWD
- HOME
- PATH
- CDPATH
- alias (alias ls='ls -F')
- function (function myls() {clear; echo Customized List; ls -F})
- .bash_profile & /etc/profile (bash_profile?) ('set -o vi' might go here)
Shell Scripts
#!/bin/bash
while
true
do
cat somefile > /dev/null
echo .
done
- ctrl-C to stop a job
- ctrl-Z to suspend a job
- ps vs. jobs
- bg and & for running in the background
- fg for pulling jobs to the foreground
- I/O Redirection (>,<, and |)
- Script Arguments ($1, $2, etc)
BASHing Through The Directories
- cd, cd ~, cd $HOME, all go to home directory
- cd .., goes to parent directory
- cd name, goes to directory name if it is in the present working directory
- cd /name1/name2/name3, drills down from root until it gets to name3
- cd ~/name, same as cd $HOME/name
- cd ~artimus, goes to home directory of user artimus
- cd ., changes to present working directory (does nothing)