HCC2D A10 Aixbasics Studenthints
HCC2D A10 Aixbasics Studenthints
HCC2D A10 Aixbasics Studenthints
cover
Front cover
AIX 6 Basics
(Course Code AU13)
Student Exercises
with Hints
ERC 10.0
Trademarks
The reader should recognize that the following terms, which appear in the content of this
training document, are official trademarks of IBM or other companies:
IBM is a registered trademark of International Business Machines Corporation.
The following are trademarks of International Business Machines Corporation in the United
States, or other countries, or both:
AIX
MVS
System p
AIX 5L
OS/2
System p5
V3.1.0.1
Student Exercises with Hints
TOC
Contents
Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
Exercises Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Exercise 1. Using the System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
Exercise 2. AIX 6.1 Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
Exercise 3. Files and Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1
Exercise 4. Using Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1
Exercise 5. File Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1
Exercise 6. vi Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1
Exercise 7. Shell Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1
Exercise 8. Using Shell Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1
Exercise 9. Controlling Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-1
Exercise 10. Customizing the User Environment . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1
Exercise 11. AIX Utilities (1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-1
Exercise 12. AIX Utilities (2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-1
Exercise 13. AIX Utilities (3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-1
Exercise 14. AIX Utilities (4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-1
Exercise 15. Additional Shell Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-1
Exercise 16. Using AIXwindows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-1
Exercise 17. Using the Common Desktop Environment (CDE) . . . . . . . . . . . . . . . 17-1
Appendix A. Customizing AIXwindows (1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1
Appendix B. Customizing AIXwindows (2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-1
Appendix C. Customizing CDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-1
Contents
iii
iv
AIX 6 Basics
V3.1
Student Exercises with Hints
TMK
Trademarks
The reader should recognize that the following terms, which appear in the content of this
training document, are official trademarks of IBM or other companies:
IBM is a registered trademark of International Business Machines Corporation.
The following are trademarks of International Business Machines Corporation in the United
States, or other countries, or both:
AIX
MVS
System p
AIX 5L
OS/2
System p5
Trademarks
vi
AIX 6 Basics
V3.1
Student Exercises with Hints
pref
Exercises Description
None of the exercises, EXCEPT Exercises 4 and 5 are dependent on
the preceding exercise being successfully completed. It is assumed,
however, that you understand the commands and concepts from each
exercise as these commands and concepts are carried over to the
follow-on exercises.
Each exercise in this course is divided into sections as described
below. Select the section that best fits your method of performing
exercises. You may select to use a combination of these sections as
appropriate.
Exercise Instructions - This section contains what it is you are to
accomplish. There are no definitive details on how to perform the
tasks. You are given the opportunity to work through the exercise
given what you learned in the unit presentation, utilizing the unit
Student Notebook, your past experience, and maybe a little intuition.
Exercise Instructions with Hints - This section is an exact duplicate
of the Exercise Instructions section except that in addition, specific
details and hints are provided to help step you through the exercise.
Using the Exercise Instructions section along with the Exercise
Instructions with Hints section can make for a rewarding
combination providing you with no hints when you do not want them
and hints when you need them. When there is more than one way to
do a command, we show you both ways with an -OR- between
possible solutions.
Optional Exercises - This section provides additional practice on a
particular topic. Specific details and hints are provided to help step you
through the Optional Exercises, if needed. Not all exercises include
Optional Exercises.
Solutions - This section provides at least one solution to questions
strategically placed in some exercises. Where applicable the solutions
have been provided at the end of the Exercise Instructions with
Hints section. Note: These are NOT the solutions to the exercises as
those are provided in the Exercise Instructions with Hints.
Exercises Description
vii
Text highlighting
The following text highlighting conventions are used throughout this book:
viii
Bold
Italics
Monospace
Monospace bold
<text>
The text between the < and > symbols identifies information the
user must supply. The text may be normal highlighting, bold or
monospace, or monospace bold depending on the context.
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
Introduction
When executing commands on the command line, use the Enter key
on the graphics keyboard not the Ctrl/Act key. If using an ASCII
keyboard use the Return key not the Send key. Use of the Ctrl/Act or
Send keys can cause unpredictable results. When correcting a
typographical error on the command line, use the Backspace key not
the arrow keys.
1-1
Basic Commands
__ 3. Display the system's date.
$ date
__ 4. Display the whole calendar for the year 2007.
$ cal 2007
__ 5. Display the month of September for the year 1752. Notice anything peculiar about
September? __________
$ cal 9 1752
__ 6. Display the month of January for the years 1999 and 99. Are 1999 and 99 the
same? __________
1-2
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
$ cal 1 1999
$ cal 1 99
__ 7. There are two commands that will display information about all users currently on
the local system. Display who is currently logged in on your system. Check to see
when they logged in.
$ who
-OR
$ finger
__ 8. Display just your login name.
$ who am i
__ 9. Use banner to display Out to Lunch.
$ banner Out to Lunch
__ 10. Use the echo command to write the character string Out to Lunch to your display.
$ echo Out to Lunch
__ 11. Use the clear command to clear your screen.
$ clear
1-3
__ 14. Access your mail and delete the message you saved in your personal mailbox. Exit
the mail program. If there is more than one person logged in on your system,
practice sending mail to each other.
$ mail -f
? d
? q
Keyboard Tips
To get some practice temporarily stopping, starting, and terminating the scrolling of
command output, use the banner command to banner the letters of the alphabet in order to
generate multiple lines of output.
__ 17. Using banner, display the alphabet separating each character with a space. As
output is scrolling to your display, temporarily stop the output. Resume the scrolling.
$ banner a b c d e f g h i j k l m n o p q r s t u v w x y z
<Ctrl-s> (temporarily stops scrolling)
<Ctrl-q> (resumes scrolling)
<Ctrl-c> (terminates the current command)
__ 18. Repeat the banner command used in the previous step, typing only the first five
letters of the alphabet, but DO NOT press Enter. Erase your input using <Ctrl-u>.
Now have the banner command display the phrase End of Exercise. This time if
you make a typing mistake while keying this command, use the Backspace key to
correct the command line.
1-4
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
$ banner a b c d e
$ <Ctrl-u>
$ banner End of Exercise
__ 19. Log off the system.
$ <Ctrl-d>
END OF EXERCISE
1-5
Exercise Solutions
__ 5. Display the month of September for the year 1752. Notice anything peculiar about
September? __________
Answer: This was an adjustment made by Pope Gregory to bring the
calendar back in sync with the Earth's rotation, causing much upheaval
among the population which felt that he had taken away eleven days of their
lives!
__ 6. Display the month of January for the years 1999 and 99. Are 1999 and 99 the
same? __________
Answer: No, they are not the same. The year is taken literally. You must be
specific as to the century as well.
1-6
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
Introduction
In this exercise, you will first use the man command from the command
line. This part of the exercise can be performed in either graphics
mode or ASCII mode.
In the second part of the exercise, you will use a Web browser to
access AIX 6.1 online documentation.
2-1
man Pages
__ 1. Log in to the system with the user name and password provided by your instructor.
__ 2. Bring up the man pages for the man command. Read the text that follows to obtain a
better understanding of the functionality of the man command.
Remember to use the space bar to go forward one screen and the return key to
go forward one line. Press the b key to go back one screen. When you have read
enough, exit man using the q key or <Ctrl-c>.
$ man man
<Ctrl-c> or q
__ 3. Using the man command, search on the keyword calendar. From the list produced,
find the command that displays a calendar.
$ man -k calendar
__ 4. Having found the cal command from the previous step, use man without any options
to obtain the correct syntax of the command.
$ man cal
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
buttons located in the upper right corner of the frame to navigate around your
pages.
__ 9. Now, suppose you do not know what document to look in for the information you
require. Use the search function in the Information Center to find information on the
wc command.
In the search box, enter the string wc command and press Enter or click Go.
In the right frame, you will see the results of your search. The words you
searched on will be highlighted in each document. Select one of the top
documents and scroll through it. Use the left arrow in the upper right corner to
go back to the search results and select another document.
__ 10. Use the Search Scope function to narrow your search. Change the search scope
for the previous search to only include the Commands Reference.
Click Search Scope: located next to the Search box.
A pop-up box will appear allowing you to define a custom search scope.
Select the radio button entitled Search only the following topics
and click the New button.
In the box entitled List Box, type an appropriate name for your new scope,
such as man pages. In the main window, click the + next to AIX
Information, and select the box next to Commands. A checkmark will
appear in the box. Click Ok to save your scope.
You should now have your new search scope highlighted. Click Ok to select it.
You will see that the text next to Search Scope: now says man pages.
Click Go next to the search box to rerun your search.
You will now see your results in the left frame. Select a few of the results and
browse the pages.
__ 11. Use any extra time you have to explore other documents available in the AIX
Information Center.
__ 12. Exit your Web browser.
Click File
Click Exit.
END OF EXERCISE
2-3
2-4
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
Introduction
In this exercise, you will be using AIX commands to work with
directories and files.
3-1
$ ls -a
$ ls -R
__ 6. Return to your home directory (/home/teamxx) and list its contents including hidden
files.
$ cd
$ ls -a
__ 7. Create a directory in your home directory called mydir. Then, issue commands to
view a long listing of both your /home/teamxx/mydir and /home/teamxx
directories. What are the sizes of each directory?________________________
$ mkdir mydir
$ ls -ld /home/teamxx/mydir
3-2
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
$ ls -ld /home/teamxx
__ 8. Change to the /home/teamxx/mydir directory. Use the touch command to create
two zero-length files called myfile1 and myfile2 in your mydir directory.
$ cd mydir
$ touch myfile1
$ touch myfile2
__ 9. Issue the command to view a long listing of the contents of your mydir directory.
What are the sizes of myfile1 and myfile2?__________________ View the long
listing again, this time also displaying the i-node numbers of the files. What are the
i-node numbers for the files? _____________________
$ ls -l
$ ls -li
__ 10. Change back to your home directory and issue the ls -R command to view your
directory tree.
$ cd
$ ls -R
__ 11. Use the istat command to view i-node information on your mydir directory.
Why may the Last Accessed date be more current than the other two dates?
$ istat mydir
__ 12. Use the rmdir command to remove the mydir directory. Does it work?
____________________ You will note that the rmdir command cannot remove a
non-empty directory. To do that, you will need to issue a command that we will learn
in the next unit, rm -r.
$ rmdir mydir
$ rm -r mydir
END OF EXERCISE
3-3
Exercise Solutions
__ 5. Issue the ls command with the -a and the -R options. What is the effect of each
option?_______________ (Note: The ls -R will provide extensive output. Once you
have seen enough, enter the key sequence <Ctrl-c> to end the command.)
The -a command option displays all hidden files (files that begin with a .).
The -R command option displays files recursively in a directory structure.
__ 7. Create a directory in your home directory called mydir. Then, issue commands to
view a long listing of both your /home/teamxx/mydir and /home/teamxx
directories. What are the sizes of each directory?________________________
The file size is the number just before the last modified date on the report
line. It is probably 512.
__ 9. Issue the command to view a long listing of the contents of your mydir directory.
What are the sizes of myfile1 and myfile2?__________________ View the long
listing again, this time also displaying the i-node numbers of the files. What are the
i-node numbers for the files? _____________________
The files sizes should be 0.
The i-nodes number is the first field on each ls -li report line. The numbers
will likely vary from system to system.
__ 11. Use the istat command to view i-node information on your mydir directory.
Why may the Last Accessed date be more current than the other two dates?
The Last Accessed date will be updated any time the directory is viewed.
The other dates are updated when the directory or its i-node structure is
changed.
__ 12. Use the rmdir command to remove the mydir directory. Does it work?
____________________ You will note that the rmdir command cannot remove a
non-empty directory. To do that, you will need to issue a command that we will learn
in the next unit, rm -r.
The rmdir fails with an error message: Directory mydir is not empty.
3-4
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
Introduction
In this exercise you will be using AIX commands to manipulate
ordinary files and directories using the commands discussed in
lecture.
4-1
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
__ 7. List the files in your current directory. You should see the two you just copied.
$ ls
4-3
$ cat goodstuff/np
__ 18. This is a good point to check everything out. Starting from your home directory and
working downwards, display a hierarchical tree of your files and subdirectories.
$ cd
$ ls -R
Remove a Directory
__ 19. Ensure you are in your home directory. Remove the goodstuff directory. Could you
do it? Why or why not?
$ pwd
$ rmdir goodstuff
__ 20. Change to the goodstuff directory. Do a listing on the contents of the goodstuff
directory including any hidden files. Remove the files. Do another listing on the
goodstuff directory including the hidden files. Notice the . and .. files are still there.
The directory is considered empty if these are the only two entries left in it.
Remove the directory.
$ cd goodstuff
$ ls -a
$ rm np
$ ls -a
$ cd ..
$ rmdir goodstuff
END OF EXERCISE
4-4
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
Optional Exercises
__ 21. Using the mkdir command only once, create a directory under the myscripts
directory named sports that has three directories in it named tennis, basketball,
and baseball. Check to be sure the directories were created properly.
$ cd /home/teamxx/myscripts
$ mkdir -p sports/tennis sports/basketball sports/baseball
$ ls sports
__ 22. Copy the file /etc/motd into the tennis directory and create two files in the
basketball directory. Leave the baseball directory empty. Check to be sure the files
were created.
$ cp /etc/motd sports/tennis
$ touch sports/basketball/myteam
$ touch sports/basketball/myplayer
$ ls sports/tennis sports/basketball
__ 23. Use the rm command to remove the sports directory and everything in it.
$ rm -r sports
4-5
Solutions
Following are the solutions for those instructions that included questions:
__ 20. Ensure you are in your home directory. Remove the goodstuff directory. Could you
do it?
Why not?
Answer: You should not be able to remove the goodstuff directory because it
has files in it.
4-6
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
Introduction
In this exercise, you will be using AIX commands to manipulate AIX file
and directory permissions. Understanding the implications of file
permissions and ownership and using the commands to change file
permissions is necessary to doing additional exercises in this course.
Tips
Make sure you are aware of what directory you are in while performing
the various steps. If you lose track of where you are in the exercise,
some instructions will appear not to work. Use pwd frequently to check
your current directory.
5-1
5-2
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
$ ls -l /home/teamxx/home_mycal
-OR $ ls -l ../home_mycal
__ 5. Change the directory to your home directory. Execute home_mycal.
What does the output look like?
_______________________________________________________________
Now, change permissions on the home_mycal file so that you, the owner of the file,
have read only permission. Try running the mycal command.
Can you do it? _________________
Why or why not? _________________
$ cd
$ home_mycal
$ chmod 455 home_mycal
$ ls -l home_mycal
$ myscripts/mycal
__ 6. Remove home_mycal. Did that remove myscripts/mycal? _________________
Why or why not?
________________________________________________________________
$ rm home_mycal
$ ls -l myscripts/mycal
5-3
What happened?
_______________________________________________________________
_______________________________________________________________
$ mycat ../.profile
-OR $ mycat /home/teamxx/.profile
__ 10. Make your home directory the current directory. Check to see if you are in your
home directory.
$ cd
$ pwd
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
$ myscripts/mycal
__ 15. Try to remove mycal. Did it work?
Why or why not?
________________________________________________________________
________________________________________________________________
$ rm myscripts/mycal
__ 16. Return the permissions of myscripts back to its original form of rwxr-xr-x and then
remove mycal.
$ chmod 755 myscripts
$ rm myscripts/mycal
__ 17. As time permits, experiment with other permission combinations. When you are
through, make sure to change the permissions back to rwx for the owner.
END OF EXERCISE
5-5
Solutions
Following are the solutions for those instructions that include questions:
__ 1. Log in to the system. Change to the myscripts directory. Display a long listing of the
files in the myscripts directory. Notice the owner and permissions for the files that
you copied in the previous exercise.
Record the permissions for mycat. __________
Record the permissions for mycal. __________
Answer:
-r-xr-xr-x mycat
-r-xr-xr-x mycal
__ 3. Change the modification time of mycal and mycat in the myscripts directory.
Check to see that the time actually changed. What is another use for the touch
command?
Answer: touch can also be used to create empty (zero length) files.
__ 4. Make it so you can reference the mycal file in the myscripts directory by the name
of home_mycal in your home directory. Compare the detailed file information for
both files. Is there any difference? What is the link count?
Answer: Only the name is different. The link count is 2 because there are two
names in the directory pointing to the same file.
__ 5. Change the directory to your home directory. Execute home_mycal. What does the
output look like? __________
Now, change permissions on the home_mycal file so that you, the owner of the file,
have read only permission. Try running the mycal command. Can you do it?
__________
Why or why not? __________
Answer: The output looks like the output from the mycal command. After
changing permissions on home_mycal to read only you will not be able to
execute mycal because the two files are linked and any changes made to
one will be reflected in the other one as well.
__ 6. Remove myscripts/home_mycal. Did that remove myscripts/mycal?
__________
Why or why not? __________
Answer: Removing home_mycal simply removes the directory entry in
myscripts that refers to home_mycal and changes the link count from 2 to
1. It does not remove the file itself. Thus, at this point the file is only known by
one name, mycal.
__ 9. Use the mycat command to display the contents of the .profile file. Did it work?
What happened?
5-6
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
5-7
5-8
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
Exercise 6. vi Editor
(with Hints)
Introduction
The vi editor is based on software developed by the University of
California at Berkeley, California, Computer Science Division. The vi
editor, pronounced vee-eye (short for visual), features commands to
create, change, append, or delete files. The following exercises will
familiarize you with some of the major features and functions of vi.
For your assistance, there is a vi Command Summary in the
Appendix of the Student Notebook.
Exercise 6. vi Editor
6-1
6-2
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
__ 4. Return to command mode. Write and quit the file. Notice that as soon as you press
the : (colon), it appears below the last line of your input area. Once the buffer is
empty and the file is closed, you will see a message giving the number of lines and
characters in the file.
ESC (puts you in command mode)
:wq (<shift-ZZ> or :x is another way to write and quit)
Exercise 6. vi Editor
6-3
1<shift-G> or :1 Enter
4<shift-G> or :4 Enter
$
0 (this is a zero)
__ 8. Move your cursor to the top of the file. Search for the word entry. Your cursor
should be on the e. Switch to input mode and add the word text. Do not forget the
space after the word.
1<shift-G> or :1
/entry
i
text
__ 9. Move the cursor to the space after the word mode on the same line. Insert a comma.
Remember, you are still in input mode.
ESC
Position the cursor to the space after mode
i, (comma)
__ 10. Enter command mode. Position the cursor anywhere on the line beginning with
some more lines. Insert a blank line to form two paragraphs.
ESC
Position cursor on line starting some more lines
o (lower case o opens the line after the cursor)
__ 11. Opening a blank line as in the previous step, automatically puts you in input mode;
therefore, return to command mode. Now save the changes you have made so far,
but DO NOT exit the editor.
ESC
:w
__ 12. While still in command mode, remove the alphabetic characters c, e, g but leave
the blank lines in their place; in other words, do not delete the entire line, just the
character. Then go back and remove the blank lines. This will give you practice
using two of the delete functions.
Position cursor on c; Press x
Position cursor on e; Press x
Position cursor on g; Press x
Position cursor on each of the blank lines; Press dd
6-4
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
Exercise 6. vi Editor
6-5
__ 18. Options can be set temporarily in an editing session using the set command. Go
back to the top of your file. Ensure you are in command mode and set the following
commands:
a. Set automatic word wrap 15 spaces before the right margin.
b. Display the INPUT MODE message when in input mode.
c. Turn line numbering on
1<shift-G>
ESC
:set wrapmargin=15 (no spaces around the =)
:set showmode
:set number
__ 19. Test each of the options set in the previous instruction.
Lines should be numbered.
Enter input mode using i or a. You should see an INPUT MODE message at
the bottom right of your display.
Key in a couple lines of miscellaneous text to test automatic word wrap.
Enter command mode by pressing ESC. The INPUT MODE message should
have disappeared from your display.
__ 20. Write the file and quit the editor.
:wq
6-6
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
through a buffer of commands that you previously executed. The commands are
actually stored in your .sh_history file in your home directory.
ESC
k (go up list of commands in buffer)
j (go down list of commands in buffer)
__ 24. Retrieve the ls command. Use the l key to move your cursor to the / in /usr. (Note:
the arrow keys tend to wipe your line out. You have to use the l key for right and h
for left.) Use the i key to insert text and change this command to be a long list.
Execute it.
k (to the ls /usr command)
l (to get to the /)
i (to get into input mode. You could have used a to append if the cursor was
on the space before the /)
-l
Enter
__ 25. Recall the cat command. This time list the contents of the /etc/passwd file.
ESC
k (to get to the previous cat command)
l (to move the cursor to the f in filesystems)
D (to erase rest of line, or dw to erase the word)
a (to append text)
passwd
Enter
__ 26. Recall the cat command. Go to the end of the line (remember $). Add to the end of
the command to pipe the output to wc to count just the lines.
ESC
k (to get to the last cat command)
$
a
| wc -l
Enter
END OF EXERCISE
Exercise 6. vi Editor
6-7
6-8
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
Introduction
Understanding the use and manipulation of the shell is considered a
foundation for understanding AIX user interfaces. You will use
commands to experiment with the shell features discussed in the
Shell Basics lecture.
7-1
Redirection
7-2
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
__ 8. Using the cat command and redirection, create a file called junk containing a few
lines of text. Use <Ctrl-d> at the beginning of a new line when you have finished
entering text and want to return the shell $ prompt. List the file contents to verify your
update.
$ cat > junk
Type in several lines of junk for your file
<Ctrl-d> on a new line to return to the shell prompt
$ cat junk
__ 9. Append more lines of text to the file you have created using the cat command and
redirection. List the file contents to verify your update.
$ cat >> junk (no spaces between the >>)
$ cat junk
__ 10. Mail the file junk to yourself. Wait a minute and open your mail, delete it, and quit
the program.
$ mail teamxx < junk
$ mail
?t
?d
?q
7-3
__ 14. This time use a pipe to count the number of files in your current directory. Was the
result what you expected this time? __________ Is it the same as in instruction 11?
________________________________________________________________
$ ls | wc -w
__ 15. Use the command you created in instruction 14, but this time insert a tee in the
middle trapping the result of the list in a file called junk2. Did you get the number
displayed on the screen? __________
Check the contents of junk2 to make sure that it contains what you expected.
$ ls | tee junk2 | wc -w
$ cat junk2
__ 16. List in reverse order the contents of your current directory. Send the results of the
reverse listing to a file named junk3, and to a program to count the number of words
in the reverse listing. Append the final count to junk3. Remember to use the append
version of redirection. In this particular case, you may get unexpected results if you
do not. It might not be a straight overwrite because the file is being used twice in the
same command. Experiment if you are curious.
$ ls -r | tee junk3 | wc -w >> junk3
$ cat junk3
__ 17. There is a special file in the /dev directory that represents your terminal. Display the
file name associated with your terminal. Output will be something like tty0, lft0, or
pts/x. Repeat the command from instruction 16 with two exceptions:
1) Rather than using junk3, tee the output to the special file that represents your
terminal (/dev/<your_terminal_name>).
2) Do not append the results of the wc command to junk3. Have the count
display to your terminal.
$ who am i
$ ls -r | tee /dev/lft0 | wc -w
7-4
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
test what you have learned so far by letting you create an incredibly long command
string.
You can choose to break the line anywhere you feel comfortable, but do not type
past the right edge of the screen. When completed, test your output by displaying
the contents of the files that were created. This should be one long command
connected by pipes and redirection.
1) Do a long listing of the files in your home directory including hidden files.
2) Capture the output to a file named reverse.listing and send the same output
to a program that will count only the number of words.
3) Capture the number of words and place the number in 4 files named file1
through file4.
4) Finally, send the output to a program to count the number of lines captured in
the previous instruction and redirect that number to a file named file5.
$ ls -al | tee reverse.listing | wc -w | tee file1 \<Enter>
> | tee file2 | tee file3 | tee file4 | wc -l > file5
(the > symbol at the start of the second line is the secondary prompt; you do
not type this)
END OF EXERCISE
7-5
Solutions
Following are the solutions for those instructions that include questions:
__ 2. Execute a simple ls to list the non-hidden files in your home directory. Now use the
ls command with a wildcard character to list these files. What is the difference in
output of these two commands?
Why? Answer: With ls * you got the contents of any subdirectories in your home
directory because the shell expanded the * before the ls command executed. The
shell expanded it to be the names of all the files (remember, directories are files) in
the directory. When you ask ls to list an ordinary file, it does, but when you ask it to
list a directory, it lists the contents of the directory, not the directory name itself. Use
the -d option of the ls command to have it list the directory itself instead of the
contents, if you want to see information on the directory only.
__ 6. List all files except those beginning with c through t. This will be a long list. You
might want to pipe the output to pg or more. Did you get any file names that you did
not expect? __________ If so, do you know why?
Answer: When you asked for all files except those beginning with c-t, you will only
execute lowercase entries. Uppercase entries like R and M will be displayed.
__ 13. Use the appropriate command to count the number of words in the temp file. Is this
the same count as in instruction 11? If not, why not?
Display the contents of temp. Remove the file.
Answer: The results of the wc -w command should be one greater than the original
count. The shell sets up the command line prior to executing the command; thus, the
temp file was created as an empty file prior to the execution of ls allowing temp to
be included in the count.
__ 14. This time use a pipe to count the number of files in your current directory. Was the
result what you expected this time? __________ Is it the same as in instruction 11?
__________
Answer: Yes. No temp file was created to capture the output for redirection.
__ 15. Use the command you created in instruction 14, but this time insert a tee in the
middle trapping the result of the list in a file called junk2. Did you get the number
displayed on the screen?
Check the contents of junk2 to make sure that it contains what you expected.
Answer: The number incremented by one because of the addition of the junk2 file.
Hint: There may be times when you may not get the results you thought. These are
independent processes communicating with each other. If the ls command finishes
processing before the shell has a chance to create the junk2 file, then junk2 would
not be included in the count.
7-6
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
__ 18. On the same command line, display the date, who is logged in, the name of your
current directory, and the names of the files in your current directory. Do these
commands have any relationship to each other? __________
Answer: Command grouping is just a shortcut for executing non-related commands
from the same command line. They have NO relationship to each other.
7-7
7-8
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
Introduction
This exercise contains three sections: variable substitution, command
substitution, and quoting. Knowledge of the first two sections, variable
and command substitution, is required to perform the third section,
quoting.
Caution: Throughout this exercise, the single quotes and the back
quotes look very similar. The single quotes look like this ', and the
back quotes like this . The back quote may look different on the
keyboard than it does as printed in this exercise.
8-1
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
You Rang? ls -l \
What Else?
<Ctrl-c>
You Rang? PS1="$ "
$ PS2="> "
__ 9. Check the value of the variable related to your home directory. Reset that variable to
change your home directory to /bin. Use the cd and pwd commands to test the
effects of this change.
$ echo $HOME (You could have checked the value using set)
$ HOME=/bin
$ cd ; pwd
__ 10. Log out and log back in. What is your home directory? __________ Why?
________________________________________________________________
Note: If you are working in an aixterm session, after keying exit, press the right
mouse button and select New Window to get back to an aixterm session.
$ exit
login: teamxx
teamxx's Password:
$ cd ; pwd
$ echo $HOME
Command Substitution
__ 11. Display your list of variables. Reissue the command but send the output to the wc
command to get the number of variables that are currently set.
$ set
$ set | wc -l
__ 12. Using command substitution, echo the following:
There are # variables currently set
where # is the number of variables.
$ echo There are set | wc -l variables set
OR
- $ echo There are $(set | wc -l) variables set
__ 13. Each user ID configured on the system is represented by one line in the
/etc/passwd file. Applying your knowledge of command substitution, echo a
message that displays:
Copyright IBM Corp. 1995, 2008
8-3
Quoting
__ 14. Using all three methods of quoting, banner the literal symbol *. Why do all three
work?
________________________________________________________________
$ banner '*'
$ banner "*"
$ banner \*
__ 15. Ensure you are in your home directory. Create a directory in your home directory
named quoting.
$ cd
$ pwd
$ mkdir quoting
__ 16. Change to the quoting directory. Create a zero-length file in the quoting directory
named filea. Create a variable named n set to the value of hello. Test what you
have done by displaying the contents of quoting and the value of n.
$ cd quoting
$ touch filea
$ n=hello
$ ls
$ echo $n
__ 17. From the quoting directory, execute the following five commands. Record the
output. Check the Solutions section for the expected output.
i.
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
END OF EXERCISE
8-5
Solutions
Following are the solutions for those instructions that include questions:
__ 7. Change the primary prompt string to "You Rang?". (Single quotes will also work)
Why is it necessary to use the quotes with "You Rang?" ?
Answer: Double quotes must be used because of the space between the words.
__ 8. Change your secondary prompt string to "What Else?". Test it with the ls command
using line continuation. End the command. Reset both prompt strings back to their
original values. Why are quotes needed around the > when resetting the PS2
variable? __________
Answer: By using quotes around the >, the symbol will not be interpreted as
redirection.
__ 10. Log out and log back in. What is your home directory? __________ Why?
Answer: Your home directory should be back to the default /home/teamxx.
Changing variables from the command line only sets the value for the length of the
login session. Once you log out, the variable is removed from your environment.
__ 14. Using all three methods of quoting, banner the literal symbol *. Why do all three
work?
Answer: All three work because the shell always negates wildcards no matter what
method of quoting is used.
__ 17. From the quoting directory, execute the following five commands. Record the
output. Check the Solutions section for the expected output.
Answers:
* $n ls $(ls)
Single quotes suppresses everything between them.
* hello filea filea
Double quotes do command and variable substitution only.
* $n ls $(ls)
Backslash negates the character following it. Note the use of a backslash in front
of each back quote.
filea hello filea filea
filea hello ls
8-6
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
Introduction
In this exercise you will use commands to experiment with process
control to get a better understanding of your process environment. You
will identify the processes associated with your terminal session, work
with variables in parent and child processes and terminate processes
you have started.
9-1
Structure
__ 1. Log in to the system and display your current process ID(PID).
$ echo $$
__ 2. Create a subshell by entering ksh. What is the process ID of the subshell?
Is it different from your login process?
$ ksh
$ echo $$
__ 3. Enter the command ls -lR / > outfile 2> errfile & and then execute the
command which displays all of your running processes. The ls command will
terminate when it finishes listing all the files in the directory tree.
$ ls -lR / > outfile 2> errfile &
$ ps -f
__ 4. Terminate your child shell. What happens if you type exit from your login shell?
$ exit
Process Environment
__ 5. Display all your variables that are in your current process environment.
$ set
__ 6. Create a variable x and set its value to 10. Check the value of the variable. Again,
display all your current variables.
$ x=10
$ echo $x
$ set
__ 7. Create a subshell with ksh. Check to see what value variable x holds in the subshell.
What is the value of x? __________ List the subshell current variables. Do you see
a listing for x? __________
9-2
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
$ ksh
$ echo $x
$ set
__ 8. Return to your parent process. Set the value of variable x so that its value will be
inherited by your child processes. Verify this by creating a subshell and checking on
the value of variable x.
$ exit
$ export x=10
$ ksh
$ echo $x
__ 9. Change the value of x to 200 in the subshell. Check that the value was changed.
$ x=200
$ echo $x
__ 10. Go back to the parent process. Check on the value of x in this environment. Was the
change in the subshell exported back to the parent?
$ exit
$ echo $x
__ 11. Create a shell script and name it sc1. It should read:
pwd; cd /; pwd
$ vi sc1
pwd
cd /
pwd
Press the ESC key followed by :wq to save the file.
__ 12. Make the file sc1 executable and run the program. What directory are you in now?
Why?
$ chmod 700 sc1
$ sc1
$ pwd
__ 13. Create another shell script and name it sc2. Have it read:
var1=hello; var2=$LOGNAME; export var1 var2
9-3
$ vi sc2
var1=hello
var2=$LOGNAME
export var1 var2
Press the ESC key followed by :wq to save the file.
__ 14. Make sc2 executable and run the program. When it is finished, examine the values
of the variables var1 and var2. What values do var1 and var2 have?
Why?
$ chmod 700 sc2
$ sc2
$ echo $var1 $var2
__ 15. Run the sc2 program again, this time by forcing it to run in the current shell. When it
is finished, check the values for var1 and var2. What values do var1 and var2 have
now?
Why?
$ . sc2
$ echo $var1 $var2
Job Control
__ 16. Create a shell script and name it sc3. It should read:
sleep 120
ls -lR / > outfile 2> errfile &
Make it executable. Start the script with the command:
$ ./sc3 > outfile 2> errfile
in the foreground.
$ vi sc3
(press i to insert text)
sleep 120
ls -lR / > outfile 2> errfile &
(press the ESC key followed by :wq to save the file)
chmod 700 sc3
$ ./sc3 > outfile 2> errfile
9-4
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
9-5
$ ps -ef
__ 24. When the process is complete, display the file that contains your output. (Hint: if you
did not specify an output file, nohup will send the output to nohup.out.)
$ pg /home/teamxx/outfile
__ 25. Rerun the sc3 script you just created placing it into the background but not using the
nohup command. Note its process id and job number. Apply the nohup to the
process ID of the background process sc3 and then log off.
Log back into the system and verify that the process is still running.
$ ./sc3 > sc3.out 2> sc3err &
$ jobs -l (note the PID of the job you just started in the background)
$ nohup -p <PID>
$ exit (you will get a message that says you have jobs running)
$ exit
Login: teamxx
teamxx's Password: teamxx
$ ps -ef
Terminating a Process
__ 26. Use the ls -lR / command we have been using to start a long running job in the
background. Note the process ID that is provided when you begin the background
process. __________
$ ls -lR / > outfile 2> errfile &
__ 27. If you did not record the process ID when you first started the command in the
background, how would you find it? __________
Once you know the process ID, kill the process. Check to be sure it was killed.
$ ps -f
$ kill <pid>
$ ps -f
__ 28. Repeat instruction 26 above. Kill the process using the job number rather than the
process ID. Check to be sure the job was killed.
$ ls -lR / > outfile 2> errfile &
$ jobs
$ kill %jobno
9-6
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
$ jobs
-OR $ ps -f
END OF EXERCISE
9-7
Solutions
Following are the solutions for those instructions that include questions:
__ 2. Create a subshell by entering ksh. What is the process ID of the subshell?
Is it different from your login process?
Answer: Your child process ID will always be different from the parent and is unique
on the system.
__ 4. Terminate your child shell. What happens if you type exit from your login shell?
Answer: You will log off the system.
__ 7. Create a subshell with ksh. Check to see what value variable x holds in the subshell.
What is the value of x? __________ List the subshell current variables. Do you see
a listing for x? __________
Answer: The value of x is null. In the output from the set command, x is not shown.
__ 10. Go back to the parent process. Check on the value of x in this environment. Was the
change in the subshell exported back to the parent?
Answer: No because the subshell runs in a different process than the parent.
__ 12. Make the file sc1 executable and run the program. What directory are you in now?
Why?
Answer: Your original directory because the cd command executed in a subshell.
When the child terminates, the parent resumes with its original environment.
__ 14. Make sc2 executable and run the program. When it is finished, examine the values
of the variables var1 and var2. What values do var1 and var2 have?
Why?
Answer: The values of both var1 and var2 are null. The sc2 script runs in a
subshell. When it completes, control is returned to the parent process. Variables set
in child processes are not available to parent processes.
__ 15. Run the sc2 program again, this time by forcing it to run in the current shell. When it
is finished, check the values for var1 and var2. What values do var1 and var2 have
now?
Why?
Answer: var1 is hello and var2 is your logname. By starting the sc2 script with the .
you are forcing it to run in the current process. Therefore, a new process is not
spawned and the variable is set and stays in the current process' environment.
__ 26. If you did not record the process ID when you first started the command in the
background, how would you find it? __________
Answer: Use ps -f.
9-8
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
9-9
V3.1
Student Exercises with Hints
EXempty
Introduction
Half way through the exercise, you will change your primary prompt
from a $ to the name of your current directory. This changed prompt
string will be reflected from that point on in the exercises. This will look
different from what you are use to seeing in previous exercises.
If you are working in an X Windows session, when instructed to log
out, execute one of the following commands: $ su - or $ login.
10-1
V3.1
Student Exercises with Hints
-OR-
EXempty
$ . .profile
__ 3. Once you have your customized .profile setup and functioning, open a subshell.
Answer the following questions:
i.
ii. Does the value of the alias dir still work? _____
iii. Can you invoke command line editing? _____
/home/teamxx=> ksh
__ 4. Exit from the subshell and return to your home directory. Most settings, with the
exception of system variables, only apply to the current environment and are not
passed to subshells (child processes). To pass alias or set customized settings
down to subshells, the ENV variable must be set in your .profile file along with the
existence of a customized .kshrc file.
Revise your .profile and create the appropriate .kshrc file to support the alias and
set customization you did in instruction 1.
In the .profile file, remove the 'alias dir' and 'set -o vi' customizations. Add the
ENV variable assignment. Export both PS1 and ENV.
Add the alias and set customizations (you just removed from .profile) to .kshrc.
<Ctrl-d>
/home/teamxx=> cd
/home/teamxx=> vi .profile
PS1='$PWD=> '
ENV=/home/teamxx/.kshrc
export PATH PS1 ENV
echo User $LOGNAME logged in at $(date)
(or whatever worked for you)
:wq
/home/teamxx=> vi .kshrc
set -o vi
alias dir='ls -l'
:wq
__ 5. Test your customization by re-executing your .profile file. Open a subshell and
answer the following questions:
i.
10-3
$ . .profile
/home/teamxx=> ksh
__ 6. Exit the subshell and return to your login shell. Display a listing of all currently set
alias names and locate the dir alias.
/home/teamxx=><Ctrl-d>
/home/teamxx=> cd
/home/teamxx=> alias
__ 7. Temporarily unalias dir without editing the .kshrc file. Then display the list of alias
settings again and ensure that it is no longer defined. Try executing dir.
/home/teamxx=> unalias dir
/home/teamxx=> alias
/home/teamxx=> dir
__ 8. The dir alias is still in your .kshrc file but is not set. The unalias command
removed it from the list of current alias names. Invoke .kshrc to automatically add
dir back in the alias list. Execute dir.
/home/teamxx=> . .kshrc
-OR Log out and log back in to reactivate .kshrc
/home/teamxx=> dir
END OF EXERCISE
V3.1
Student Exercises with Hints
EXempty
Solutions
Following are the solutions for those instructions that include questions:
__ 2. Test your customization by re-executing your .profile. You can choose to log out and
back in, or simply rerun it using the dot notation. Once you have done that, execute
and answer the following:
1) Did your message display? _______
2) Is your prompt the name of your home directory? _______
3) Change to the /etc directory. Did your prompt change? _____
4) Using dir do you get a long listing of your current directory? _____
5) Invoke dir using command line editing.
If you answered NO to any question, edit your .profile and fix it.
Answers:
1) A message similar to the following should be displayed:
User teamxx logged in at Thu Apr 19 14:34:26 CST 2001
2) Your primary prompt string should be similar to:
/home/teamxx=>
3) /home/teamxx=> cd /etc
4) /etc=> dir
You should see a long listing of the current directory.
5) ESC
k
/etc=> dir
__ 3. Once you have your customized .profile setup and functioning, open a subshell.
Answer the following questions:
i.
ii. Does the value of the alias dir still work? _____
iii. Can you invoke command line editing? _____
The answer to all three questions should have been NO and output that looks similar
to the following:
a) $ (Unless you thought ahead and exported PS1 as well in .profile)
b) $ dir
ksh: dir: not found.
c) $ ESC k (you should see a square bracket and letter k)
10-5
__ 5. Test your customization by re-executing your .profile file. Open a subshell and
answer the following questions:
i.
V3.1
Student Exercises with Hints
EXempty
Introduction
This exercise is designed to give you experience using the find
command.
Using the command line editing feature will be very helpful during this
exercise as some of the commands can get quite lengthy and will be
repeated in many instructions.
This exercise shows the $ prompt; however, unless you reset the PS1
variable from the prior exercise, you will see your current directory as
your prompt.
11-1
V3.1
Student Exercises with Hints
EXempty
i.
From your home directory issue the command to find only files starting with the
letter l. Record the names displayed.
$ cd
$ mkdir level1
$ touch level1/letter1
$ cd level1
$ mkdir level2
$ touch level2/letter2
$ cd
$ ls l*
$ find . -name 'l*' -type f
END OF EXERCISE
11-3
Solutions
Following are the solutions for those instructions that include questions:
__ 6. To demonstrate that find recursively searches all directories and subdirectories
from the search path down, do the following:
a. Ensure you are in your home directory.
b. Make a subdirectory called level1.
c. Create a zero-length file named letter1 in the subdirectory level1.
d. Change to the level1 subdirectory.
e. Make a subdirectory under level1 called level2.
f. Create a zero-length file named letter2 in the subdirectory level2.
g. Change to your home directory.
h. From your home directory issue the command to list all files starting with the letter l.
Record the names displayed.
i.
From your home directory issue the command to find only files starting with the
letter l. Record the names displayed.
Answer: The output is predictable. find goes to the end of the tree and will display
the path names of files meeting the selection criteria. In our example, we used a
relative path name as the starting directory for our find. As a result, find's output
is presented as relative pathnames as well.
V3.1
Student Exercises with Hints
EXempty
Introduction
This exercise is designed to give you experience using some AIX data
tools.
12-1
V3.1
Student Exercises with Hints
EXempty
__ 10. The tail command is also handy for stripping out header information from the
output of a command. First, list all processes currently running on your system.
Notice the headings. Next, display all processes running on your system excluding
the header information.
$ ps -ef | more
$ ps -ef | tail +2 | more
12-3
__ 20. Restore all files from your archive into the /tmp-directory.
$ cd /tmp
$ tar -xvf archive.tar
END OF EXERCISE
V3.1
Student Exercises with Hints
EXempty
Introduction
You will be manipulating ordinary files and directories using
commands discussed in lecture. Where there is more than one way to
invoke a command, you will see an -OR- between the possible
solutions in the Exercise Instructions with Hints section.
13-1
V3.1
Student Exercises with Hints
EXempty
END OF EXERCISE
13-3
V3.1
Student Exercises with Hints
EXempty
Introduction
You will be manipulating ordinary files and directories using
commands discussed in lecture. Where there is more than one way to
invoke a command, you will see an -OR- between the possible
solutions in the Exercise Instructions with Hints section.
14-1
V3.1
Student Exercises with Hints
EXempty
file, __________________. Do a long listing on the file and record the number of
bytes. _____________ Compare the number to the number in the previous
instruction.
$ compress -v mymagic
$ ls -l mymagic.Z
__ 7. Using zcat, expand and view the contents of mymagic.Z. You may want to page it
as it is a large file.
$ zcat mymagic.Z | pg
__ 8. Using uncompress, restore the compressed file back to its original file. Invoke a long
listing and record the number of bytes. ____________ The number should be the
same as the number in Step 5.
$ uncompress mymagic.Z
$ ls -l mymagic
14-3
END OF EXERCISE
V3.1
Student Exercises with Hints
EXempty
Introduction
You need not have any programming experience to perform this
exercise. Refer to the unit in the Student Notebook for help with the
syntax of constructs when creating the shell scripts in this exercise.
15-1
V3.1
Student Exercises with Hints
EXempty
$ vi checkfile
ls noname && cat noname || echo The file was not found
$ checkfile
__ 4. Modify the checkfile script so that error messages from the ls command do not
appear on the screen. Execute the script.
$ vi checkfile
ls noname 2> /dev/null && cat noname || echo The file was not
found
$ checkfile
__ 5. Modify the checkfile script to accept a single parameter from the command line as
input to the ls and cat commands. Execute the script twice, once using the file
named parameters and again using the file named noname.
$ vi checkfile
ls $1 2> /dev/null && cat $1 || echo The file was not found
$ checkfile parameters
$ checkfile noname
15-3
if [[ $? -eq 0 ]]
then cat $x
else echo $x was not found
fi
done
$ checkfile filename filename filename
END OF EXERCISE
V3.1
Student Exercises with Hints
EXempty
Solutions
Following are the solutions for those instructions that include questions:
__ 3. Modify the checkfile script and change the name of the file from parameters to
noname (check to ensure that you do NOT have a file by this name in your current
directory). Also, using conditional execution, if the ls command was NOT
successful, display the error message, The file was not found. Execute the
script. What else got displayed?
Answer: An error message from the ls command.
15-5
V3.1
Student Exercises with Hints
EXempty
Introduction
It will be necessary to perform this machine exercise through a VNC
session. Be sure to check with your instructor if you have any
questions regarding the terminal you should use.
While in the AIXwindows environment, you may wish to minimize or
close any windows not needed to prevent the terminal screen from
becoming too cluttered.
This exercise also includes an optional exercise. Verify with your
instructor that the machine setup will support the optional exercise.
16-1
Starting AIXWindows
__ 1. Start your terminal emulator application, connect to the AIX system, and log in.
login: teamxx
password <your password>
__ 2. Before we can start the VNC server application, you will need to set a VNC
password for your remote session. Run the vncpasswd program, and when
prompted, enter a password. Set your password to the same as your username (for
example, if your userid was team01, set the password to team01).
vncpasswd
__ 3. Start the VNC server application. Make note of the hostname/IP address and
session number for the VNC server that is started.
Hostname: ______________________________
IP Address: ______________________________
Session number: __________________________
$ vncserver
New X desktop is <hostname>:<session number>
Starting applications specified in
/home/team01/.vnc/xstartup
Log file is /home/team01/.vnc/<hostname>:<session
number>.log
$ host <hostname>
__ 4. Switch back to your lab workstation or lab portal facility and launch a VNC viewer.
Enter in the IPaddress:session where appropriate, and the password. If all is
correct, a window should appear with the AIXWindows environment in it, running
under your assigned userid.
Start a VNC viewer on your lab workstation (this will be either your classroom
workstation or a lab portal facility, depending on the lab configuration), and
specify the hostname or IP address and session number. When asked,
16-2 AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
supply the password you set in Step 3. The AIXWindows environment should
appear within the VNC client window.
16-3
Notice that with the Size option, the edge or corner that is moved to resize the
window is the first of them that the mouse pointer comes into contact with.
Click the left mouse button or press enter when you have finished resizing.
__ 11. View the window menu again. Why do you think some items may be greyed out?
__ 12. Open the window menu on the aixterm, but now type the letter m rather than clicking
move. Note that this is another way to move a window.
Click the window menu button with the left mouse button.
The window menu will appear.
Notice that the menu items have letters underlined (for example, the m in
move).
Press m on the keyboard. These functions are not case sensitive. What
happens?
These defined keys are known as mnemonics.Try the mnemonics for some of
the other functions.
__ 13. The window menu also contains key sequence definitions (for example Alt+F7).
These key bindings are known as accelerators.
What happens when you try pressing the Alt+F7 key when the menu is posted?
What happens if you try a mnemonic when the menu is not posted?
__ 14. Iconify (minimize) the aixterm window. Once it is an icon, restore it back to the
screen.
Use the left mouse button to click the small square button just to the right of
the title area. This should turn the window into an icon.
To restore the window, click the icon with the left mouse button. (When
working in VNC, you ma need to scroll the VNC window to locate the icon.)
The window menu is again displayed, with certain options activated. Using
the left mouse button, click restore. This will restore the window with its
previous location and size. Double-clicking an icon will also restore that
window.
V3.1
Student Exercises with Hints
EXempty
__ 15. Maximize the aixterm window. What happens? Once it is maximized, resize the
window to a smaller size.
Using the left mouse button, click the large square button to the right of the
title area. The aixterm window should fill the screen.
Make the window smaller using any of the techniques you have learned
previously.
16-5
To cut text from tempfile, move the mouse pointer to the beginning of the line
you wish to copy. Press the left mouse button and drag the pointer to where
you wish the selection to end. The selected text should be in reverse video.
When the left mouse button is released, the text will be placed into a buffer.
Move the mouse pointer to tempfile.new and left click to bring it to the
foreground. Then press the shift key and click the right mouse button. The
text will be placed beginning at the cursor location. (On a locally attached
graphics terminal and 3-button mouse, the middle button would normally be
used here)
<Esc> and :q!
__ 21. You have now completed this machine exercise. You may either try the optional
steps that follow, end AIXwindows or lock your terminal.
Continue with the optional steps.
-OR Move the mouse pointer to the root menu and press the right mouse button.
On the root menu choose Clients.
From the Clients menu choose Screen Lock.
To unlock the screen, attempt some action (such as clicking the mouse or
pressing enter) and, in response to the prompt, type your AIX user password.
__ 22. When you are done with working on this AIXWindows exercise, whether at this point
or somewhere in the optional steps), be sure to go to the last step (step 28) and
terminate the vncserver on your system.
lightskyblue
foreground color
forestgreen
font
rom10.iso1
title
My Window
V3.1
Student Exercises with Hints
EXempty
full cursor
scrollbar
aixterm -bg lightskyblue -fg forestgreen -fn rom10.iso1 -T My
Window -fullcursor -sb &
Why do you think this window is smaller than the others?
__ 25. Start an xclock from the command line within one of the windows. Give the clock
the following characteristics:
background color
white
foreground color
red
blue
second hand
16-7
xcalc &
ps
exit
__ 30. You have now completed the optional machine exercise. Shut down the VNC
AIXWindows session from your original terminal emulator session.
vncserver -kill :X (Where X is the VNC session number)
END OF EXERCISE
V3.1
Student Exercises with Hints
EXempty
Solutions
__ 11. View the window menu again. Why do you think some items may be greyed out?
Answer: The greyed out options are not active for this window.
__ 13. The window menu also contains key sequence definitions (for example Alt+F7).
These key bindings are known as accelerators. What happens when you try
pressing the Alt+F7 key when the menu is posted? What happens if you try a
mnemonic when the menu is not posted?
Answer: The Alt+F7 key combination is yet another way to move a window. Note
that the other window menu options also have accelerators.
The accelerators can be used even if the window menu is not an option. The
mnemonics can only be used if the window menu is open.
__ 23. Start an aixterm from the command line. Give the window the following
characteristics: ...
Why do you think this window is smaller than the others?
Answer: This window is smaller than the others because of the font. The window is
still 80 characters wide by 25 characters high, but appears smaller due to a small
font. To list all available fonts use xlsfonts command.
__ 28. From the remote system's window, execute the xcalc & command. From which
system is the calculator being executed? You can verify this with the ps command.
When you have completed this step, close the remote system's window.
Answer: The xcalc command should be executing on the remote system, but
displayed on your system.
16-9
V3.1
Student Exercises with Hints
EXempty
Introduction
This exercise is designed to provide an introduction to the features of
CDE. You will use the Help Manager to obtain information as needed.
Much of your work in this exercise will be with the File Manager, which
is one of the most useful CDE functions.
If time permits, an optional exercise is included on the CDE calendar
functions. Feel free to explore the other functions of CDE. In the next
unit and exercise, you will learn to customize your CDE environment.
17-1
V3.1
Student Exercises with Hints
EXempty
correct, a window should appear with the AIXWindows environment in it, running
under your assigned userid.
Start a VNC viewer on your lab workstation (this will be either your classroom
workstation or a lab portal facility, depending on the lab configuration), and
specify the hostname or IP address and session number. When asked,
supply the password you set in Step 3. The AIXWindows environment should
appear within the VNC client window.
__ 5. The CDE environment, by default, launches the Application Manager and File
Manager. Close those two windows (we will restart them later).
In the upper left corner of each window click on the file menu and then click
on the click on Close at the bottom of that menu.
__ 6. Locate the CDE Front Panel; you may need to scroll the desktop window to find it at
the bottom of the window. Find the following components of the CDE Front Panel
(do not click on them, just locate them):
Workspace Switch Buttons
The four push buttons in the middle of the panel.
Style Manager
The icon with the mouse and color palette.
File Manager
The icon that looks like a file cabinet drawer next to the calendar.
Application Manager
The icon that looks like a file cabinet drawer with a pencil (next to help).
Personal Application Manager
The icon that looks like a piece of paper and a pencil.
Clock, Calendar
Note the time and date.
Mail
The envelope icon.
Trash Can
Icon on the right end of the panel.
Exit Icon
The small icon to the right of the Workspace Switch buttons.
Move Handles
Left and right ends of the panel.
17-3
V3.1
Student Exercises with Hints
EXempty
17-5
V3.1
Student Exercises with Hints
EXempty
17-7
__ 29. Set the File Manager preferences to display a Directory Tree diagram, starting at the
root directory.
On the File Manager window, double-click the root directory icon.
Click View.
Click Set View Options.
In Headers, select Iconic Path, Text Path, and Message Line
In Show, select By Tree and Folders Only
In Representation select By Small Icons
Click Apply.
__ 30. Navigate to the root directory in the File Manager window.
Double click (left mouse button) on the root directory in the iconic path near
the top of the window.
__ 31. Expand the /usr/dt directory.
Click the + in front of the /usr icon (you may have to scroll).
Click the + in front of the dt icon (again, you may have to scroll to see the file
names listed).
The /usr/dt directory contains CDE executables and default configurations.
__ 32. Set your viewing options to see a single folder at a time (rather than a tree structure)
and using small icons. Also request display of the full path using icons near the top
of the window.
In the Set View options window:
Select only Iconic Path in Headers;
Select By Single Folder in Show;
Select By Small Icons in Representation.
Click Apply.
__ 33. Set your viewing options to display by properties (such as modify date, permissions,
owner etc). This output will look similar to the output of the ls -la command.
In the Set View Options window:
Unselect all choices in Headers
Select By Tree and Folders Only in Show;
Select by Name, date, size... in Representation.
Click Apply.
__ 34. Close the File Manager and any windows that it opened.
__ 35. Use the File Manager to execute the date command. This command is found in the
/bin directory.
Click the File Manager icon.
17-8 AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
17-9
V3.1
Student Exercises with Hints
EXempty
17-11
Click the Week View icon on the Calendar Toolbar. The Week View icon is
the third icon from the right.
__ 50. Set a reminder to yourself for the appointment. Make the appointment private so that
others cannot view it on your calendar.
Click the Appointment Editor icon. Again, this icon is the first icon on the
Calendar Toolbar.
Be sure your appointment shows in the Time What window. If it does not,
cancel the Appointment Editor and then click the day your appointment is
scheduled. Once this day is highlighted, click the Appointment Editor.
Select your appointment in the Time What window
On the Appointment Editor, click More. An extended appointment window
will be displayed.
Under Reminders, choose how you would like to receive the reminder; by
beep, flash, popup or mail.
Click Privacy and choose a preferred privacy option.
Once the reminder is complete, click Change. Then click Cancel.
__ 51. Return to the month view icon on the calendar menu bar.
Click the Month View icon on the calendar menu bar. It is the second from the
right.
__ 52. Close the Calendar window
Click the upper left of the window to display the menu window. Click Close.
__ 53. Exit out of the vnc session.
If using a VNC session, close the desktop window. Then switch to your ASCII
terminal session and type vncserver -kill :X where X is the session number
you previously created.
END OF EXERCISE
V3.1
Student Exercises with Hints
EXempty
Introduction
In this exercise, students will learn how to edit files to customize their
AIXwindows environment.
A-1
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
DarkSlateGrey
wheat
80x30
rom10.iso1
vi .Xdefaults
Add the above lines into the file. Be sure there are no trailing blanks after any
of the entries. Save the file using <Esc> :wq
__ 7. Restart AIXwindows. This will cause your new .Xdefaults file to be read and used
for any new aixterm windows you create. Now, open a new aixterm window. Does
it have the characteristics specified in the .Xdefaults file?
Move the mouse to the root window and press the right mouse button. This
will display the root menu.
Keeping the right mouse button depressed, move the mouse pointer to
Restart... and release the mouse button.
When asked if you want to Restart Mwm, use the left mouse button to click
OK.
Using the left mouse button, click one of your aixterm windows so that it
becomes the active window.
On the command line enter: aixterm &. This new window should use the
characteristics you entered into the .Xdefaults file.
__ 8. Now, end the AIXwindows session and then restart it. If using a VNC environment,
switch to your ASCII terminal session and issue vncserver -kill :session where
Copyright IBM Corp. 1995, 2008
A-3
session is the VNC session ID. Restart the session by running vncserver. What do
the two original windows look like? Why?
grey
navy
vi .Xdefaults
Edit the file to change the colors for your aixterm windows. Save the
changes.
__ 10. Restart the mwm and then create a new aixterm window from the command line.
Does it use your new color specifications? It should!
Move the mouse to the root window and press the right mouse button. This
will display the root menu.
Keeping the right mouse button depressed, move the mouse pointer to
Restart... and release the mouse button.
When asked if you want to Restart Mwm, use the left mouse button to click
OK.
Using the left mouse button, click one of your aixterm windows so that it
becomes the active window.
On the command line enter: aixterm &
__ 11. Exit your AIXwindows environment and log out from your system. If using VNC,
switch to your ASCII terminal session and kill the VNC server.
(LFT) Press <CTRL><ALT><BACKSPACE>.
(VNC) $ vncserver -kill :X (where X is the VNC session ID)
END OF EXERCISE
A-4
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
Introduction
In this exercise, students will learn how to use the AIXwindows custom
tool to customize their AIXwindows environment.
B-1
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
There are two ways to select a color. One way is to use the left mouse button
to scroll through the various colors. When you find one that looks interesting,
click the color with the left mouse button. The color will be displayed. Note the
red, green, and blue sliders in the window will change based on the color
chosen.
Another way to choose a color is to use the left mouse button to slide the red,
green and blue bars to whatever color mixture you want. The color will be
displayed. Once you decide on a color, click Match RGB to Closest Color
Name, and review the results.
Click Apply. The background color of the xcalc should change.
Click OK to close the window.
__ 7. Switch focus to an aixterm window and display the contents of .Xdefaults. Has it
been updated? It should not have been!
Use the left mouse button to click the aixterm window.
cat .Xdefaults
__ 8. So, to have your values saved in .Xdefaults, change your focus back to the xcalc
customizing window. Save the values you have chosen.
Use the left mouse button to click back to the xcalc Customizing Window.
Click File, which is located in the upper left of the window.
Click Save As....
On the Save As... window, you are given the opportunity to choose which
file you wish to save the values in. The default is $HOME/.Xdefaults. Click
OK.
__ 9. Now, review the .Xdefaults file again. Your resource change should now be there.
Use the left mouse button to click the aixterm window.
cat .Xdefaults
__ 10. Return to the xcalc Customizing window and now choose the resource category of
Fonts.
Use the left mouse button to click the Customizing Tool window.
Click the small rectangle in the Colors box. Keep the left mouse button
pressed.
Point to Fonts and release the mouse button.
__ 11. View the various fonts that can be used for the window interior.
Click the Fonts... button which corresponds to the window interior option.
The Fonts browser will appear.
Copyright IBM Corp. 1995, 2008
B-3
__ 12. The List of Fonts window is used to display all the possible fonts. Feel free to
scroll through them, but be aware that there are LOTS of fonts in the list! You can
narrow down the list of fonts by choosing Family, Weight, Slant, Style, Spacing,
and Size in the respective selection windows. Below these windows will be
feedback indicating how many fonts match the selection criteria.
Click a font from the List of Fonts that appears interesting. It will be displayed in
the Sample box (some fonts will not display). If you have trouble finding a font you
like, try the following to narrow down the search:
Family: Helvetica
Weight: Bold
Slant: All
Style: All
Spacing: All
Size: 14
Choose a font to be used for the xcalc window and save your choice as you did for
the background color. Verify they change has been added to your .Xdefaults file.
Close the Customizing windows.
Use the left mouse button to make your font choice. Once you select a font, it
will be displayed in the Sample box.
Once you have decided on the font to use, be sure it is highlighted and then
click Apply. xcalc should now use the new font.
Click OK.
On the xcalc customizing window, click File.
Click Save As...
Click OK to save your changes to the .Xdefaults file.
Click the upper left of the xcalc Customizing Tool window to open the
window menu and then click Close.
Run cat .Xdefaults to verify the font information has been updated in the
file.
__ 13. Use the customizing tool to change the background color for an aixterm. When you
choose Apply will the color of your existing aixterm windows change like it did for
the xcalc window? Will the new color be updated in the .Xdefaults file? Verify that
your change updated .Xdefaults and affects the appearance of a new aixterm.
Move the mouse point to the root window and hold down the right mouse
button. While still holding down the button, point to Custom and release the
button.
On the Customizing Tool window click aixterm and then OK.
Click the Colors... box for window interior background.
B-4
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
On the Colors window, choose any color and then click OK.
On the aixterm Customizing window, click File. Then, click Save as....
On the Save As... window, click OK. Your changes have now been added to
the .Xdefaults file.
Close the aixterm Customizing window by clicking in the upper left corner to
open the window menu and then click Close.
cat .Xdefaults
aixterm &
B-5
Optional Exercises
Using the Custom Tool: Size and Location, Icons and Scrollbar
__ 18. Make sure you have a running Calculator Tool. If not, start one.
In your aixterm window enter: xcalc &
__ 19. Start the AIXwindows Custom Tool and choose xcalc again.
Move the mouse pointer to the root window and press the right mouse button.
While still holding the button down, point to Custom and release the mouse
button.
On the Customizing Tool window, click xcalc and then OK.
__ 20. Choose the Size and Location resource category and customize the size of the
xcalc.
On the xcalc Customizing window, use the left mouse button to click the
small rectangle in the Colors box. Click Size and Location.
On the Size and Location window, try using different pixel values for height
and width. As a suggestion, start with a size of 300x400. Press Enter after
choosing the sizes you want. Notice the change in the calculator tool.
Save the size values if you want by clicking File. Then, click Save as.... On
the Save As... window, click OK. Your changes have now been added to the
.Xdefaults file.
__ 21. Suppose you wish to update the icon used for a particular AIXwindows application.
To demonstrate how this is done, we will change the icon used for xcalc. You may
first want to iconify and then restore the xcalc window to view the icon that is used.
Then, use the xcalc Customizing window, and choose the icon resource category.
On the xcalc Customizing window, click the small rectangle in the Colors
box and then click Icon.
__ 22. Choose a new icon for the xcalc window: have the icon look like a terminal. Once
you have completed this task, review the .Xdefaults file to verify that your entry has
been added. Test the new icon to verify that it is being used.
Click Pictures which corresponds to the icon picture * line.
The window under Files lists all the available pictures that can be used as
an icon. Scroll through the list to see what the options are. To view any of
them, click the file name and then on View Picture. The escherknot is an
interesting icon to view.
Under Files, click the icon file named terminal and then View Picture.
Once you approve of this choice, choose Cancel to remove the picture.
Click OK to save your choice.
B-6
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
On the xcalc Customizing window, use the left mouse button to click File,
then Save As..., then OK to save your values in the .Xdefaults file.
Close the Customizing Tool window by choosing Close from the window
menu.
Now, from an aixterm window, view the .Xdefaults file using the cat
.Xdefaults command to make sure your change has been added.
In order for the new icon to be used, MWM must be restarted. Move the
mouse pointer to the root window and press the right mouse button. Choose
Restart and then OK to restart the Motif window manager.
Now, iconify the xcalc window. It should use the new icon you have chosen.
__ 23. Now, add a scroll bar to the aixterm windows. Verify that the .Xdefaults file has
been updated and test to verify that the scroll bar works.
Move the mouse pointer to the root window and press the right mouse button.
Holding down on the button, point to Custom and release the button.
On the Customizing Tool window, click aixterm and then OK.
Click the small rectangle in the Colors box and then click Scroll Bar.
Click the box for visible scroll bar and choose true.
Click File, Save As... and then OK.
Close the Customizing Tool window by choosing Close from the window
menu.
View the .Xdefaults file using the cat .Xdefaults command. The scrollbar
resource should be listed.
Start an aixterm window using the aixterm & command. The new window
should display a scrollbar.
__ 24. In your new aixterm window, list the files in /usr/bin and then use the scrollbar to go
back and forth in the listing.
In the aixterm window run: ls /usr/bin
In the scrollbar area click your right mouse button to scroll up
In the scrollbar area click your left mouse button to scroll down
B-7
Move the mouse pointer to the root window and press the right mouse button.
On the root menu, click Custom.
On the Customizing Tool window click mwm and then on OK.
From the Mwm Customizing window, view the various resource categories by
moving the left mouse button to the small rectangle in the Colors box and
clicking. You will see that there are many resources that can be tailored.
Choose Colors, which is the default.
For the window manager background type in red.
For the window manager foreground type in blue.
Click File, Save As... and then OK to save the new resource values in the
.Xdefaults file.
Change the focus to an aixterm and view the .Xdefaults file using the cat
.Xdefaults command to verify the changes have been stored.
Move the mouse pointer to the root window and click the right mouse button.
Choose Restart from the root menu and then OK to restart the mwm. What
happens?
Now, view both the root menu and the window menu. The colors should have
changed!
__ 26. Some users prefer to use the pointer focus policy so they dont have to click a
window to make it the active window. The pointer focus policy allows you to merely
move the pointer to a window to make it the active window. If you are interested,
change your focus policy to pointer. Verify that .Xdefaults has been updated and
that the new focus policy works.
From the Mwm Customizing window, click the small rectangle in the Colors
box. Then, click Focus.
Move the pointer to the box that corresponds to the keyboard focus policy
and click the small rectangle.
The default is explicit, meaning that you need to click a window to make it the
active window. If you wish to change the focus policy, click pointer.
To save this change, click File, Save As... and OK.
Use the cat .Xdefaults command the verify the changes have been made
to the .Xdefaults file.
Now, restart the mwm by moving the mouse pointer to the root window and
using the right mouse button, point to Restart.... Click OK to restart the
Motif Window Manager.
You will notice now that when you move the mouse around, the different
windows will be highlighted. The highlighted window is the active window.
B-8
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
The pointer focus policy seems to work best if the windows are not
overlapped.
End the customizing tool when you have finished. You may also want to
iconify or close some windows if your screen is looking cluttered.
END OF EXERCISE
B-9
V3.1
Student Exercises with Hints
EXempty
Introduction
Students will work as teams using a graphics terminal to customize
their CDE environment. This machine exercise will focus on using the
interactive customization features of CDE. First, the CDE environment
will be customized using the Style Manager. Then, the Front Panel will
be customized.
C-1
C-2
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
C-3
Check each of the workspaces to see if the same application session is available.
__ 8. Now, remove a Workspace application from one or more Workspaces.
If you want to remove an application, which you previously occupied into
multiple Workspaces, from a Workspace you can see that there is an
Unoccupy Workspace menu item in the pull down Window menu for just that
purpose.
__ 9. Have the dtterm application appear on the Front Panel as the default application
associated with the Personal Applications control.
Click the arrow above the Personal Applications control to display the
subpanel.
Point at Terminal, the item you want to have on the Front Panel.
Press the right mouse button.
Choose Copy to Main Panel.
The icon for the terminal should now appear on the Front Panel.
Click the arrow above the Personal Applications control to close the
subpanel.
__ 10. Tear off the Personal Applications subpanel menu, and place it on the workspace.
Click the arrow above the Personal Applications control to raise its
subpanel.
With the subpanel now raised, point at its title bar.
Press and hold the left button on the mouse and drag the whole menu to a
convenient location on the backdrop.
Release the mouse buttons to drop the menu at that location.
The menu will stay displayed after an item has been selected. Normally, it will
close after one of its items has been selected.
__ 11. Create a new subpanel for the Style Manager control and add the Icon Editor and
the aixterm applications to it.
Point at the Style Manager control. Notice that it does not have a subpanel
since there is no arrow above its control.
Press the right mouse button to get a pop-up menu.
Select the Add Subpanel option.
If the control already had a subpanel present, there would have also been an
option to delete the subpanel.
Click the subpanel. Note that it contains two items: Install Icon, which
enables you to add more items to this subpanel, and a function related to the
control itself.
C-4
AIX 6 Basics
V3.1
Student Exercises with Hints
EXempty
C-5
Select the Firefox icon, and drag it with the left mouse button on to the Install
Icon.
__ 16. Close the Personal Applications subpanel.
Click the arrow in the subpanel.
__ 17. Find out the name of the definition file in directory $HOME/.dt/types/fp_dynamic.
Write down the file name:
$ ls $HOME/.dt/types/fp_dynamic
The file name should be Firefox1.fp
__ 18. Copy this definition file to directory $HOME/.dt/types and specify a new file name.
$ cd $HOME/.dt/types
$ cp fp_dynamic/firefox1.fp browser.fp
__ 19. Anchor the application control in the Front Panel by editing the copied definition file.
Use your student notes to find out which lines must be changed.
$ vi browser.fp
CONTAINER_TYPE
CONTAINER_NAME
POSITION_HINTS
BOX
Top
last
__ 20. Restart the CDE. After restarting CDE, you should see the application icon on the
Front Panel.
END OF EXERCISE
C-6
AIX 6 Basics
V3.1
backpg
Back page