Sie sind auf Seite 1von 104

Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Oracle Solaris h a s10 Operating
m ) ideฺ
System
i l ฺ coEssentials
t G u
o t ma Guide
Activity d e n
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

D61752GC21
Edition 2.1
June 2011
D73329
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Disclaimer

This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and
print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way.
Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display,
perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization
of Oracle.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

The information contained in this document is subject to change without notice. If you find any problems in the document, please
report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not
warranted to be error-free.

Restricted Rights Notice

If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United
States Government, the following notice is applicable:

U.S. GOVERNMENT RIGHTS


The U.S. Government’s rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted
by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract.
a b le
f e r
Trademark Notice
an s
n - t r
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective
o
an
owners.

s
ha eฺ
Author )
Enzo Silva
i l ฺ comt Guid
o t ma den
Technical Contributor and Reviewer
@ h S tu
Mike Lanker
- 90 thi s
l z
le Oracle
This book was published using: se Tutor
t e u
i s a- e to
z (lu cens
élle li
a T
Luis
Table of Contents
Practices for Lesson 1: Oracle Solaris 10 Operating System Essentials ................................................ 1-1
Practices for Lesson 1............................................................................................................................. 1-2
Practices for Lesson 2: Using the Oracle Solaris 10 OS .......................................................................... 2-1
Practices for Lesson 2: Overview............................................................................................................. 2-2
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Practice 2-1: Identifying Computer Components....................................................................................... 2-3


Practice 2-2: Using a Password ............................................................................................................... 2-4
Practice 2-3: Logging in Using the Command Line Login Option ............................................................... 2-5
Practice 2-4: Invoking a Failsafe Session ................................................................................................. 2-6
Practice 2-5: Locking the Desktop Environment Screen ............................................................................ 2-7
Practice 2-6: Changing the Desktop Background...................................................................................... 2-8
Practice 2-7: Moving Files by Using Drag-and-Drop ................................................................................. 2-9
Practice Solutions ................................................................................................................................... 2-10

a ble
Practices for Lesson 3: Using Command-Line Features and Online Help Resources ............................ 3-1
f e r
Practices for Lesson 3: Overview............................................................................................................. 3-2
an s
t r
Practice 3-1: Constructing Commands ..................................................................................................... 3-3
n -
a no
Practice 3-2: Using Command-Line Features ........................................................................................... 3-4
Practice 3-3: Scrolling Through Online man Pages................................................................................... 3-5
h a s
Practice 3-4: Using Online Documentation ............................................................................................... 3-6
m ) ideฺ
Practice Solutions: Using Command Line Features .................................................................................. 3-7
i l ฺ co t Gu
t m a
Practices for Lesson 4: Viewing Directories and Files ............................................................................
e n 4-1

h o t u d
Practices for Lesson 4: Overview............................................................................................................. 4-2

Practice Solutions: Accessing Files and 9 i s S


Practice 4-1: Accessing Files and Directories ........................................................................................... 4-3
0@ ..................................................................................
z - Directories
e t h 4-5
Practices for Lesson 5: Workingllwithe Filesuand s Directories .................................................................... 5-1
Practices for Lesson 5: a - te .............................................................................................................
Overview t o 5-2
i s e
z (luUsing
Practice 5-1: Using
c e ns FileandCommands
Directory and .................................................................................... 5-3

é l le
Practice Solutions: li Directory File Commands........................................................................... 5-6
T for Lesson 6: Using the vi Editor.............................................................................................. 6-1
Practices
a
s
ui Practices for Lesson 6: Overview............................................................................................................. 6-2
L Practice 6-1: Using the vi Editor ............................................................................................................... 6-3
Practices for Lesson 7: Using Commands Within the Shell .................................................................... 7-1
Practices for Lesson 7: Overview............................................................................................................. 7-2
Practice 7-1: Working in the Korn Shell .................................................................................................... 7-3
Practice Solutions: Working in the Korn Shell ........................................................................................... 7-5
Practices for Lesson 8: Using Basic File Permissions ............................................................................ 8-1
Practices for Lesson 8: Overview............................................................................................................. 8-2
Practice 8-1: Changing File Permissions .................................................................................................. 8-3
Practice Solutions: Changing File Permissions......................................................................................... 8-6
Practices for Lesson 9: Configuring Access Control Lists (ACLs).......................................................... 9-1
Practices for Lesson 9: Overview............................................................................................................. 9-2
Practice 9-1: Using Access Control Lists .................................................................................................. 9-3
Practice Solutions: Using Access Control Lists......................................................................................... 9-6
Practices for Lesson 10: Searching Files and Directories ....................................................................... 10-1
Practices for Lesson 10: Overview ........................................................................................................... 10-2
Practice 10-1: Locating Files and Text ..................................................................................................... 10-3

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Oracle Solaris 10 Operating System Essentials


i
Practice Solutions: Locating Files and Text .............................................................................................. 10-5
Practices for Lesson 11: Performing Basic Process Control .................................................................. 11-1
Practices for Lesson 11: Overview ........................................................................................................... 11-2
Practice 11-1: Manipulating System Processes ........................................................................................ 11-3
Practice Solutions: Manipulating System Processes ................................................................................. 11-6
Practices for Lesson 12: Advanced Shell Functionality ......................................................................... 12-1
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Practices for Lesson 12: Overview ........................................................................................................... 12-2


Practice 12-1: Managing Jobs in the Korn Shell ....................................................................................... 12-3
Practice Solutions: Managing Jobs in the Korn Shell ................................................................................ 12-5
Practices for Lesson 13: Reading Shell Scripts ....................................................................................... 13-1
Practices for Lesson 13 ........................................................................................................................... 13-2
Practices for Lesson 14: Creating Archives............................................................................................. 14-1
Practices for Lesson 14: Overview ........................................................................................................... 14-2
Practice 14-1: Archiving and Retrieving Files ........................................................................................... 14-3
a ble
Practice Solutions: Archiving and Retrieving Files .................................................................................... 14-5
f e r
Practices for Lesson 15: Compressing, Viewing, and Uncompressing Files .......................................... 15-1
an s
n - t r
Practices for Lesson 15: Overview ........................................................................................................... 15-2
no
Practice 15-1: Compressing and Restoring Files ...................................................................................... 15-3
a
h a s
Practice Solutions: Compressing and Restoring Files ............................................................................... 15-5

m ) ideฺ
Practices for Lesson 16: Performing Remote Connections ..................................................................... 16-1
o u
a ilฺc nt G
Practices for Lesson 16: Overview ...........................................................................................................
Practice 16-1: Performing Remote Connection Commands ......................................................................
16-2
16-3
t m e
Practice Solutions: Performing Remote Connection Commands ud
ho St............................................................... 16-5

9 @
0 this
-
t e l lez use
i s a- e to
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Oracle Solaris 10 Operating System Essentials


ii
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Practices for h a s
Lesson 1:
)
m ui10 e ฺ
d Operating
Oracle
i l ฺ coSolaris
t G
a eEssentials
System
t m n
@ S tu1 d
hoChapter
- 9 0 this
t e l lez use
i s a- e to
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Oracle Solaris 10 Operating System Essentials


Chapter 1 - Page 1
Practices for Lesson 1

Practices Overview
There are no practices for Lesson 1.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Oracle Solaris 10 Operating System Essentials


Chapter 1 - Page 2
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Practices for h a s
Lesson 2: Using
) e ฺ
the Oracle
i l ฺ comtSolaris
G uid 10 OS
o t ma 2 den
Chapter
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Using the Oracle Solaris 10 OS


Chapter 2 - Page 1
Practices for Lesson 2: Overview

Practices Overview

In this practice, you complete the following tasks:


• Identify computer components
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

• Use and change a password


• Log in using the command-line Login option
• Invoke a Failsafe session
• Lock the desktop environment screen
• Change the desktop background
• Move files by using drag-and-drop

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Using the Oracle Solaris 10 OS


Chapter 2 - Page 2
Practice 2-1: Identifying Computer Components

Overview
To identify components of the computer, complete the following steps:

Tasks
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

1. The four main components of the hardware are:


a. RAM ______________________
b. CPU ______________________
c. I/O devices ______________________
d. Operating system ______________________
e. Hard disk ______________________
f. Software ______________________
a ble
2. Name the three main components of the SunOS operating system.
f e r
___________________________________________________________
ans
___________________________________________________________ n - t r
o
an
___________________________________________________________
s
3. ha eฺ
Define a virtual memory operating system. Name a virtual memory operating system.
)
i l comt Guid
___________________________________________________________

