Assignment E
General instructions for all assignments
Provide an answer for each item in each session.
Number each answer with the same number as the corresponding item in the session assignment.
When the answer to the item is a Unix command, show the command and the system's response.
When the system prints more than 5 lines, abbreviate the response to 5 lines
(unless more lines are specifically requested), showing the most important parts.
Use vi to create a file for each session, for example,
create a file named sessionE1
Session E1
- Log into the system.
- Use the appropriate command to determine your login shell.
- Find your entry in the /etc/passwd file to verify the result of step 2.
Put your entry here, in your answer.
- Create a Korn subshell.
- Use the same command you used above to show that your login shell is still shown.
- Use a different command to determine your current shell.
It should show that your current shell is the Korn shell.
- Create a Bourne Again subshell.
- Use the command to show the current shell.
It should show that your current shell is the Bourne Again shell.
- Exit from your current subshell.
- Use a command to determine your current shell.
It should show that your current shell is the Korn shell.
- Exit from your current subshell.
- Use the command to show the current shell.
It should show that your current shell is your login shell.
- Log out of the system before starting the next session.
Session E2
- Log into the system.
- Use the who command and redirect the result to a file called file1
- Use the more command to see the contents of file1.
Put 5 lines from file1 in your answer, including the line containing your login ID.
- Create a Korn subshell.
- In one command line, use the date and who commands in sequence so that the output of date
will display on the screen and the output of who will be redirected to a file called
file2. Show the date results and the first two lines from file2
- Make a duplicate of file2 and call it file2.bak
- Set vi to be your command-line editor.
- Use the command-line editor to recall the previously issued date and who commands.
Edit the line so that the output of both commands (date and who) are
redirected to a file called file3.
Use the more command to display the result.
Show the date result and the first two who output lines from file3.
- Use the command-line editor to recall the original date and who command line
which redirects the output of who command to file2
Edit the line so that the word "date" is misspelled as "bate".
Execute the edited command.
- Compare the contents of file2 and file2.bak What do you see?
- Using command-line editing, recall the line created with the bate error.
Edit it so that the errors also go to file2error
Show the contents of file2error
- Exit from the Korn shell and log out of the system
before starting the next session.
Session E3
- Log into the system.
- Create a long listing of your home directory and redirect it to file1
Show the first 5 lines of file1
- Edit the previous command so that the output goes to both the screen and file1
You will need to use a pipe and tee to accomplish this.
Show the first two lines from the screen and the first two lines from file1
- Edit the previous command so that the output goes to both file2 and file3
Show the first two lines from file2 and the first two lines from file3
- Set the noclobber option.
- Repeat the previous command line from step 4 so that the output goes to both file2 and file3
Do you get any error message? If so, what is it?
- Edit the previous command line to force clobbering of the files.
- Unset the noclobber.
- Repeat the command that caused the error message. Does it work now?
- You may log out, or continue with the following session.
Session E4
- Log into the system or change to your home directory.
- Without using an editor create a one-line file called file1
by using the echo command (use output redirection).
This is one of the ways in which we can create a short file quickly.
- Check the contents of file1 using the cat command.
- Now, without using an editor, create a two-line file called file2 by using the echo command.
Use double quotes for the argument of the echo command. Put the opening quote at
the beginning of the first line and the closing quotes at the end of the second line.
Explain what you just did and why it works.
- Check the contents of file2 using the cat command.
- In a variable called statement store the following data,
including the quotation marks:
"UNIX is basically a simple operating system"
- Now use the following command:
echo "Dennis Ritchie said $statement but you have to be a genius to understand the simplicity."
What is printed and why?
- Now use the following command:
echo 'Dennis Ritchie said $statement but you have to be a genius to understand the simplicity.'
What is printed and why?
- Now use the following command:
echo "Dennis Ritchie said \$statement but you have to be a genius to understand the simplicity."
What is printed and why?
- Use an echo command, that uses the variable statement
and prints the following, including all four of the double quote characters:
"Dennis Ritchie said "UNIX is basically a simple operating system" but you have to be a genius
to understand the simplicity."
- You may log out, or continue with the following session.
Session E5
- Log into the system or change to your home directory.
- Store the word PARENT in a variable called firstVar
- Print the value of the variable firstVar (using echo command).
- Create a bash subshell.
- Store the word SUBSHELL in a variable called secondVar
- Print the value of the variable firstVar (using echo command).
- Print the value of the variable secondVar (using echo command).
- Explain these two results.
- Use the exit command to return from the subshell shell back into your login shell.
- Print the value of the variable firstVar (using echo command).
- Print the value of the variable secondVar (using echo command).
- Explain these two results.
- You may log out, or continue with the following session.
Session E6
- Do NOT change anything in this session; just look at the files.
- Log into the system or change to your home directory.
- Display the contents of the system startup file (the file name is different in different shells).
- Display the permissions for this file. Do you have permissions to change it?
- Display the contents of your personal startup file (the file name is different in different shells).
- Display the permissions for this file. Do you have permissions to change it?
- Display the contents of system-wide shut-down files (if there is one - if none, say none).
- If there is one, do you have permissions to change it?
- Display the contents of your personal shut-down files (if there is one - if none, say none).
- If there is one, do you have permissions to change it?
- Log out of the system.
Submission session
Create a heading similar to the heading for assignment A.
Tommy Atkins replace with your name
CIS 18A
Winter 2011 replace with the current quarter
Assignment E replace with the current assignment letter
- Use the following command to create a file with your work from the assignment:
cat headingE sessionE1 sessionE2 sessionE3 sessionE4 sessionE5 sessionE6 > assignmentE.txt
-
Use e-mail or WinSCP to obtain a copy of assignmentA.txt.
Print it using notepad, or otherwise use the Courier New or other mono-space font.
- Turn in your printout to the instructor on time.