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!)
- Make sure you are in your home directory
cd- Go to your it244 directory
cd it244- Go to your ex directory
cd ex- Create an ex11 directory
mkdir ex11- Go to your ex11 directory
cd ex11Start Up a Script Session
Execute the script command, using the --flush option
script --flushCombining Options
- Perform a long listing of the files/directories for this course
ls -l /home/ckelly/course_files/it244_files- Use ls to see the directory contents in reverse order by date
ls -ltr /home/ckelly/course_files/it244_filesHere you are combining the options indicating you want a long listing (l), ordered by date and time (t), in reverse order (r).
- Use ls to see the access permissions on the it244_files directory
ls -ld /home/ckelly/course_files/it244_filesHere you are combining the options indicating you want a long listing (l) of the directory itself (d), not its contents.The Human Readable Option
- Use df to see the disk space available on pe15
dfNotice two things.
First, the available space field is very hard to read.
Second, you are seeing disk partitions on more than one machine.
blade61 and blade66 are two different machines.
The single, logical, filesystem we see is composed of multiple physical disks and partitions.
- Now use df with the -h option
df -hThe free disk space is now much easier to read.The --help Option
- Invoke the --help option for cat
cat --help- Look at the help for ls
ls --helpNotice that some help is very long.
- Explore the --help option for cd
cd --helpcd does not respond to the --help option, or, for that matter, -h.Running Commands with Pathnames or Only the Name of the Command
- Run ls using only the name of the command
ls ~ckelly- Learn the location of the ls executable file
which ls- Run ls using an absolute pathname
/bin/ls ~ckellyThis has the same effect as typing the name of the command on the command line, which is also the name of the executable file for ls.The PATH System Variable
- Display the value of PATH
echo $PATHNotice that each directory name is an absolute pathname separated by a colon, : .
Notice also, that the current directory, . , does not appear in this list.Running a Program in the Current Directory
- Go to the ex11 directory
cd ~/it244/ex/ex11- Make sure you are in your ex11 directory
pwd- Run the shell script hello.sh which is in my course_files/it244_files directory
~ckelly/course_files/it244_files/hello.sh- Copy hello.sh to your current directory
cp ~ckelly/course_files/it244_files/hello.sh .
- Make sure the copy operation worked
ls- Try to run the program you just copied using just the name of the file
hello.shYou get an error message.
- Run the program by placing ./ in front of the file name
./hello.shNow the program run.Exit Status
- Run ls with no options or arguments
ls- Examine the exit status returned by the last command
echo $?Since ls ran without any problems, it returned an exit status of 0, indicating that all went well.
- Now run ls on a file that doesn't exist
ls foobar- Examine the exit status returned by the last command
echo $?Since ls failed, it returns a non-zero exit status.
- See what this exit status means
ls --help | tailReturning the value 2 means ls ran into a serious problem.
Exit Your Script Session
Use the exit command
exitYou should see a confirmation message confirming that the script is finished, resulting in a file called typescriptBash Script for this Exercise
- Go to your ex11 directory
cd ~/it244/ex/ex11- Create the script ex11.sh
nano ex11.sh- Write into this file the commands you used above
Include Unix commands from the section Combining Options to the section Exit Status.
- Save this file
Save and quit.
- Make this script executable
chmod 755 ex11.sh- Run the script
./ex11.shFix any errors you find.
If you have trouble, see me.