___________________________________________________________
o t ma den
___________________________________________________________
4. @ h S tu
Distinguish between the Sun OS 5.x operating system and the Solaris 10 OS.
- 90 thi s
l z
__________________________________________________________
le use
t e
a- e to
___________________________________________________________
i s
(lu cens
____________________________________________________________
z
5.
li
List the three primary shells supported by the Solaris OS.
élle
a T
___________________________________________________________

Luis ___________________________________________________________
___________________________________________________________
6. Name the default shell for the root (/) user in the Solaris 10 OS.
__________________________________________________________
7. Match the following terms with their descriptions:
__ Shell a. Core of the Solaris OS
__ Kernel b. Command interpreter
__ Hard Disk c. Storage device

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Using the Oracle Solaris 10 OS


Chapter 2 - Page 3
Practice 2-2: Using a Password

Overview
To log in using your desktop environment login screen and change your password, complete the
following steps:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Tasks
1. Obtain a username and password from your instructor.
2. Log in to the system using the desktop environment Login screen.
a. Type your username, and press Return.
b. Type your password, and press Return.
3. Right-click the desktop environment background.
The Workspace menu appears.
4. Select Open Terminal from this menu. a ble
f e r
A terminal window appears.
ans
5. Use the passwd command to change your password to mypass1.
n - t r
o
$ passwd
s an
passwd: Changing password for username
) ha eฺ
comt Guid
Enter existing login password:
New password: i l ฺ
Re-enter new passwd:
o t ma den
@ h S tu
passwd: passwd successfully changed for username
- 90 thi s
$
l z
le use
6. e
Close the terminal window.
t
a- e to
7. i s
Click Launch > Log Out <username> to log out of the desktop environment session.
z (lu cens
A logout confirmation window appears.
8. élle li
Click OK or press Return to continue to log out.
a T
Luis9. Enter the following incorrect username and password on the Login screen:
Username: student2
Password: wrong
The following message appears:
Login incorrect; please try again
10. Click and hold down the Options button on the Login screen.
11. Select the Reset Login Screen option from the Options menu.
Note: After successful completion of Step 11, reset the default password of the user before
moving to the next task.

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Using the Oracle Solaris 10 OS


Chapter 2 - Page 4
Practice 2-3: Logging in Using the Command Line Login Option

Overview
To log in using the command line, complete the following steps:

Tasks
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

1. Click and hold down the Options button on the Login screen.
2. Select Command Line Login.
The following message appears:
****************************************************************
*Suspending Desktop Login ...
*
*If currently logged out, press [Enter] for a console login
prompt.
a ble
f e r
*
ans
*Desktop Login will resume shortly after you exit console
n - t r
session.
a no
h a s
****************************************************************
*
m ) ideฺ
3.
i l ฺ co t Gu
Press Return to display the following login prompt:
hostname console login:
o t ma den
4. h
Type your username, and press Return.
@ S tu
5.
90 thi s
Type your new password, and press Return.
-
6. z
le use
At the shell prompt, type exit.
l
a -
The hostname console t e to prompt reappears. After a short time, the Login
login:
i s e
(lu cens
screen reappears.
z
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Using the Oracle Solaris 10 OS


Chapter 2 - Page 5
Practice 2-4: Invoking a Failsafe Session

Overview
To invoke a Failsafe session, complete the following steps:

Tasks
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

1. Click and hold down the Options button on the Login screen.
2. Select Session.
The Session menu appears.
3. Select Failsafe Session.
4. Type your username, and press Return.
5. Type your password, and press Return.
A terminal window appears.
a ble
6. Using the mouse, move the cursor into the terminal window.
f e r
7. At the shell prompt, type exit.
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Using the Oracle Solaris 10 OS


Chapter 2 - Page 6
Practice 2-5: Locking the Desktop Environment Screen

Overview

Tasks
1. What are the two ways in which you can secure your login session?
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

___________________________________________________________
___________________________________________________________
2. To lock the desktop environment screen, complete the following steps:
a. Log in to the desktop using the default desktop environment session.
b. Click Launch > Lock Screen to lock the current desktop environment session.
c. Type your password and press Return to regain access to your desktop environment
session.
a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Using the Oracle Solaris 10 OS


Chapter 2 - Page 7
Practice 2-6: Changing the Desktop Background

Overview
To change the desktop background, complete the following steps:

Tasks
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

1. Log in to the desktop by using the default desktop environment session.


2. Click Launch > Preferences > Desktop Preferences > Display > Desktop Background
option.
The Desktop Background Preferences window appears.
3. Select the background that you want to use from the Desktop Wallpaper list.
4. Click Close.

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Using the Oracle Solaris 10 OS


Chapter 2 - Page 8
Practice 2-7: Moving Files by Using Drag-and-Drop

Overview

To drag and drop a file into a directory in the desktop environment, you must create a directory
and a file.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Tasks
1. Double-click the Documents icon on the Desktop to open the File Browser window.
2. In the File Browser window, click File > Create Folder.
A folder icon with the name, untitled folder, appears in edit mode.
3. Name this folder Folder1.
4. Click File > Create Document > Empty File in the File Browser window.
A file icon with the name new file appears in edit mode.
a ble
f e r
5. Name this file File1.
ans
6. Move your pointer over the File1 icon.
n - t r
7. Click and hold the left mouse button.
a no
h a s
8. Drag the File1 icon over the Folder1 icon, and release the mouse button.
The File1 file is moved into the Folder1 folder.
m ) ideฺ
9. Move your pointer over the Folder1 icon. i l ฺ co t Gu
10. Right-click the Folder1 icon.
o t ma den
A menu appears. @ h S tu
11. Select Move to Trash. - 90 thi s
l z
le use
t e
The Folder1 folder is moved to Trash.
a- e to
i s
(lu cens
Practice Summary
z
Discussion:
é li minutes to discuss what experiences, issues, or discoveries you had
lle Take a few
T
during
a the practices.
u i s • Experiences
L
• Interpretations
• Conclusions
• Applications

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Using the Oracle Solaris 10 OS


Chapter 2 - Page 9
Practice Solutions

Practice 2-1: Identifying Computer Components


To identify components of the computer, complete the following steps:
1. The four main components of the hardware are:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a. RAM ___X__________________
b. CPU ___X__________________
c. I/O devices ___X__________________
d. Operating system ______________________
e. Hard disk ___X__________________
f. Software ______________________
2. Name the three main components of the SunOS operating system.
• The kernel
a ble
• The shell f e r
ans
• The directory hierarchy
n - t r
3. Define a virtual memory operating system. Name a virtual memory operating system. o
s an
A virtual memory operating system enables the execution of programs, as if more memory
ha eฺ
were available than physically exists in RAM. SunOS 5.x is a virtual memory operating
)
system.
i l ฺ comt Guid
ma den
4. Distinguish between the SunOS 5.x operating system and the Solaris 10 OS.
o t
The SunOS 5.x operating system consists of the kernel, the shell, and the directory
hierarchy. @ h S tu
- 90 thi s
l z
The Solaris 10 OS consists of the SunOS 5.x operating system, Open Network Computing
le use
t e
(ONC+) software, and the Solaris desktop environment GUI.
a- e to
i s
5. List the three primary shells supported by the Solaris OS.
z (lu cens
• Bourne shell
élle
• C shell
li
a T
Luis • Korn shell
6. Name the default shell for the root (/) user in the Solaris 10 OS.
Bourne shell.
7. Match the following terms with their descriptions:
b Shell a. Core of the Solaris OS
a kernel b. Command interpreter
c Hard disk c. Storage device

Practice 2-5: Locking the Desktop Environment Screen


1. What are the two ways in which you can secure your login session?
Locking the screen and exiting the session

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Using the Oracle Solaris 10 OS


Chapter 2 - Page 10
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Practices for h a s
Lesson 3: Using
) e ฺ
i l ฺ comt GuidFeatures and
Command-Line
o t ma dHelp
Online e n Resources
@ h Chapter
S tu3
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Using Command-Line Features and Online Help Resources
Chapter 3 - Page 1
Practices for Lesson 3: Overview

Practices Overview
In this exercise, you perform the following tasks:
• Construct commands
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

• Use command-line features


• Scroll through online man pages
• Use online documentation

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Using Command-Line Features and Online Help Resources
Chapter 3 - Page 2
Practice 3-1: Constructing Commands

Overview
To identify components of the computer, complete the following steps:

Tasks
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

1. To construct commands, arrange the following terms to show the correct syntax of a
command:
options arguments command

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Using Command-Line Features and Online Help Resources
Chapter 3 - Page 3
Practice 3-2: Using Command-Line Features

Overview
To use command-line features, complete the following steps:

Tasks
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

1. Open a terminal window, if you do not already have one open. Name the two components
of command-line syntax that can enhance the capability of a command.
______________________________________________________________________
2. Enter the command to display information about the operating system and the workstation
name.
_____________________________________________________________
3. Execute the man uname command. List the functions of the -s and -r options to the
uname command. a ble
f e r
_____________________________________________________________
ans
_____________________________________________________________
n - t r
o
a. Enter the uname -s command. What information appears?
s an
ha eฺ
________________________________________________________
)
comt Guid
b. Enter the uname -r command. What information appears?
i l ฺ
________________________________________________________
4. t ma den
Enter the command to display the current time and date on your system.
o
@ h S tu
_____________________________________________________________
- 90 thi s
5. z
Display this month’s calendar. What command did you enter?
l le use
t e
_____________________________________________________________
a- e to
6. i s
What special character is used to separate commands on a single command line?
z (lu cens
____________________________________________________________
7. élle li
Enter the command to clear your terminal window.
a T
Luis _____________________________________________________________

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Using Command-Line Features and Online Help Resources
Chapter 3 - Page 4
Practice 3-3: Scrolling Through Online man Pages

Overview
To learn how to search for online documentation: In the following table, list the keys or the
functions of the keys used to control scrolling the online man pages.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Keys Function
Displays the next screen of a man page
Return
/pattern
Quits the man command
a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Using Command-Line Features and Online Help Resources
Chapter 3 - Page 5
Practice 3-4: Using Online Documentation

Overview
To access online documentation, complete the following steps:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Tasks
1. Using the -k option with the man command, find the man page that describes how to clear
a terminal window (use the keyword clear). How do you enter this command on the
command-line?

_____________________________________________________________
2. Clear the terminal window.
3. What Web site enables you to browse Oracle product documentation?
a ble
f e r
_____________________________________________________________
ans
n - t r
a no
Practices Summary
h a s
m d ฺ
Discussion: Take a few minutes to discuss what experiences,)issues, orediscoveries you had
o u i
during the lab exercises.
• Experiences a ilฺc nt G
• Interpretations h otm tude
• Conclusions - 9 0@ this S
• Applications
t e l lez use
i s a- e to
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Using Command-Line Features and Online Help Resources
Chapter 3 - Page 6
Practice Solutions: Using Command Line Features

Practice 3-1: Constructing Commands


1. To construct commands, arrange the following terms to show the correct syntax of a
command:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

options arguments command


command options arguments

Practice 3-2: Using Command-Line Features


1. Open a terminal window, if you do not already have one open. Name the two components
of command-line syntax that can enhance the capability of a command.
Options and arguments
2. Enter the command to display information about the operating system and the workstation
name.
a ble
f e r
$ uname -a
ans
3. Execute the man uname command. List the functions of the -s and -r options to the
n - t r
uname command. o
an
The -r option prints the operating system release level. The -s option prints the name of
s
the operating system.
) ha eฺ
i l ฺ comt Guid
a. Enter the uname -s command. What information appears?

o t ma den
The operating system name, for example, SunOS.

@ h S tu
b. Enter the uname -r command. What information appears?

90 thi s
The operating system release level, for example, 5.10.
-
4. z
le use
Enter the command to display the current time and date on your system.
l
$ date t e
a- e to
i s
5.
(lu cens
Display this month’s calendar. What command did you enter?
z
élle
$ cal li
6.
a T
What special character is used to separate commands on a single command line?

Luis The semicolon (;)


7. Enter the command to clear your terminal window.
$ clear

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Using Command-Line Features and Online Help Resources
Chapter 3 - Page 7
Practice 3-3: Scrolling Through Online man Pages
To learn how to search for online documentation, list the keys or the functions of the following
keys in the empty cells in Table 2-4 to control scrolling the online man pages:
Keys Function
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Space bar Displays the next screen of a man page


Return Displays the next line of a man page
/pattern Searches forward for a pattern
Q Quits the man command and returns to
the shell prompt

Practice 3-4: Using Online Documentation


a ble
To access online documentation, complete the following steps: f e r
1. Using the -k option with the man command, find the man page that describes how to clear ans
a terminal window (use the keyword clear). How do you enter this command on the n - t r
o
command-line?
s an
$ man -k clear
) ha eฺ
comt Guid
2. Clear the terminal window.
i l ฺ
ma den
$ clear
o t
3. What Web site enables you to browse Oracle product documentation?
The Web site http://docs.sun.com@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Using Command-Line Features and Online Help Resources
Chapter 3 - Page 8
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Practices for h a s
Lesson 4:
) e ฺ
Viewing
i l ฺ com G uid and Files
Directories
t m a 4 ent
@ ho Stud
Chapter

- 9 0 this
t e l lez use
i s a- e to
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Viewing Directories and Files


Chapter 4 - Page 1
Practices for Lesson 4: Overview

Practices Overview
In this practice, you use the commands described in the lesson to list and change directories. All
the directories are situated within your home directory.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Viewing Directories and Files


Chapter 4 - Page 2
Practice 4-1: Accessing Files and Directories

Overview
To access files and directories, complete the following steps. Write the commands that you use
to perform each task in the space provided.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Preparation
Ensure that a default printer is configured for your system. You can use the lpstat -d
command to view the default printer information. Ask your instructor for any help required.

RLDC
In addition to being able to use local classroom equipment, this lab was designed to also use
equipment located in a remote lab data center. Directions for accessing and using this resource
can be found at:
a ble
http://remotelabs.sun.com/
f e r
Ask your instructor for the particular SSH configuration file that you should use to access the ans
appropriate remote equipment for this practice. n - t r
a no
h a s
Tasks
m ) ideฺ
1. Display your current working directory.
i l ฺ co t Gu
o t ma den
_____________________________________________________________
2. Change to your home directory.
@ h S tu
- 90 thi s
_____________________________________________________________
3. Display the contents of lyour
z
le current e
sworking directory.
- t e o u
l u i sa se t
_____________________________________________________________

l e z l i c en any hidden files.


