Log in to pe15
- 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
(When you are ready for me to check this exercise, please scroll back up to where you entered these commands!)
- Go to your ex directory
cd ~/it244/ex- Create an ex16 directory
mkdir ex16- Go to your ex16 directory
cd ex16Start Up a script Session
Execute the script command, using the --flush option
script --flushMore Practice with Background Jobs
- Copy bother.sh from my course_files/it244_files directory
cp ~ckelly/course_files/it244_files/bother.sh .- Make sure the copy operation worked
ls- Run bother.sh in the background redirecting its output
./bother.sh > /dev/null &- Run jobs
jobs- Run ps
ps- Bring the job to the foreground
fgNotice that you do not have a prompt.
That is because bother.sh is running in the foreground.
You can't see that becasue it's output is redirected to /dev/null.
Right now you can't run a command, because you do not have a prompt.
But you can suspend the current foreground job using Control Z .
- Suspend the job
Control ZNow you get your prompt back.
- Run jobs
jobsNotice that the bother.sh process still exists.
But it is in a state of suspended animation.
So it is nothing doing anything at the moment.
- Send the job back to the background
bg- Run jobs
jobsNotice that .bother.sh is running again.
- Run ps
ps- Kill the job using the process ID of bother.sh
kill PROCESS_IDPROCESS_ID is the PID number of the bother.sh process.
- Run jobs
jobsThe job has been terminatedBuilt-in Commands
- Find the file that will be run when you use ls
which lsYou get an absolute pathname, so ls is not a built-in.
- Find the file that will be run when you use cat
which catcat is also not a built-in.
- Find the file that will be run when you use bg
which bgwhich returns nothing because bg is a built-in command.
This means the code for this command is contained within the shell itself.
- Find the file that will be run when you use fg
which fgfg is also a built-in command.bash Startup Files
- Go to your home directory
cd- Make sure you are in your home directory
pwd- Look for any bash startup files
ls .bash*Unless you have created .bashrc or .bash_profile, you should see only .bash_history.
- Open up a second login session, while leaving your first login session going.
- You will use this second login session for file editing.
- This is so that your use of nano does not interfere with the script session in your first session.
- Make sure that you keep track of what is to be done in which login window!
- In your SECOND login window: Create a .bash_profile startup file
nano .bash_profile- In your SECOND login window: Enter the following line:
ex=~/it244/exThere must not be any spaces on either side of the = .
You have just created the variable ex with the value of ~/it244/ex.
- In your SECOND login window: Save your changes and quit nano
- Back in your FIRST login window: Try to use this new variable
echo $execho prints a blank line, because .bash_profile ran when you first logged in.
When .bash_profile ran, ex was not defined in .bash_profile.
It has not been run again since you made the changes.
- Run .bash_profile in your current shell
source .bash_profile- Now try to use the new variable
echo $ex- Use this new variable to go to your ex directory inside your it244 directory
cd $ex- Verify your current location
pwdCreate an Interactive Non-login Shell
- In your FIRST login window: Go back to your home directory
cd- Also in your SECOND login window: Go back to your home directory
cd- In your SECOND login window: Create a .bashrc file
nano .bashrcNotice that this is a different file than .bash_profile.
- In your SECOND login window: Enter the following line in the file
PS1='--> 'Again, there must be no spaces on either side of the = .
- In your SECOND login window: Save your changes and quit nano
(You can now close out your second login shell, but NOT the first!)- Back in your FIRST login window: Create a subshell
bashNotice that your prompt has changed.
That is because you changed the prompt variable PS1 in your .bashrc file.
When you created this interactive non-login shell, .bashrc was run.
.bashrc changed the value of PS1, giving you a new prompt.
- Look at your running processes
psThe first bash process is your login shell.
The second is your current shell.
- Leave the subshell
exitNotice that your prompt now has returned to normal.
- Run ps again
psYou have only one bash process running.
This means you are back in your login shell.
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, and you will probably also noticed that you are back in the original directory, from where you first ran the script command.