Log in to pe15
- Log in to a Windows machine
Enter your Unix username as the account name. Then enter your password.
- Run the ssh client
Use the values in the table below to connect to pe15.
ssh configuration parameter value protocol ssh ssh version 2 ssh port 22 host pe15.cs.umb.edu user name your Unix username Authentication method password
- Enter your password
A dialog box will appear on the screen into which you must type the password for your Unix account.
Directory for This Exercise
- Go to your ex directory
cd ~/it244/ex- Create an ex21 directory
mkdir ex21- Go to your ex21 directory
cd ex21Start Up a script Session
Execute the script command, using the --flush option
script --flushCommand Line Editing
- Enter a long command line
echo foo; echo bar; echo bletch- Recover this last command line but do not hit Enter
↑- Go to the beginning of the command line
Control A- Go to the end of the command line
Control E- Go back to just before the last echo command
Use the left arrow key (←) to do this.
- Remove the last echo command
Control K- Remove the command line completely
Control UCommand Completion
- Go back to your ex21 directory
cd ~/it244/ex/ex21- Enter the first two letters of the mkdir command then hit Tab
mk[Tab]The terminal should beep.
- Hit Tab a second time
[Tab]You should now see a list of all commands that begin with "mk".
- Type "di" after "mk" and hit Tab
The mkdir command is complete.
- Create the directory test
Add the argument "test" after mkdir.Pathname Completion
- Go to your it244 directory using pathname completion
cd ~/it2[Tab] [Enter]You should now be in your it244 directory.
- Show your current directory and it's contents
pwd ; ls- Enter the first few letters of a pathname, then hit Tab
cd ~/it244/e[Tab]The Readline library adds an "x"
- Hit Tab again
The Readline library adds "ex" to the pathname.
- Hit the Tab twice more
The Readline library lists the example directories.
- Add "21" and hit Return
This will take you back to your ex21 directory.
Variable Completion
- Create the variable foo
team='Red Sox'- Use variable completion to print the value of this variable
echo $t[Tab][Enter]- Create two new variables
blar=blimp ; bletch=baloney- Use variable name completion
echo $b[Tab]Readline completion adds an l.
- Use variable completion to see your choices
[Tab][Tab]Completion shows you the variables that match.Exit Your script Session
Use the exit command
exitYou should see a confirmation message confirming that the script session is finished, resulting in a file called typescript. I will look at the typescript file, along with the other files in your directory.Aliases
- Go to your home directory
cd- Make sure you are in your home directory
pwd- Edit .bash_profile using an editor
nano .bash_profile- Create the global variable ex in .bash_profile
export ex=it244/ex- Create an alias using your ex variable
alias ex='cd $ex'- Save these changes and quit
- Go to your ex21 directory
cd ~/it244/ex/ex21- Re-Start Your script Session Execute the script command, using both the --flush option AND the --append option
script --flush --append- Make this change take effect
source ~/.bash_profile- Use this alias
ex- Display your current directory
pwd- Exit Your script Session
Use the exit command
exitYou should see a confirmation message confirming that the script session is finished, resulting in a file called typescript. I will look at the typescript file, along with the other files in your directory.- Go back to your home directory
cd- Open .bash_profile in an editor
nano .bash_profile- Create two new aliases
alias h='history 10' alias hg='history | grep '- Save these changes and quit
- Make sure you are inside your ex21 directory
cd ~/it244/ex/ex21- Re-Start Your script Session
Execute the script command, using both the --flush option AND the --append option
script --flush --append- Make this change take effect
source ~/.bash_profile- Run the first alias
hYou should see your last 10 command lines.
- Run the second alias
hg cdYou should see every time you have run cd in the last 500 command lines.Single and Double Quotes
- Create a variable
city=Boston- Display the value of this variable
echo $city- Define another variable using single quotes
capitol='$city is the capitol of Massachusetts'- Display the value of this variable
echo $capitolThe variable city is not evaluated because it was enclosed in single quotes when defined.
- Redefine city using double quotes
capitol="$city is the capitol of Massachusetts"- Display this redefined variable
echo $capitolThe double quotes permitted the shell to evaluate city when assigning a value to capitol.
- Make sure you are in your home directory
cd- Display the value of PWD
echo $PWDPWD has the address of your home directory.
- Go to my home directory
cd ~ckelly- Display the value of PWD
echo $PWDPWD is now set to the address of my home directory.
- Create an alias using this variable in double quotes
alias new_pwd="echo $PWD"- Use this alias in your current location
new_pwdIt displays the address of my home directory.
- Return to your home directory
cd- Make sure you are in your home directory
pwd- Use the alias in this new location
new_pwdThe alias again returns the address of my home directory.
Since you created the alias in my home directory, and used double quotes, the value of PWD at the time of definition was used in creating the alias.
But you want alias to use the value of PWD at the time the alias is used.
- Redefine the alias using single quotes
alias new_pwd='echo $PWD'- Use the newly redefined alias
new_pwdIt displays the address of your home directory.
- Go to my home directory
cd ~ckelly- Use the redefined alias again
new_pwdIt displays the address of my home directory.
Since you defined the alias using single quotes, PWD was not evaluated when it was defined, but instead, when it is used.Exit Your script Session
Use the exit command
exitYou should see a confirmation message confirming that the script session is finished, resulting in a file called typescript. I will look at the typescript file, along with the other files in your directory.Functions
- Go to your home directory
cd- Open .bash_profile using nano
nano .bash_profile- Define a function
cheer () { echo Go $1'!' }- Define another function
print_args () { echo "arg1: $1" echo "arg2: $2" echo "arg3: $3" }- Save and quit
- Make sure you are inside your ex21 directory
cd ~/it244/ex/ex21- Re-Start Your script Session
Execute the script command, using both the --flush option AND the --append option
script --flush --append- Make these functions available in your login shell
source ~/.bash_profile- Use the first function
cheer 'Red Sox'- Use the second function
print_args foo bar bletchExit Your script Session
Use the exit command
exitYou should see a confirmation message confirming that the script session is finished, resulting in a file called typescript. I will look at the typescript file, along with the other files in your directory.Checking Your Work
- Tell the instructor you have finished making changes to .bash_profile
There is no Bash script for this Class Exercise.