4. Display all(files, including
él
_____________________________________________________________
T
a Display a long list of the contents of the current working directory.
5.
Luis _____________________________________________________________
6. Display the file types in your current working directory.
_____________________________________________________________
7. Change to the dir1 directory.
_____________________________________________________________
8. Display a long list of the contents of the current working directory.
_____________________________________________________________
9. Change to the fruit directory.
_____________________________________________________________
10. Change to the planets directory available under $HOME/dir3 directory by using the
relative pathname.
_____________________________________________________________
11. Return to your home directory.
____________________________________________________________

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Viewing Directories and Files


Chapter 4 - Page 3
12. Change directories to the dir1 directory by using an absolute pathname.
____________________________________________________________
13. Return to your home directory.
____________________________________________________________
14. Change to the /etc directory by using a relative pathname.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

____________________________________________________________
15. Return to your home directory.
____________________________________________________________
16. Display a long list of the contents of the current working directory.
____________________________________________________________
17. Display the contents of the fruit file by using the cat command.
____________________________________________________________
18. Under what circumstances must you refrain from using the cat command to view the a ble
contents of a file? f e r
ans
____________________________________________________________
n - t r
19. Display the contents of the fruit file and the fruit2 file by using a single command. o
s
_____________________________________________________________an
) ha eฺ
20. Display on the screen the first five lines of the /usr/dict/words file.
ฺ comt Guid
_____________________________________________________________
i l
o t ma den
21. Display on the screen the last eight lines of the /usr/dict/words file.
h tu
_____________________________________________________________
@ S
- 90 thi s
22. Distinguish between the head and tail commands.
l z
le use
_____________________________________________________________
t e
a- e to
s
_____________________________________________________________
i
(lu cens
23. Determine the total number of lines contained in the /usr/dict/words file.
z
élle li
_____________________________________________________________
a T
Luis24. Print the dante_1 file to the default printer.
_____________________________________________________________
25. What action occurs when you enter the lp -m command for the default printer?
_____________________________________________________________
26. What does the ~ symbol represent?
_____________________________________________________________

Practice Summary
Discussion: Take a few minutes to discuss what experiences, issues, or discoveries you had
during the practices.
• Experiences
• Interpretations
• Conclusions
• Applications

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Viewing Directories and Files


Chapter 4 - Page 4
Practice Solutions: Accessing Files and Directories
To access files and directories, complete the following steps. Write the commands that you use
to perform each task in the space provided.
1. Display your current working directory.
$ pwd
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

2. Change to your home directory.


$ cd
$ pwd
3. Display the contents of your current working directory.
$ ls
4. Display all files, including any hidden files.
$ ls -a
5. Display a long list of the contents of the current working directory.
a ble
f e r
$ ls -l
ans
6. Display the file types in your current working directory.
n - t r
$ ls -F
a no
7. Change to the dir1 directory.
h a s
$ cd dir1
m ) ideฺ
$ pwd
i l ฺ co t Gu
8. ma den
Display a long list of the contents of the current working directory.
o t
$ ls -l
@ h S tu
9. Change to the fruit directory.
- 90 thi s
$ cd fruit l z
le use
t e
a- e to
$ pwd
i s
z lu planets
10. Change to(the
c e nsdirectory available under $HOME/dir3 directory by using the
li
éll$ecdpathname.
relative
a T ../../dir3/planets
u i s
L $ pwd
11. Return to your home directory.
$ cd
$ pwd
12. Change directories to the dir1 directory by using an absolute pathname.
$ cd /export/home/student/dir1
$ pwd
or
$ cd ~/dir1
13. Return to your home directory.
$ cd;pwd

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Viewing Directories and Files


Chapter 4 - Page 5
14. Change to the /etc directory by using a relative pathname.
$ pwd
/export/home/student
$ cd ../../../etc
$ pwd
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

/etc
15. Return to your home directory.
$ cd;pwd
16. Display a long list of the contents of the current working directory.
$ ls -l
17. Display the contents of the fruit file by using the cat command.
$ cat fruit
18. Under what circumstances must you refrain from using the cat command to view the
a ble
contents of a file? f e r
Do not use the cat command to view binary files. ans
n - t r
no
19. Display the contents of the fruit file and the fruit2 file by using a single command.
a
$ cat fruit fruit2
h a s
20. Display on the screen the first five lines of the /usr/dict/words
m ) idfile.
e ฺ
$ head -5 /usr/dict/words
i l ฺ co t Gu
21. Display on the screen the last eight lines of m thea/usr/dict/words
e n file.
o t d
$ tail -8 /usr/dict/wordsh
@ S tu
22. Distinguish between the head - 9and s
0 tailthcommands.
i
The head command displays
z
lle theufirst e
s 10 lines of a file, whereas the tail command
- t e t o
l sa number
displays the last 10
uitotal
lines
s
of
e a file.
23. Determine(the
z c e n of lines contained in the /usr/dict/words file.

é li
ll$ewc -l /usr/dict/words
T
a Print the dante_1 file to the default printer.
24.
u i s
L $ lp dante_1
25. What action occurs when you enter the lp -m command for the default printer?
The lp -m command sends a mail message to you after the print job is complete.
26. What does the ~ symbol represent?
The ~ symbol represents the user’s home directory.

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Viewing Directories and Files


Chapter 4 - Page 6
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Practices for h a s
Lesson 5:
) e ฺ
Working
i l ฺ comwith
G
id and
uFiles
t m a ent
Directories
@ S tu5 d
hoChapter
- 9 0 this
t e l lez use
i s a- e to
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Working with Files and Directories


Chapter 5 - Page 1
Practices for Lesson 5: Overview

Practices Overview
In this practice, you use the commands described in the lesson to copy, move, rename, create,
and remove files and directories.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Working with Files and Directories


Chapter 5 - Page 2
Practice 5-1: Using Directory and File Commands

Overview
To use directory and file commands, complete the following steps. Write the commands that you
would use to perform each task in the space provided.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Preparation
No special preparation is required for this practice.

RLDC
In addition to being able to use local classroom equipment, this practice was designed to also
use equipment located in a remote lab data center. Directions for accessing and using this
resource can be found at:
http://remotelabs.sun.com/
a ble
Ask your instructor for the particular SSH configuration file that you should use to access the f e r
appropriate remote equipment for this practice.
ans
n - t r
a no
Tasks
h a s
1. Return to your home directory (if you need to), and list the )contents. eฺ
l ฺ comt Guid
_____________________________________________________________
i
2. Copy the dir1/coffees/beans/beanstfile
o mainto thededir4
n directory, and call it roses.
h S tu
_____________________________________________________________
@
3. Create a directory called vegetables- i s
90 inthdir3.
z
lle us e
a - e
_____________________________________________________________
t to
l u i s
4. Move the dir1/coffees/beans/beans
s e file into the dir2/recipes directory.
z ( ce n
_____________________________________________________________
5. T é l l
Complete
e l i
the missing option and description in the following table:
a
Luis
Option Description
CP -i
Includes the contents of a directory,
including the contents of all
subdirectories, when you copy a
directory
6. From your home directory, create a directory called practice1.
_____________________________________________________________
7. Using a single command, copy the file.1 and file.2 files to the practice1 directory.
_____________________________________________________________
8. Copy dir3/planets/mars file to the practice1 directory, and name the file
addresses.
_____________________________________________________________

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Working with Files and Directories


Chapter 5 - Page 3
9. Create a directory called play in your practice1 directory, and move the
practice1/addresses file to the play directory.
_____________________________________________________________
10. Using a single command with options, copy the play directory in the practice1 directory
to a new directory in the practice1 directory called appointments.
_____________________________________________________________
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

11. Recursively list the contents of the practice1 directory.


_____________________________________________________________
12. In your home directory, create a directory called house with a subdirectory of furniture
using a single command.
_____________________________________________________________
13. Create an empty file called chairs in the new furniture directory.
_____________________________________________________________
a b le
e r
14. Using one command, create three directories called records, memos, and misc in your
home directory. a n sf
_____________________________________________________________ n - tr
15. Create a new file called carrot, and then rename it celery. a no
h a s
_____________________________________________________________
m ) andidmisc
e ฺ
16. Using a single command, remove the directories called
l ฺ c o Gu
memos from your home
directory. i
a ent
t m
h o
S t ud
_____________________________________________________________
17. Try to remove the directory called
9 @ is
0house/furniture with the rm (no options) command.
- t h
What happens?
t e l lez use
_____________________________________________________________
i s a- to remove
e to a directory that is not empty. Remove the
18. Identify the command
z ns List the contents of the house directory to verify that the
(lu cedirectory.
house/furniture
élle directory
furniture li has been removed.
a T
Luis _____________________________________________________________
19. Create a new directory named newname, and then rename it veggies.
_____________________________________________________________
20. Create a file named mycontents that is a symbolic link to the
/var/sadm/install/contents file.
_____________________________________________________________
21. Verify that the symbolic link works.
_____________________________________________________________
22. Type q to quit the mycontents file view.
_____________________________________________________________
23. Remove the symbolic link that you created in Step 20.
_____________________________________________________________

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Working with Files and Directories


Chapter 5 - Page 4
Practice Summary
Discussion: Take a few minutes to discuss what experiences, issues, or discoveries you had
during the practice.
• Experiences
• Interpretations
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

• Conclusions
• Applications

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Working with Files and Directories


Chapter 5 - Page 5
Practice Solutions: Using Directory and File Commands

Tasks
To use directory and file commands, complete the following steps:
1. Return to your home directory (if you need to), and list the contents.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

$ cd; ls
2. Copy the dir1/coffees/beans/beans file into the dir4 directory, and call it roses.
$ cp dir1/coffees/beans/beans dir4/roses
3. Create a directory called vegetables in dir3.
$ mkdir dir3/vegetables
4. Move the dir1/coffees/beans/beans file into the dir2/recipes directory.
$ mv dir1/coffees/beans/beans dir2/recipes
5. Complete the missing option and description in the following table:
a ble
f e r
ans
Option Description
n - t r
CP -i Prevents you from accidentally a no
a s
overwriting existing files or directories
h
-r Includes the contentso ofm
) ideฺ
a directory,
i l ฺ
including the contents c of allt Gu
t mawhendyou
subdirectories,
o e ncopy a
h
directory
@ S tu
6. From your home directory, create- 90a directory
t s
hi called practice1.
z
lle us e
$ mkdir practice1
a - t e tothe file.1 and file.2 files to the practice1 directory.
s
7. Using a singleicommand, ecopy
$ z lu efile.2
cp (file.1
c ns practice1
8. Copy
li
élledir3/planets/mars file to the practice1 directory, and name the file
a T
uis
addresses.
L $ cp dir3/planets/mars practice1/addresses
9. Create a directory called play in your practice1 directory, and move the
practice1/addresses file to the play directory.
$ mkdir practice1/play
$ mv practice1/addresses practice1/play
10. Using a single command, copy the play directory in the practice1 directory to a new
directory in the practice1 directory called appointments.
$ cp -r practice1/play practice1/appointments
11. Recursively list the contents of the practice1 directory.
$ ls -R practice1

12. In your home directory, create a directory called house with a subdirectory of furniture
using a single command.
$ cd; mkdir -p house/furniture

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Working with Files and Directories


Chapter 5 - Page 6
13. Create an empty file called chairs in the new furniture directory.
$ touch house/furniture/chairs
14. Using one command, create three directories called records, memos, and misc in your
home directory.
$ mkdir records memos misc
15. Create a new file called carrot, and then rename it celery.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

$ touch carrot
$ mv carrot celery
16. Using a single command, remove the directories called memos and misc from your home
directory.
$ rmdir memos misc
or
$ rm -r memos misc
a ble
17. Try to remove the directory called house/furniture with the rm (no options) command.
f e r
What happens?
ans
$ rm house/furniture n - t r
o
rm: house/furniture is a directory
s an
ha eฺ
18. Identify the command to remove a directory that is not empty. Remove the
)
comt Guid
house/furniture directory. List the contents of the house directory to verify that the
furniture directory has been removed. i l ฺ
$ rm -r house/furniture
o t ma den
$ ls house @ h S tu
- 90 thi s
$
l z
le use
t e
19. Create a new directory named newname, and then rename it veggies.
a- e to
i s
(lu cens
$ mkdir newname
z li
$ mv newname veggies
élle
20. Create a file named mycontents that is a symbolic link to the file
T
a
Luis /var/sadm/install/contents.
$ ln -s /var/sadm/install/contents mycontents
21. Verify that the symbolic link works.
$ more mycontents
22. Type q to quit the mycontents file view.
23. Remove the symbolic link that you created in Step 20.
$ rm mycontents
$ ls mycontents
mycontents: No such file or directory

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Working with Files and Directories


Chapter 5 - Page 7
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Working with Files and Directories


Chapter 5 - Page 8
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Practices for h a s
Lesson 6: Using
) e ฺ
om Guid
the vilฺcEditor
i
a 6 ent
t m
@ ho Stud
Chapter

- 9 0 this
t e l lez use
i s a- e to
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Using the vi Editor


Chapter 6 - Page 1
Practices for Lesson 6: Overview

Practices Overview
In this practice, you perform vi editor commands in the tutor.vi tutorial.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Using the vi Editor


Chapter 6 - Page 2
Practice 6-1: Using the vi Editor

Overview
To learn how to use the vi editor, complete the following steps.

Preparation
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

No special preparation is required for this practice.

RLDC
In addition to being able to use local classroom equipment, this practice was designed to also
use equipment located in a remote lab data center. Directions for accessing and using this
resource can be found at:
http://remotelabs.sun.com/
Ask your instructor for the particular SSH configuration file that you should use to access the a ble
appropriate remote equipment for this practice. f e r
ans
n - t r
Tasks a no
1. Make sure that you are in your home directory. To open the h a s tutorial file,
) tutor.vi
e ฺ
comt Guid
enter the following command:
$ vi tutor.vi i l ฺ
2. Complete the lessons outlined in this tutorial.
o t ma den
@ h S tu
- 90 thi s
Practice Summary l z
le use
Discussion: Take asfew
t e
a- minutes ttoo discuss what experiences, issues, or discoveries you had
i
(lu cens
during the practice
e
e z
• llExperiences li
T é
i s a • Interpretations
Lu • Conclusions
• Applications

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Using the vi Editor


Chapter 6 - Page 3
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Using the vi Editor


Chapter 6 - Page 4
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Practices for h a s
Lesson 7: Using
) e ฺ
Commands
i l ฺ comt G uid the Shell
Within
o t ma 7 den
Chapter
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Using Commands Within the Shell


Chapter 7 - Page 1
Practices for Lesson 7: Overview

Practices Overview
In this practice, you will answer questions on the material presented in this module.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Using Commands Within the Shell


Chapter 7 - Page 2
Practice 7-1: Working in the Korn Shell

Overview
Complete the following steps. Write your answer in the space provided.

Preparation
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

No special preparation is required for this practice.

RLDC
In addition to being able to use local classroom equipment, this practice was designed to also
use equipment located in a remote lab data center. Directions for accessing and using this
resource can be found at:
http://remotelabs.sun.com/
Ask your instructor for the particular SSH configuration file that you should use to access the
a ble
appropriate remote equipment for this practice. f e r
ans
n - t r
Tasks
a no
a
1. Which specific shell characters have special meaning to the shell?
h s
m ) ideฺ
_____________________________________________________________
2. Name some common shell metacharacters. i l ฺ co t Gu
t ma den
_____________________________________________________________
o u directory of a user?
h for theSthome
@
3. Which metacharacter is a shell substitute
90 thi s
z -
_____________________________________________________________
4. Navigate to your homet e l le ufrom
directory seyour current working directory by using the
i s a-metacharacter.
appropriate special e to
5. Which twoz lu ens are often referred to as wildcard characters?
(metacharacters
é l le lic
_____________________________________________________________
a TMake sure that you are in your home directory. List the contents of all the files and
s6.
ui directories in your home directory starting with d, using a wildcard entry.
L
_____________________________________________________________
7. Which character do you use to match a single character, excluding a leading period?
_____________________________________________________________
8. Which character or characters would you use to match a set or range of characters?
_____________________________________________________________
9. Which character or characters would you use to have the shell ignore the special meaning
of metacharacters?
_____________________________________________________________
10. What are file descriptors?
_____________________________________________________________
_____________________________________________________________
11. Which symbol or symbols do you use to redirect output and append the output to a file?
_____________________________________________________________

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Using Commands Within the Shell


Chapter 7 - Page 3
12. Which command redirects standard error messages?
_____________________________________________________________
13. Which symbol or character do you use to connect two or more commands on a single
command line?
_____________________________________________________________
14. Define a variable. Name the kinds of variables used in Korn shell programming.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

_____________________________________________________________
_____________________________________________________________
15. Which command do you use to display shell variables and their current values?
_____________________________________________________________
16. Which command do you use to display a list of previously executed commands in the shell?
_____________________________________________________________
17. What is an initialization file?
a ble
_____________________________________________________________
f e r
_____________________________________________________________ ans
18. List the four user initialization files described in this module. n - t r
_____________________________________________________________ a no
h a
_____________________________________________________________
s
m ) ideฺ
i l ฺ co t Gu
_____________________________________________________________

your path o t ma den


19. Edit your ~/.profile file to set the ENV variable to $HOME/.kshrc. Also add /etc to

@ h S tu
- 90 thi s
20. Edit your ~/.kshrc file to set the prompt to be hostname and the current directory.
z
le use
21. Log out and log in again to check that your settings work.
l
t e
a- e to
Practice Summary i s
Discussion: z (lu a few
Take
c e ns to discuss what experiences, issues, or discoveries you had
minutes
llepractice. li
duringéthe
T
a • Experiences
Luis • Interpretations
• Conclusions
• Applications

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Using Commands Within the Shell


Chapter 7 - Page 4
Practice Solutions: Working in the Korn Shell

Tasks
1. Which specific shell characters have special meaning to the shell?
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Metacharacters
2. Name some common shell metacharacters.
Metacharacters include the following: ~, -, +, *, ?, and [].
3. Which metacharacter is a shell substitute for the home directory of a user?
The ~ character
4. Navigate to your home directory from your current working directory by using the
appropriate special metacharacter.
$ cd
a ble
$ pwd f e r
ans
$ /export/home/student
n - t r
5. Which two metacharacters are often referred to as wildcard characters? o
The * and ? characters
s an
ha eฺ
6. Make sure that you are in your home directory. List the contents of all the directories in your
)
i l ฺ comt Guid
home directory starting with d, using a wildcard entry.

ma den
$ pwd
o t
/export/home/student
@ h S tu
$ ls d*
- 90 thi s
dante dante_1
l z
le use
dir1: t e
a- e to
i s
(lu cens
coffees fruit trees
z
élle
dir2: li
a T beans notes recipes

Luis dir3:
planets vegetables
dir4:
roses
dir5:
7. Which character do you use to match a single character, excluding a leading period?
The ? character
8. Which character or characters would you use to match a set or range of characters?
The [] character
9. Which character or characters would you use to have the shell ignore the special meaning
of metacharacters?
The \, ‘, and “ characters
10. What are file descriptors?
File descriptors determine where the input to the command originates and where the output
or error messages are sent.

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Using Commands Within the Shell


Chapter 7 - Page 5
11. Which symbol or symbols do you use to redirect output and append the output to a file?
The >> character
12. Which command redirects standard error messages?
$ command 2> filename
13. Which symbol or character do you use to connect two or more commands on a single
command line?
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

The | character
14. Define a variable. Name the kinds of variables used in Korn shell programming.
A variable refers to a temporary storage area in memory.
Korn shell programming uses two types of variables:
• Variables that are exported to subprocesses
• Variables that are not exported to subprocesses
15. Which command do you use to display shell variables and their current values?
a ble
The set command f e r
ans
16. Which command do you use to display a list of previously executed commands in the shell?
n - t r
The history command o
17. What is an initialization file? s an
) ha eฺ
An initialization file is the file that you use to control the features of your desktop
environment.
i l ฺ comt Guid
o t ma den
18. List the four user initialization files described in this module.
The user initialization files are:
@ h S tu
~/.profile
- 90 thi s
~/.kshrc
l z
le use
~/.cshrc t e
a- e to
i s
(lu cens
~/.dtprofile
z
élle li
19. Edit your ~/.profile file to set the ENV variable to $HOME/.kshrc. Also add /etc to
a T
your path.

Luis Use the following commands:


ENV=$HOME/.kshrc
PATH=$PATH:/etc
export ENV PATH
20. Edit your ~/.kshrc file to set the prompt to be hostname and the current directory.
Use the following commands:
PS1=”‘hostname‘: \$PWD $ ”
export PS1
21. Log out and log in again to check that your settings work.
Use the following commands:
sys-03:/export/home/user $
sys-03:/export/home/user $ echo $PATH
/usr/bin:/usr/dt/bin:/usr/openwin/bin:/bin:/etc

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Using Commands Within the Shell


Chapter 7 - Page 6
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Practices for h a s
Lesson 8: Using
) e ฺ
Basic l ฺ om Permissions
cFile G uid
i
a 8 ent
t m
@ ho Stud
Chapter

- 9 0 this
t e l lez use
i s a- e to
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using Basic File Permissions


Chapter 8 - Page 1
Practices for Lesson 8: Overview

Practices Overview
In this practice, you read permissions on files and use the symbolic mode and the octal mode to
change permissions.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using Basic File Permissions


Chapter 8 - Page 2
Practice 8-1: Changing File Permissions

Overview
To view permissions on files and change permissions, complete the following steps:

Preparation
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Ensure that the umask value is set to 022 on your system. If not, set the umask value to 022 by
running the following command:
$ umask 022

RLDC
In addition to being able to use local classroom equipment, this practice was designed to also
use equipment located in a remote lab data center. Directions for accessing and using this
resource can be found at:
a ble
http://remotelabs.sun.com/ f e r
Ask your instructor for the particular SSH configuration file that you should use to access the ans
appropriate remote equipment for this practice. n - t r
a no
h a s
Tasks
m ) ideฺ
1. Perform the following commands in your home directory:i l ฺ co t Gu
$ mkdir perm
o t ma den
$ cd /etc
@ h S tu
$ ls -l group motd-9 0 tvfstabhi s
z shadow
e
lleshadowusvfstab ~/perm
$ cp group motd
- t e
a shadow tofile, the error message cp: cannot open shadow:
When trying to copy
i sthe e
lu eappears.
Permission (denied
z c ns Why?
lle li
_____________________________________________________________
é
T
a _____________________________________________________________
Luis $ ls -l ~/perm
$ cd
$ cp -r /etc/skel perm
2. Change to the perm directory, and list the contents of the directory.
$ cd perm
$ ls -l

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using Basic File Permissions


Chapter 8 - Page 3
In the following table, fill in the permission sets for each file and write the three digit octal
number that represents the combined set of permissions.

File or Permissions Octal Value


Directory
Owner Group Other
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

group
motd
skel
vfstab

3. Create a new file and a new directory.


a. What are the default permissions given to the new file? a ble
f e r
________________________________________________________
ans
b. What are the default permissions given to the new directory?
n - t r
o
s an
________________________________________________________
4. Describe the difference between the symbolic mode and the octal mode.
) ha eฺ
_____________________________________________________________
l ฺ comt Guid
_____________________________________________________________
i
t ma den
5. Using the symbolic mode, add write permission for the group to the motd file.
o
h S tu
_____________________________________________________________
@
- 90 thi s
6. Using the octal mode, change the permissions on the motd file to -rwxrw----.
l z
le use
t e
_____________________________________________________________
a- e to
i s
7. Using the octal mode, add write permission for other on the file named group.
z (lu cens
_____________________________________________________________
élle li
8. Identify the GID and UID for the motd file. Which command did you use?
a T
Luis _____________________________________________________________
_____________________________________________________________
9. Create a new file called memo in your dir4 directory.
_____________________________________________________________
10. Remove the read permission for the owner from the memo file in the dir4 directory. Use
either the symbolic mode or the octal mode.
_____________________________________________________________
a. What happens when you try to use the cat command to view the memo file?
________________________________________________________
b. What happens when you try to copy the memo file?
________________________________________________________
________________________________________________________
11. What is the function of the umask utility? What is the default umask that exists on your
system?
_____________________________________________________________

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using Basic File Permissions


Chapter 8 - Page 4
12. Change the umask to 027. Which command did you run?
_____________________________________________________________
13. Create a new file and a new directory. Record the access permissions. Which command did
you run?
_____________________________________________________________
_____________________________________________________________
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

14. Change the umask back to 022.


15. Create a new file and a new directory.
$ touch test2file
$ mkdir test2dir
16. Record the access permissions.
$ ls -l test2file
$ ls -ld test2dir
a ble
f e r
Practice Summary
a n s
r
-t you had
Discussion: Take a few minutes to discuss what experiences, issues, or discoveries
n
o
during the practice.
• Experiences s an
• Interpretations ) ha eฺ
• Conclusions i l ฺ comt Guid
• Applications
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using Basic File Permissions


Chapter 8 - Page 5
Practice Solutions: Changing File Permissions

Overview
To view permissions on files and change permissions, complete the following steps:

Tasks
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

1. Perform the following commands in your home directory:


$ mkdir perm
$ cd /etc
$ ls -l group motd shadow vfstab
-rw-r--r-- 1 root sys 290 Jun 5 09:40 group
-rw-r--r-- 1 root sys 49 Apr 6 2002 motd
-r-------- 1 root sys 795 Jun 28 15:25 shadow
a ble
-rw-r--r-- 1 root sys 257 Jun 5 10:01 vfstab
f e r
$ cp group motd shadow vfstab ~/perm
ans
When trying to copy the shadow file, the error message cp: cannot open shadow: n - t r
o
Permission denied appears. Why?
s an
ha eฺ
Only the owner of this file, who is the root user, has read permission.
)
comt Guid
$ ls -l ~/perm
i l ฺ
-rw-r--r-- 1 root sys 290 Jun 5 09:40 group
t ma den
-rw-r--r-- 1 root sys 49 Apr 6 2002 motd
o
@ h S tu
-rw-r--r-- 1 root sys 257 Jun 5 10:01 vfstab
$ cd - 90 thi s
l z
le use
t e
$ cp -r /etc/skel perm
a- e to
s
2. Change to the perm directory, and list the contents of the directory.
i
z (lu cens
$ cd perm
élle
$ ls -l li
a T
uis
-rw-r--r-- 1 student class 290 Jul 29 14:34 group
L -rw-r--r-- 1 student class 49 Jul 29 14:34 motd
drwxr-xr-x 2 student class 512 Jul 29 14:34 skel
-rw-r--r-- 1 student class 420 Jul 29 14:34 vfstab

In the following table, fill in the permission sets for each file and write the three digit octal
number that represents the combined set of permissions.
File or Permissions Octal Value
Directory
Owner Group Other
group rw- r-- r-- 644
motd rw- r-- r-- 644
skel rw- r-x r-x 755
vfstab rw- r-- r-- 644

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using Basic File Permissions


Chapter 8 - Page 6
3. Create a new file and a new directory.
a. What are the default permissions given to the new file?
rw-r--r--
b. What are the default permissions given to the new directory?
rwxr-xr-x
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

4. Describe the difference between the symbolic mode and the octal mode.
The symbolic mode uses combinations of letters and symbols to add or remove
permissions for each type of user.
The octal mode uses octal numbers to represent each permission. The octal mode is also
referred to as the absolute mode.
5. Using the symbolic mode, add write permission for the group to the motd file.
$ chmod g+w motd
$ ls -l
a ble
6. Using the octal mode, change the permissions on the motd file to -rwxrw----.
f e r
$ chmod 760 motd
ans
$ ls -l n - t r
7. a no
Using the octal mode, add write permission for other on the file named group.
h a s
$ chmod 646 group
m ) ideฺ
$ ls –ldi
i l ฺ co t Gu
ma den
8. Identify the GID and UID for the motd file. Which command did you use?
o t
$ ls -n motd
@ h S tu
90 thi
-rwxrw---- 1 11001 10 49 Nov 19 15:16 motd
- s
9. z
le use
Create a new file called memo in your dir4 directory.
l
a - t
$ touch ~/dir4/memoe to
i s e
10. Remove thelu
z (symbolic
c e ns or theforoctal
read permission the owner from the memo file in the dir4 directory. Use
eitherethe
é l li ~/dir4/memo mode.
l$ chmod u-r mode

a T
ui s or
L $ chmod 244 ~/dir4/memo
a. What happens when you try to use the cat command to view the memo file?
You cannot use the cat command, because read permission has been removed for the
user. Even though you are part of the group, the permissions are viewed in the order in
which they appear. The following message appears:
cat: cannot open /export/home/student/dir4/memo
b. What happens when you try to copy the memo file?
You cannot copy the file, because the user has no read permission. The following message
appears:
cp: cannot open /export/home/student/dir4/memo: Permission
denied

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using Basic File Permissions


Chapter 8 - Page 7
11. What is the function of the umask utility? What is the default umask that exists on your
system?
The umask utility modifies the default permissions set for files and directories at the time of
creation. To view the default umask value on your system, run the umask command.
$ umask
022
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

$
12. Change the umask to 027. Which command did you run?
$ umask 027
13. Create a new file and a new directory. Record the access permissions. Which command did
you run?
$ touch testfile
$ mkdir testdir
a ble
$ ls -l testfile
f e r
-rw-r-----
ans
$ ls -ld testdir
n - t r
o
an
drwxr-x---
14. Change the umask back to 022. s
ha eฺ
)
comt Guid
$ umask 022
15. Create a new file and a new directory.
i l ฺ
$ touch test2file
o t ma den
$ mkdir test2dir
@ h S tu
-
16. Record the access permissions.90 thi s
l z
le use
t e
$ ls -l test2file
a- e to
i
-rw-r--r--s
z (lu cens
$ ls -ld test2dir
élle
drwxr-xr-xli
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using Basic File Permissions


Chapter 8 - Page 8
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Practices for h a s
Lesson 9:
) e ฺ
Configuring
i l ฺ comt GAccess
uid Control
o t ma (ACLs)
Lists d e n
@ h Chapter
S tu9
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Configuring Access Control Lists (ACLs)


Chapter 9 - Page 1
Practices for Lesson 9: Overview

Practices Overview
In this practice, you create three files and modify the ACLs associated with them.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Configuring Access Control Lists (ACLs)


Chapter 9 - Page 2
Practice 9-1: Using Access Control Lists

Overview
Complete the following steps.

Preparation
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

A user called acluser with a password of acluser1 and a group called aclgroup is required
for this practice. This user and group were created for you.

RLDC
In addition to being able to use local classroom equipment, this practice was designed to also
use equipment located in a remote lab data center. Directions for accessing and using this
resource can be found at:
http://remotelabs.sun.com/
a ble
Ask your instructor for the particular SSH configuration file that you should use to access the f e r
appropriate remote equipment for this practice. ans
n - t r
a no
Tasks
h a s
1. Log in and open a terminal window. m ) ideฺ
i l ฺ co t Gu
_____________________________________________________________
2. Create the directory named $HOME/acl_test,
o t maanddchange
e n directories to that location.
@ h S tu
_____________________________________________________________
3. Use the echo command toz - 90 file1,
create t s
i add the text string Success for life to
hand
the file. e lle us e
a - t to
i s
_____________________________________________________________
e
u forethensfile named file1.
4. Displayzthe(lACL
é l le lic
_____________________________________________________________
a TDo the permissions in the ACL match the permissions indicated by the ls command?
ui s
L _____________________________________________________________
5. Change permissions on the file named file1 so that only the owner and group have read
access.
_____________________________________________________________
6. Change your user identity to acluser.
_____________________________________________________________
7. Display the contents of the file1 file. What is the output?
_____________________________________________________________
8. Exit your su session.
_____________________________________________________________
9. Use the setfacl command to add an ACL entry that allows read access for acluser to
the ACL for the file1 file.
_____________________________________________________________
10. Verify that the new ACL entry exists.
_____________________________________________________________
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Configuring Access Control Lists (ACLs)


Chapter 9 - Page 3
11. Change your user identity back to acluser.
_____________________________________________________________
12. Use the ls command to display the permissions applied to the file1 file. According to
these permissions, does acluser have read access?
_____________________________________________________________
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

What indicates that an additional ACL entry exists for the file1 file?
_____________________________________________________________
13. Change to the acl_test directory and attempt to display the contents of the file1 file.
_____________________________________________________________
What is the result?
_____________________________________________________________
14. Exit your su session.
_____________________________________________________________
a ble
f e r
15. Create and display the ACL for the file2 file.
ans
_____________________________________________________________
n - t r
o
an
Do the group permissions match the permissions associated with the mask entry?
s
_____________________________________________________________
ha eฺ
)
16. Change the permission mode to grant read, write, and execute permissions to the group
that owns the file2 file.
i l ฺ comt Guid
o t ma den
_____________________________________________________________
h tu
17. Display the ACL and a long listing for the file2 file.
@ S
90 thi s
_____________________________________________________________
-
l z
le use
Do the mask permissions match the group permissions?
t e
a- e to
_____________________________________________________________
i s
(lu cens
18. Set the mask permissions for the file named file2 to read-only.
z
élle li
_____________________________________________________________
a T
uis
19. Display the ACL and a long listing for file2.
L _____________________________________________________________
Do the mask permissions match the group permissions?
_____________________________________________________________
In the long listing output, do you find an indication that file2 has additional ACL entries?
_____________________________________________________________
20. Add an ACL entry for the group named aclgroup to the file2 file. Grant only read and
write permissions for this group.
_____________________________________________________________
21. Change your user identity to acluser, thereby inheriting the users environment.
_____________________________________________________________
22. Use the echo command to insert the text string Success for life into the file2 file.
_____________________________________________________________
What is the output?
_____________________________________________________________
23. Exit your su session.
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Configuring Access Control Lists (ACLs)


Chapter 9 - Page 4
24. Display the ACL for the file2 file.
_____________________________________________________________
25. Create a file called file3 and add an ACL entry to the file that recalculates the mask
allowing a user from the aclgroup group to insert a line of text to the file.
_____________________________________________________________
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

26. Change your user identity to acluser, inheriting the users environment.
_____________________________________________________________
27. Use the echo command to insert the text string Success for life in the file3 file.
_____________________________________________________________
28. Display the contents of the file3 file.
_____________________________________________________________
29. Exit your su session.
_____________________________________________________________ a ble
f e r
Practice Summary ans
n - t r
Discussion: Take a few minutes to discuss what experiences, issues, or discoveries you had o
during the practice.
s an
• Experiences
) ha eฺ
• Interpretations
i l ฺ comt Guid
• Conclusions
o t ma den
• Applications
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Configuring Access Control Lists (ACLs)


Chapter 9 - Page 5
Practice Solutions: Using Access Control Lists

Overview
Complete the following steps:
1. Log in and open a terminal window.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

2. Create the directory named $HOME/acl_test, and change directories to that location.
$ mkdir $HOME/acl_test
$ cd $HOME/acl_test
3. Use the echo command to create the file1 file, and add the text string Success for
life to the file.
$ echo “Success for Life” > file1
$ ls -l
-rw-r--r-- 1 student class 17 Feb 9 09:40 file1
a ble
4. Display the ACL for the file1 file. f e r
ans
$ getfacl file1
n - t r
Do the permissions in the ACL match the permissions indicated by the ls command? o
Yes, they should. s an
) ha eฺ
5. Change permissions on the file1 file so that only the owner and the group have read
access.
i l ฺ comt Guid
$ chmod 440 file1
o t ma den
$ ls -l
@ h S tu
90 thi s
-r--r----- 1 student class 17 Sep 25 13:06 file1
-
$ getfacl file1
l z
le use
t e
a- e to
6. Change your user identity to acluser.
i s
(lu cens
$ su - acluser
z
élle li
passwd:acluser1
T
7. Display the contents of the file1 file. What is the output?
a
Luis $ cat ~student/acl_test/file1
The following error message is displayed:
cat: cannot open /export/home/student/acl_test/file1
8. Exit your su session.
$ exit
9. Use the setfacl command to add an ACL entry that allows read access for acluser to
the ACL for the file1 file.
$ setfacl -m user:acluser:4 file1
10. Verify that the new ACL entry exists.
$ getfacl file1
11. Change your user identity back to acluser.
$ su - acluser
passwd:acluser1
12. Use the ls command to display the permissions applied to the file1 file.
$ ls -l ~student/acl_test/file1
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Configuring Access Control Lists (ACLs)


Chapter 9 - Page 6
According to these permissions, does acluser have read access?
No.
What indicates that an additional ACL entry exists for the file1 file?
The + symbol at the end of the permissions string
13. Change to the acl_test directory and attempt to display the contents of the file1 file.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

$ cd ~student/acl_test
$ cat file1
What is the result?
The file content appears.
14. Exit your su session.
$ exit
$
15. Create and display the ACL for the file2 file. a ble
f e r
$ touch file2
ans
$ getfacl file2
n - t r
o
an
Do the group permissions match the permissions associated with the mask entry?
Yes. s
ha eฺ
16. )
Change the permission mode to grant read, write, and execute permissions to the group
that owns the file2 file.
i l ฺ comt Guid
$ chmod g=rwx file2
o t ma den
17. h tu
Display the ACL and a long listing for the file2 file.
@ S
$ getfacl file2
- 90 thi s
$ ls -l file2 l z
le use
t e
a- e to
Do the mask permissions match the group permissions?
i s
Yes.
z (lu cens
18. élle li
Set the mask permissions for the file2 file to read-only.
a T
uis
$ setfacl -m mask:r-- file2
L 19. Display the ACL and a long listing for the file2 file.
$ getfacl file2
$ ls -l file2
Do the mask permissions match the group permissions?
Yes.
In the long listing output, do you find an indication that the file2 file has additional ACL
entries?
No.
20. Add an ACL entry for the group named aclgroup to the file2 file. Grant only read and
write permissions for this group.
$ setfacl -m group:aclgroup:6 file2
21. Change your user identity to acluser, thereby inheriting the users environment.
$ su - acluser
password: acluser1

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Configuring Access Control Lists (ACLs)


Chapter 9 - Page 7
22. Use the echo command to insert the text string Success for life into the file2 file.
$ echo “Success for Life” > ~student/acl_test/file2
What is the output?
ksh: /export/home/student/acl_test/file2 cannot create
23. Exit your su session.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

$ exit
24. Display the ACL for the file2 file.
$ getfacl file2
25. Create a file called file3 and add an ACL entry to the file that recalculates the mask
allowing a user from the aclgroup group to insert a line of text to the file.
$ touch file3
$ setfacl -r -m g:aclgroup:6 file3
26. Change your user identity to acluser, inheriting the users environment.
a ble
f e r
$ su - acluser
ans
password: acluser1
n - t r
27. Use the echo command to insert into the text string Success for life in the file3 file. o
$ echo “Success for Life” > ~student/acl_test/file3s an
28. Display the contents of the file3 file. ) ha eฺ
$ cat ~student/acl_test/file3
i l ฺ comt Guid
29. Exit your su session.
o t ma den
$ exit
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Configuring Access Control Lists (ACLs)


Chapter 9 - Page 8
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Practices for h a s
Lesson 10:
) e ฺ
Searching
i l ฺ comtFiles
G uidand
o t ma den
Directories
@ h Chapter
S tu10
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10: Searching Files and Directories


Chapter 10 - Page 1
Practices for Lesson 10: Overview

Practices Overview
In this practice, you search for files and directories by using the find command. You also
display and manipulate text in files.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10: Searching Files and Directories


Chapter 10 - Page 2
Practice 10-1: Locating Files and Text

Overview
You practice searching for files and directories by using the find command. You also display
and manipulate text in files.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Preparation
No special preparation is required for this practice.

RLDC
In addition to being able to use local classroom equipment, this practice was designed to also
use equipment located in a remote lab data center. Directions for accessing and using this
resource can be found at:
http://remotelabs.sun.com/
a ble
Ask your instructor for the particular SSH configuration file that you should use to access the f e r
appropriate remote equipment for this practice. ans
n - t r
a no
Tasks
h a s
1. How do the grep, egrep, and fgrep commands differ? m ) ideฺ
i
_____________________________________________________________l ฺ co t Gu
t ma den
_____________________________________________________________
o
h S tu
_____________________________________________________________
@
2. Search for the text string other - t s
90in the /etc/group
hi file. Display it to the screen.
l e z e
a - tel to us
_____________________________________________________________
3. Using the grep
( l u iscommand,n s e look for all lines in the file4 file located in your home directory
that do z not contain e the letter M.
l l e l i c
é
_____________________________________________________________
T
a
Luis4. Display all lines in the files dante, file1, and dante_1 that contain the pattern he.
_____________________________________________________________
5. Display all the lines in the file file4 that contain either the pattern Sales or the pattern
Finance.
_____________________________________________________________
6. Which option is peculiar to the grep command but does not apply to the egrep and fgrep
commands?
_____________________________________________________________
7. Display all the lines that have the pattern load in the /etc/system file.
_____________________________________________________________
8. Use the grep command to display how many lines contain at least one instance of the
word module (uppercase and lowercase) in the /etc/system file.
_____________________________________________________________
9. Use the grep command to record how many instances of the word Module (uppercase M
only) appear in the /etc/system file.
_____________________________________________________________
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10: Searching Files and Directories


Chapter 10 - Page 3
10. Starting in your home directory, find all files that were modified in the last one day.
_____________________________________________________________
11. Use the find command to search the /etc directory for all the files owned by the user lp.
_____________________________________________________________
12. Starting in your home directory, find all files of type f for file.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

_____________________________________________________________
13. In your home directory, find all files of type d for directory.
_____________________________________________________________
14. From your home directory, use the find command with an option that prompts you before
removing any files, to search for ordinary files of size 0 (zero) in the /tmp directory.
_____________________________________________________________
Note: Make sure that you answer No when prompted to remove any files.
a ble
Practice Summary f e r
Discussion: Take a few minutes to discuss what experiences, issues, or discoveries you had ans
during the practice. n - t r
o
• Experiences
s an
• Interpretations
) ha eฺ
• Conclusions
i l ฺ comt Guid
• Applications
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10: Searching Files and Directories


Chapter 10 - Page 4
Practice Solutions: Locating Files and Text

Overview
To locate files and text, complete the following steps:

Tasks
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

1. How do the grep, egrep, and fgrep commands differ?


The grep command searches the contents of one or more files for a character pattern.
The egrep command searches the contents of one or more files for one or more patterns
using extended regular expression metacharacters.
The fgrep command searches a file for a literal string or a group of characters.
2. Search for the text string other in the /etc/group file. Display it to the screen.
$ grep other /etc/group
a ble
3. Using the grep command, look for all lines in the file4 file located in your home directory
f e r
that do not contain the letter M.
ans
$ cd n - t r
$ grep -v M file4 a no
4. h a s
Display all lines in the files dante, file1, and dante_1 that contain the pattern he.
m ) ideฺ
$ grep he dante file1 dante_1
i l ฺ co t Gu
ma den
5. Display all the lines in the file file4 that contain either the pattern Sales or the pattern
o t
Finance.
@ h S tu
- 0 command
$ egrep ’(Sales|Finance)’ file4
9grep t s
hi but does not apply to the egrep and fgrep
6. Which option is peculiar to z the
e lle us e
commands?
- t o
The -w optionis isapeculiareto tthe grep command alone.
(lu cethat
7. Displayzall the lines
nshave the pattern load in the /etc/system file.
éll$egrep load li /etc/system
a T
Luis8. Use the grep command to display how many lines contain at least one instance of the
word module (uppercase and lowercase) in the /etc/system file.
$ grep -ic module /etc/system
9. Use the grep command to record how many instances of the word Module (uppercase M
only) in the /etc/system file.
$ grep -c Module /etc/system
10. Starting in your home directory, find all files that were modified in the last one day.
$ find /export/home/student -mtime -1
11. Use the find command to search the /etc directory for all the files owned by the user
lp.
$ find /etc -user lp
12. Starting in your home directory, find all files of type f for file.
$ find ~ -type f
13. In your home directory, find all files of type d for directory.
$ find ~ -type d

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10: Searching Files and Directories


Chapter 10 - Page 5
14. From your home directory, use the find command with an option that prompts you before
removing any files, to search for ordinary files of size 0 (zero) in the /tmp directory.
$ find /tmp -type f -size 0 -ok rm {} \;
Note: Make sure that you answer No when prompted to remove any files.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10: Searching Files and Directories


Chapter 10 - Page 6
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Practices for h a s
Lesson 11:
) e ฺ
Performing
i l ฺ comt G uid Process
Basic
o t ma den
Control
@ h Chapter
S tu11
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Basic Process Control


Chapter 11 - Page 1
Practices for Lesson 11: Overview

Practices Overview
In this practice, you use the commands described in this module to determine PIDs, view a
process tree, and kill processes.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

This practice introduces the tty command, which displays the name of the current terminal
window. The name displayed by the tty command includes a unique identification number
assigned by the Solaris OS to each open terminal window (for example, /dev/pts/2). In the
tasks illustrating the tty command, the unique identification number is displayed as
/dev/pts/n, where n is a numeral

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Basic Process Control


Chapter 11 - Page 2
Practice 11-1: Manipulating System Processes

Overview
Complete the following steps.

Preparation
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

No special preparation is required for this practice.

RLDC
In addition to being able to use local classroom equipment, this practice was designed to also
use equipment located in a remote lab data center. Directions for accessing and using this
resource can be found at:
http://remotelabs.sun.com/
Ask your instructor for the particular SSH configuration file that you should use to access the
a ble
appropriate remote equipment for this practice. f e r
ans
n - t r
Tasks
a no
Perform the following:
h a s
m ) running
1. Use the following ps commands to list the processes currently d e ฺon your system.
What information does each command provide? ilฺc
o Gu i
t m a ent
ho Stud
$ ps
_____________________________________________________________
9 @
0 this
-
lez use
$ ps -f
e l
_____________________________________________________________
- t
$ ps -e isa e to
(lu cens
_____________________________________________________________
z
T éll$eps -ef li
a
Luis _____________________________________________________________
2. Perform the ps -ef command in a terminal window. Identify the process ID related to the
ps -ef command.
$ ps -ef
PID: _____________________________________
3. Open another terminal window, referred to as terminal window 1, and enter the following
command:
$ gcalctool
Note: This command launches the calculator, which is terminated by using the kill
command from another terminal window in a subsequent task.
4. Open another terminal window, called terminal window 2. Use the ps or pgrep command
to identify the PID of the gcalctool command.
PID: _____________________________________
5. In terminal window 2, terminate the gcalctool command by using the PID.
_____________________________________________________________

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Basic Process Control


Chapter 11 - Page 3
6. In terminal window 2, use the tty command to identify the name of this terminal window.
The name appears as /dev/pts/n, where n is a numeral (for example, /dev/pts/4).
$ tty
/dev/pts/___________________________________________________
7. Move back to terminal window 1. Use the pgrep command to find the PID associated with
the name of terminal window 2.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

$ pgrep -t pts/n
PID: _____________________________________
8. In terminal window 1, use the kill command to terminate the terminal window 2.
$ kill PID
Did it work? ______________________________________
9. Use the kill command with the -9 option to terminate terminal window 2.
$ kill -9 PID
a ble
Did it work? ______________________________________ f e r
ans
10. Name the commands used to search for a specific process.
n - t r
_____________________________________________________________
_____________________________________________________________ a no
h a s
) ideฺ
11. Run the following kill commands to identify the signal names associated with signal
m
numbers.
i l ฺ co t Gu
ma den
$ kill -l 9 (-l is the letter l)
o t
Signal: ___________________________________________
@ h S tu
$ kill -l 15 (-l is the
- 90 thi
letter l) s
z
le use
Signal: __________________________________________
l
t e
a- between
12. What is the difference to a process and a job?
i s e
(lu cens
_____________________________________________________________
z
lle li
_____________________________________________________________
é
T
13. What is the difference between the pkill command and the kill command?
a _____________________________________________________________
u i s
L _____________________________________________________________
14. In a terminal window type the command sleep 500 &.
15. In the same terminal window use the ps command to identify the shell process running in
that window.
_____________________________________________________________
16. In another terminal window use the ptree command using the shell PID from Step 14 as
the argument.
_____________________________________________________________
17. In this terminal window use the kill command with the PID as the argument that was
used in Step 15. Does the window close?
_____________________________________________________________

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Basic Process Control


Chapter 11 - Page 4
Practice Summary
Discussion: Take a few minutes to discuss what experiences, issues, or discoveries you had
during the practice.
• Experiences
• Interpretations
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

• Conclusions
• Applications

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Basic Process Control


Chapter 11 - Page 5
Practice Solutions: Manipulating System Processes

Overview
Perform the following steps:

Tasks
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Perform the following steps:


1. Use the following ps commands to list the processes currently running on your system.
What information does each command provide?
$ ps
This command prints information for the current user and terminal.
$ ps -f
This command prints a full listing of the ps command.
a ble
$ ps -e
f e r
This command prints information about every process running.
ans
$ ps -ef
n - t r
This command prints a full listing of the ps -e command.
a no
2. Perform the ps -ef command in a terminal window. Identify the
h a sprocess ID related to the
ps -ef command.
m ) ideฺ
The PID differs from system to system. i l ฺ co t Gu
3. Open another terminal window, referred totas
a ewindow
mterminal n 1, and enter the following
command: h o tu d
@ s S
$ gcalctool
z - 90 thi
Note: This command launches
e l le the u e
scalculator, which is terminated by using the kill
a
command from another - t t o
terminal window in a subsequent task.
i s s e
4. Open another
z (lu terminal
c e nwindow, called terminal window 2. Use the ps or pgrep command

éll$eps the
to identify li of the gcalctool command.
PID
a T -ef | grep gcalctool
u i s or
L $ pgrep gcalctool
5. In terminal window 2, terminate the gcalctool command by using the PID.
$ kill PID
The value PID is the PID of the gcalctool command.
6. In terminal window 2, enter the tty command to identify the name of this terminal window.
The name appears as /dev/pts/n, where n is a numeral (for example, /dev/pts/4).
$ tty
This name differs from system to system.
7. Move back to terminal window 1. Use the pgrep command to find the PID associated with
the name of terminal window 2.
$ pgrep -t pts/n
The PID differs from system to system.

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Basic Process Control


Chapter 11 - Page 6
8. In terminal window 1, use the kill command to terminate terminal window 2.
$ kill PID
Did it work?
No.
9. Use the kill command with the -9 option to terminate terminal window 2.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

$ kill -9 PID
Did it work?
Yes.
10. Name the commands used to search for a specific process.
The pgrep command and the ps command with the grep command.
11. Run the following kill commands to identify the signal names associated with signal
numbers.
$ kill -l 9
a ble
The signal name is KILL. f e r
ans
$ kill -l 15
n - t r
The signal name is TERM.
a no
12. What is the difference between a process and a job?
h a s
Every program that runs on the Solaris 10 OS creates a process.
m e ฺ that a shell can
) iAdprocess
manage is called a job.
i l ฺ co t Gu
13. What is the difference between the pkill command
t m a and e nthe kill command?
You can terminate a job using the kill o
h command. d
tuYou can terminate a specific process
@ s S
using the pkill command.
z - 90 thsleep
i
14. In a terminal window type
e l le us
the e
command 500 &.
$ sleep 500 t
a- & e to
i s
(lu cens
[1] 15866
z
é ll$e li
15. T
a Inthatthewindow.
same terminal window use the ps command to identify the shell process running in
u i s
L $ ps
PID TTY TIME CMD
3989 pts/3 0:00 ksh
4029 pts/3 0:00 ps
4028 pts/3 0:00 sleep
16. In another terminal window use the ptree command using the shell PID from Step 14 as
the argument.
$ ptree 3989
3985 gnome-terminal
3989 ksh
4028 sleep 500
17. In this terminal window use the kill command with the PID as the argument that was
used in Step 15. Does the window close?
$ kill -9 3989

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Basic Process Control


Chapter 11 - Page 7
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Basic Process Control


Chapter 11 - Page 8
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Practices for h a s
Lesson 12:
) e ฺ
Advanced
i l ฺ comtShell
G uidFunctionality
o t ma 12den
Chapter
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Advanced Shell Functionality


Chapter 12 - Page 1
Practices for Lesson 12: Overview

Practices Overview
In this practice, you use the commands described in this module to control jobs.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Advanced Shell Functionality


Chapter 12 - Page 2
Practice 12-1: Managing Jobs in the Korn Shell

Overview
Complete the following steps. Write the commands that you would use to perform each task in
the space provided.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Preparation
No special preparation is required for this practice.

RLDC
In addition to being able to use local classroom equipment, this practice was designed to also
use equipment located in a remote lab data center. Directions for accessing and using this
resource can be found at:
http://remotelabs.sun.com/
a ble
Ask your instructor for the particular SSH configuration file that you should use to access the f e r
appropriate remote equipment for this practice.
ans
n - t r
a no
Tasks
h a s
Perform the following:
m ) ideฺ
1. Run the following command in the background: ilฺco G u
ma den t
$ sleep 500 &
o t
h S tu
_____________________________________________________________
@
2. Find the job number of the sleep - 90 command
t s
hi in Step 1.
z
lle us e
a - e
Job number:__________________________________________________
t to
i s e
_____________________________________________________________
3. Bring the z job ns
(luto theceforeground, and then put it back in the background.
é l l e l i
_____________________________________________________________
a T
Luis4. What are job control commands? Name any two commands that are used for job control
and mention the functions of each of them.
_____________________________________________________________
_____________________________________________________________
5. Terminate the job by running the sleep command.
_____________________________________________________________
6. Enable the noclobber option, and use the set command to verify that you enabled it.
_____________________________________________________________
7. Display all predefined aliases.
_____________________________________________________________
8. Create an alias named cls that clears the terminal screen.
_____________________________________________________________
9. Create an alias named dir that displays a long listing of all the files and directories in the
current directory.
_____________________________________________________________

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Advanced Shell Functionality


Chapter 12 - Page 3
10. Create an alias named h that lists your command history.
_____________________________________________________________
11. Unalias the history command and the clear command.
_____________________________________________________________
12. Display all defined functions.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

_____________________________________________________________
13. Create a function called data that:
• Clears the terminal screen
• Displays the date and time
• Displays who is logged in to your system
• Displays the path of the current working directory
• Lists the current working directory in long format
_____________________________________________________________ a ble
f e r
14. Use vi to edit the .kshrc file in your home directory.
ans
$ vi ~/.kshrc
n - t r
Add the following line entries:
a no
set -o vi
h a s
alias h=’history’
m ) ideฺ
alias cls=’clear’ i l ฺ co t Gu
alias lf=’pwd ; ls -lF’
o t ma den
15. Enter the following commands:
@ h S tu
- 90 thi s
$ . ~/.profile
l z
le use
$ . ~/.kshrc
t e
a- e to
i s
16. Test your new aliases and functions.
z (lu cens
Practice
T é lleSummaryli
i s a the practice.
Discussion: Take a few minutes to discuss what experiences, issues, or discoveries you had
Lu during
• Experiences
• Interpretations
• Conclusions
• Applications

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Advanced Shell Functionality


Chapter 12 - Page 4
Practice Solutions: Managing Jobs in the Korn Shell

Overview
Complete the following steps.

Tasks
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

1. Run the following command in the background:


$ sleep 500 &
2. Find the job number of the sleep command started in Step 1.
$ jobs
The job number differs from system to system.
3. Bring the job to the foreground, and then put it back in the background.
$ fg %1
a ble
sleep 500
f e r
^Z[1] + Stopped (SIGTSTP) sleep 500 &
ans
$ jobs n - t r
o
[1] + Stopped (SIGTSTP) sleep 500 &
s an
$ bg %1
) ha eฺ
comt Guid
[1] sleep 500 &
4. i l ฺ
What are job control commands? Name any two commands that are used for job control
t ma den
and mention the functions of each of them.
o
h S tu
Job control commands enable you to place jobs in the foreground or background, and to
@
start or stop jobs. - 90 thi s
l z
le use
Two commands used for job control are the jobs command and the bg %n command.
t e
a- e to
The jobs command lists all jobs that are currently running or are stopped in the
i s
(lu cens
background, and the bg %n command runs the current or specified job in the background
z
élle li
(n is the job ID).
5.
a T
Terminate the job by running the sleep command.
Luis $ kill %1
[1] + Terminated sleep 500 &
6. Enable the noclobber option, and use the set command to verify that you enabled it.
$ set -o noclobber
$ set -o | more
7. Display all predefined aliases.
$ alias
8. Create an alias named cls that clears the terminal screen.
$ alias cls=clear
9. Create an alias named dir that displays a long listing of all the files and directories in the
current directory.
$ alias dir=’ls -l’
10. Create an alias named h that lists your command history.
$ alias h=history

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Advanced Shell Functionality


Chapter 12 - Page 5
11. Unalias the history command and the clear command.
$ unalias h
$ unalias cls
12. Display all defined functions.
$ typeset -f
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

13. Create and test a function called data that:


• Clears the terminal screen
• Displays the date and time
• Displays who is logged in to your system
• Displays the path of the current working directory
• Lists the current working directory in long format.
$ function data { clear; date; who; pwd; ls -l; }
14. Use vi to edit the .kshrc file in your home directory: a ble
f e r
$ vi ~/.kshrc
ans
Add the following line entries:
n - t r
o
set -o vi
s an
alias h=’history’
) ha eฺ
comt Guid
alias cls=’clear’
alias lf=’pwd ; ls -lF’
i l ฺ
15. Run the following commands:
o t ma den
$ . ~/.profile
@ h S tu
$ . ~/.kshrc - 90 thi s
l z
le use
16. Test your new aliases and functions.
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Advanced Shell Functionality


Chapter 12 - Page 6
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Practices for h a s
Lesson 13:
) e ฺ
Reading
i l ฺ comShell
G
id
uScripts
t m a 13 ent
@ ho Stud
Chapter

- 9 0 this
t e l lez use
i s a- e to
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: Reading Shell Scripts


Chapter 13 - Page 1
Practices for Lesson 13

There are no practices for Lesson 13.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: Reading Shell Scripts


Chapter 13 - Page 2
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Practices for h a s
Lesson 14:
) e ฺ
Creating
i l ฺ comArchives
G uid
t m a 14 ent
@ ho Stud
Chapter

- 9 0 this
t e l lez use
i s a- e to
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Creating Archives


Chapter 14 - Page 1
Practices for Lesson 14: Overview

Practices Overview
In this practice, you archive, view, and retrieve files on a tape or a flash drive.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Creating Archives


Chapter 14 - Page 2
Practice 14-1: Archiving and Retrieving Files

Overview
To create a file archive, view the archive and retrieve files from the archive, complete the
following steps:
Note: If you get a Permission Denied error message while performing this practice, check the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

write-protect switch on the tape cartridge. Archive your home directory to a file by using the tar
command.

Preparation
Ensure that a tape device is connected to your system. Ask your instructor for any help
required.

RLDC
a ble
In addition to being able to use local classroom equipment, this practice was designed to also
f e r
use equipment located in a remote lab data center. Directions for accessing and using this
ans
resource can be found at:
n - t r
http://remotelabs.sun.com/
a no
a s
Ask your instructor for the particular SSH configuration file that you should use to access the
h
appropriate remote equipment for this practice.
m ) ideฺ
i l ฺ co t Gu
Tasks o t ma den
@ h S tu
Perform the following: 0 thi
-9command s
1. What type of file does theetar
l l z s e create?
- t e to u
_____________________________________________________________
i s a e
2. Archive your
z ns on a tape.
(luhomecedirectory
lle li
_____________________________________________________________
é
T
3. Which command do you use to mount a flash drive?
a _____________________________________________________________
u i s
L 4. Which command do you use to copy files to a flash drive?
_____________________________________________________________
5. Archive your home directory to a file called username.tar in the /tmp directory by using
the tar command.
_____________________________________________________________
6. Use the tar command to view the contents of your home directory archive.
_____________________________________________________________
7. Create a new directory in your home directory called Retrieve. Use the cd command to
move to the new directory. You can use the new directory to practice retrieving files from
archives. Retrieve the contents of the archive tar file that you created on tape.
_____________________________________________________________
8. Ensure that all files in the ~/dir1 directory are readable, and then use the jar command
to archive the ~/dir1 directory.
_____________________________________________________________

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Creating Archives


Chapter 14 - Page 3
9. Use the tar command to archive the ~/dir1 directory and the contents of the dir1
directory.
_____________________________________________________________
10. What is the difference between the tar command and the jar command?
_____________________________________________________________
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

11. Compare the current size of the tar file and the jar file archives.
_____________________________________________________________
Is there a difference in the size of the files?
_____________________________________________________________

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Creating Archives


Chapter 14 - Page 4
Practice Solutions: Archiving and Retrieving Files

Overview
To create a file archive, view the archive and retrieve files from the archive, complete the
following steps.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Tasks
1. What type of file does the tar command create?
A tar file
2. Archive your home directory on a tape.
$ cd
$ tar cvf /dev/rmt/0
a ble
3. Which command do you use to mount a flash drive?
f e r
The volrmmount -i rmdisk0 command
ans
4. Which command do you use to copy files to a flash drive? n - t r
The cp command a no
5. Archive your home directory to a file called username.tar in h a s/tmp directory by using
the
the tar command. m ) ideฺ
$ tar cvf /tmp/username.tar . ilฺc
o Gu
m ayour home
e n t
6. Use the tar command to view the contents
h o t of
u d directory archive.
@ is S t
$ tar tf /tmp/username.tar
- 9 0 th called Retrieve. Use the cd command to
7. Create a new directory in your
l e z home directory
e
move to the new directory.
- l You can
tecontents
t o ususe the new directory to practice retrieving files from
i s
archives. Retrieve a the e of the archive tar file that you created on tape.
l u
( Retrieve en s
l e z
$ mkdir
l i c
T él $ cd ~/Retrieve
a
uis
$ tar xvf /dev/rmt/0
L ... (output truncated)
8. Ensure that all files in the ~/dir1 directory are readable, and then use the jar command
to archive the ~/dir1 directory.
$ cd
$ jar cvf dir1.jar dir1
9. Use the tar command to archive the ~/dir1 directory and the contents of the ~/dir1
directory.
$ cd
$ tar cvf dir1.tar dir1
10. What is the difference between the tar command and the jar command?
The tar command archives files to a single file called a tar file. The jar command
compresses the named files in addition to archiving the files.

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Creating Archives


Chapter 14 - Page 5
11. Compare the current size of the tar file and the jar file archives.
$ ls -l dir1.tar dir1.jar
Is there a difference in the size of the files?
Yes.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Creating Archives


Chapter 14 - Page 6
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Practices for h a s
Lesson 15:
) e ฺ
i l ฺ comt GuViewing,
Compressing, id and
o t ma den
Uncompressing Files
h t u
- 9 is S 15
0@ thChapter
t e l lez use
i s a- e to
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Compressing, Viewing, and Uncompressing Files


Chapter 15 - Page 1
Practices for Lesson 15: Overview

Practices Overview
In this practice, you compress and uncompress files, and view compressed files.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Compressing, Viewing, and Uncompressing Files


Chapter 15 - Page 2
Practice 15-1: Compressing and Restoring Files

Overview
To compress and uncompress files, complete the following steps. Write the commands that you
would use to perform each task in the space provided.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Preparation
Note: Before you begin this practice, uncompress any file that you compressed in the examples
in the module.
RLDC
In addition to being able to use local classroom equipment, this practice was designed to also
use equipment located in a remote lab data center. Directions for accessing and using this
resource can be found at:
http://remotelabs.sun.com/
a ble
Ask your instructor for the particular SSH configuration file that you should use to access the f e r
appropriate remote equipment for this practice.
ans
n - t r
a no
Tasks
h a s
Perform the following:
m ) ideฺ
1. In your home directory, use the compress command i l ฺ coto compress
t G u the dante file and the
file1 file.
o t ma den
h tu
_____________________________________________________________
@ S
2. What are the new names for -the 90compressed
t s
hi versions of the dante file and the file1 file?
z
lle us e
_____________________________________________________________
- t
a can e o use to view the contents of a file that was compressed with
tyou
i s
3. Which three commands e
z (lu command?
the compress
c e ns
élle li
_____________________________________________________________
T
a Use the gzip command to compress the file2 file and the dante_1 file.
4.
Luis _____________________________________________________________
5. What are the new names for the compressed versions of the file2 file and the dante_1
file?
_____________________________________________________________
6. What is the difference between the gzip command and the zip command?
_____________________________________________________________
7. Use the zip command to compress the file3 file, the fruit2 file, and the tutor.vi file
to a file called files.zip.
_____________________________________________________________
8. Which command do you use to view the compressed archive file called files.zip?
_____________________________________________________________
9. Do the original versions of the file3 file, the fruit2 file, and the tutor.vi file still exist?
_____________________________________________________________

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Compressing, Viewing, and Uncompressing Files


Chapter 15 - Page 3
10. Uncompress the dante.Z file and the file1.Z file.
_____________________________________________________________
Do the dante file and the file1 file still have a .Z extension on the file names?
_____________________________________________________________
11. Which command do you use to uncompress the file2.gz file and the dante_1.gz file?
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

_____________________________________________________________
Do the file2 file and the dante_1 file still have a .gz extension on the file names?
_____________________________________________________________
12. Which command do you use to unarchive the file3 file, the fruit2 file, and the
tutor.vi file from the zip file created in Step 7?
_____________________________________________________________
Does the files.zip file still exist in the directory?
_____________________________________________________________ a ble
f e r
13. What happens when you compress a file that is already compressed?
ans
_____________________________________________________________
n - t r
Practice Summary a no
h a sor discoveries you had
during the practice. m ) ideฺ
Discussion: Take a few minutes to discuss what experiences, issues,

i l ฺ co t Gu
ma den
• Experiences
o t
• Interpretations
@ h S tu
• Conclusions
- 90 thi s
• Applications
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Compressing, Viewing, and Uncompressing Files


Chapter 15 - Page 4
Practice Solutions: Compressing and Restoring Files

Overview
To compress and uncompress files, complete the following steps.

Tasks
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

1. In your home directory, use the compress command to compress the dante file and the
file1 file.
$ compress dante
$ compress file1
2. What are the new names for the compressed versions of the dante file and the file1 file?
dante.Z
file1.Z
a ble
3. Which three commands can you use to view the contents of a file that was compressed with
f e r
the compress command?
ans
The uncompress -c filename command, the zcat filename command, or the gzcat
n - t r
filename command
a no
4. s
Use the gzip command to compress the file2 file and the dante_1 file.
h a
$ gzip file2 dante_1
m ) ideฺ
5. What are the new names for the compressed versions i l ฺ coof the
t G u file and the dante_1
file2
file?
o t ma den
The names are:
@ h S tu
file2.gz
- 90 thi s
l z
le use
dante_1.gz
t e
a- between
6. What is the difference to the gzip command and the zip command?
i s e
lu ereduces
The gzip(command
z c ns the size of files, whereas the zip command compresses one
T é lle files intolia single zip archive.
or more
a Use the zip command to compress the file3 file, the fruit2 file, and the tutor.vi file
7.
Luis to a file called files.zip.
$ zip files.zip file3 fruit2 tutor.vi
adding: file3 (deflated 25%)
adding: fruit2 (deflated 17%)
adding: tutor.vi (deflated 75%)
8. Which command do you use to view the compressed archive file called files.zip?
The unzip -l files.zip command
9. Do the original versions of the file3 file, the fruit2 file, and the tutor.vi file still exist?
Yes.
10. Uncompress the dante.Z file and the file1.Z file.
$ uncompress dante.Z
$ uncompress file1.Z
Do the dante file and the file1 file still have a .Z extension on the file names?
No.

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Compressing, Viewing, and Uncompressing Files


Chapter 15 - Page 5
11. Which command do you use to uncompress the file2 file and the dante_1 file?
The gunzip file2.gz dante_1.gz command
Do the file2 file and the dante_1 file still have a .gz extension on the file names?
No.
12. Which command do you use to unarchive the file3 file, the fruit2 file, and the tutor.vi
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

file from the zip file created in Step 7?


$ unzip files.zip
Archive: files.zip
replace file3? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
inflating: file3
inflating: fruit2
inflating: tutor.vi
Does the files.zip file still exist in the directory?
a ble
Yes. f e r
ans
13. What happens when you compress a file that is already compressed?
n - t r
Compressing a file that has already been compressed results in a file size that is larger and o
not smaller.
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Compressing, Viewing, and Uncompressing Files


Chapter 15 - Page 6
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
a no
Practices for h a s
Lesson 16:
) e ฺ
Performing
i l ฺ comt G uid
Remote
o t ma den
Connections
@ h Chapter
S tu16
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: Performing Remote Connections


Chapter 16 - Page 1
Practices for Lesson 16: Overview

Practices Overview
In this practice, you will use some of the remote connection commands introduced in this
lesson.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: Performing Remote Connections


Chapter 16 - Page 2
Practice 16-1: Performing Remote Connection Commands

Overview
To use remote connection commands, complete the following steps. Write the commands that
you would use to perform each task in the space provided.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Preparation
Launch the calculator on each system prior to beginning the practice, by performing the
gcalctool command.

RLDC
In addition to being able to use local classroom equipment, this practice was designed to also
use equipment located in a remote lab data center. Directions for accessing and using this
resource can be found at:
a ble
http://remotelabs.sun.com/
f e r
Ask your instructor for the particular SSH configuration file that you should use to access the ans
appropriate remote equipment for this practice. n - t r
a no
h a s
Tasks
m ) ideฺ
Perform the following:
i l ฺ co t Gu
1. Perform the ssh command to log in to another
o t masystem d innyour classroom.
e
h tu
_____________________________________________________________
@ S
Which directory are you accessing - s
90 on thethremote
i system?
l e z e
- l
tethat t o us
_____________________________________________________________
2. Perform the command
i s a e shows you the host name of the current system.
l u
( cen s
_____________________________________________________________
e z i
él the ps lcommand
l
3. Perform
T to identify the PID of the gcalctool command on the remote
a system.
Luis _____________________________________________________________
4. Terminate the gcalctool command using the PID.
_____________________________________________________________
Are you able to terminate the process? Why or why not?
_____________________________________________________________
5. Log out of the remote system.
_____________________________________________________________
6. Display the host name of your current system to determine whether you are back on your
host system.
_____________________________________________________________
7. Which remote connection command do you use to run a program remotely?
_____________________________________________________________
8. Which command do you use to terminate a process by remotely logging into another
system?
_____________________________________________________________

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: Performing Remote Connections


Chapter 16 - Page 3
9. Which command do you use to copy files remotely?
_____________________________________________________________
10. Copy the dante file from your local directory to the /export/home/student/dir1
directory on the remote host.
_____________________________________________________________
11. Copy the dante file from the remote system back to the home directory on your local
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

system.
_____________________________________________________________
12. Which command do you use to copy remote directories?
_____________________________________________________________
13. Which remote connection command do you use to transfer files from system to system,
including binary files?
_____________________________________________________________
a ble
14. How do you end an ftp session?
f e r
_____________________________________________________________
ans
15. How do you simultaneously transfer multiple files from a remote system to your current n - t r
working directory on your local system?
a no
a
_____________________________________________________________
h s
16. m ) ideฺ
How do you transfer multiple files from the local system to a directory on the remote
system?
i l ฺ co t Gu
o t ma den
_____________________________________________________________

@ h S tu
Practice Summary
- 0 thi
9discuss s
Discussion: Take a few minutes
l z
le use what experiences, issues, or discoveries you had
to
during the practice. t e
a- e to
i s
(lu cens
• Experiences
z
le li
• lInterpretations
T• é Conclusions
a
Luis • Applications

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: Performing Remote Connections


Chapter 16 - Page 4
Practice Solutions: Performing Remote Connection Commands

Overview
To use remote connection commands, complete the following steps:

Tasks
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

1. Perform the ssh command to log in to another system in your classroom.


$ ssh [-l login_name] hostname | user@hostname [ command]

Which directory are you accessing on the remote system?


A home directory on the remote system (either /home/username or
/export/home/username) or the root(/) directory if no home directory exists
2. Perform the command that shows you the host name of the current system.
a ble
$ uname -n
f e r
3. Perform the ps command to identify the PID of the gcalctool command on the remote
ans
system.
n - t r
o
an
$ ps -ef | grep gcalctool
4. Terminate the gcalctool command using the PID. s
ha eฺ
)
comt Guid
$ kill PID
l ฺ
Are you able to terminate the process? Why or why not?
i
t ma den
If you log in to the remote system as root, you are able to terminate the process. If you log
o
h tu
in to the remote system as the same user (same UID) as the user that started the process
@ S
90 thi s
on the remote system, then you are also able to terminate the process. If you log in to the
-
z
le use
remote system as some other user, then you are not able to terminate the process because
l
t e
you do not own it and do not have permission.
a- e to
5. i s
Log out of the remote system.
z (lu cens
élle
$ exit
li
6.
a T
Display the host name of your current system to determine whether you are back on your

Luis host system.


$ uname -n
7. Which remote connection command do you use to run a program remotely?
The ssh command
8. Which command do you use to terminate a process by remotely logging into another
system?
The ssh command to remotely log in to your system from another system, followed by the
pkill command
9. Which command do you use to copy files remotely?
The scp command
10. Copy the dante file from your local directory to the /export/home/student/dir1
directory on the remote host.
$ scp dante hostname:/export/home/student/dir1
11. Copy the dante file from the remote system back to the dir2 directory on your local system.
$ scp hostname:/export/home/student/dir1/dante
/export/home/student/dir2

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: Performing Remote Connections


Chapter 16 - Page 5
12. Which command do you use to copy remote directories?
$ scp -r directory_name hostname:/export/home/student
13. Which remote connection command do you use to transfer files from system to system,
including binary files?
The ftp command
14. How do you end an ftp session?
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ

Type bye or quit at the ftp> prompt.


15. How do you simultaneously transfer multiple files from a remote system to your current
working directory on your local system?
Run the mget command.
16. How do you transfer multiple files from the local system to a directory on the remote
system?
Run the mput command.
a ble
f e r
ans
n - t r
o
s an
) ha eฺ
i l ฺ comt Guid
o t ma den
@ h S tu
- 90 thi s
l z
le use
t e
a- e to
i s
z (lu cens
élle li
a T
Luis

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: Performing Remote Connections


Chapter 16 - Page 6

Das könnte Ihnen auch gefallen