Sunteți pe pagina 1din 258

Operating System Boot Camp

Student Guide

Education Services
July 2012

Welcome to Operating System Boot Camp.

Copyright 2012 EMC Corporation. All rights reserved

Introduction

Copyright 2012 EMC Corporation. All rights reserved

Introduction

The objectives for this course are shown here. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Introduction

These materials may not be copied without EMC's written consent.

Copyright 2012 EMC Corporation. All rights reserved.


These materials may not be copied without EMC's written consent.
EMC believes the information in this publication is accurate as of its publication date. The information is subject to change
without notice.
THE INFORMATION IN THIS PUBLICATION IS PROVIDED AS IS. EMC CORPORATION MAKES NO REPRESENTATIONS OR
WARRANTIES OF ANY KIND WITH RESPECT TO THE INFORMATION IN THIS PUBLICATION, AND SPECIFICALLY DISCLAIMS
IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Use, copying, and distribution of any EMC software described in this publication requires an applicable software license.
EMC2, EMC, EMC ControlCenter, AlphaStor, ApplicationXtender, Captiva, Catalog Solution, Celerra, CentraStar, CLARalert,
CLARiiON, ClientPak, Connectrix, Co-StandbyServer, Dantz, Direct Matrix Architecture, DiskXtender, DiskXtender 2000,
Documentum, EmailXaminer, EmailXtender, EmailXtract, eRoom, FLARE, HighRoad, InputAccel, Navisphere, OpenScale,
PowerPath, Rainfinity, RepliStor, ResourcePak, Retrospect, Smarts, SnapShotServer, SnapView/IP, SRDF, Symmetrix,
TimeFinder, VisualSAN, VSAM-Assist, WebXtender, where information lives, Xtender, Xtender Solutions are registered
trademarks; and EMC Developers Program, EMC OnCourse, EMC Proven, EMC Snap, EMC Storage Administrator, Acartus,
Access Logix, ArchiveXtender, Authentic Problems,Automated Resource Manager, AutoStart, AutoSwap, AVALONidm, CClip, Celerra Replicator, Centera, CLARevent, Codebook Correlation Technology, EMC Common Information Model,
CopyCross, CopyPoint, DatabaseXtender, Direct Matrix, EDM, E-Lab, Enginuity, FarPoint, Global File Virtualization, Graphic
Visualization, InfoMover, Infoscape, Invista, Max Retriever, MediaStor, MirrorView, NetWin, NetWorker, nLayers, OnAlert,
Powerlink, PowerSnap, RecoverPoint, RepliCare, SafeLine, SAN Advisor, SAN Copy, SAN Manager, SDMS, SnapImage,
SnapSure, SnapView, StorageScope, SupportMate, SymmAPI, SymmEnabler, Symmetrix DMX, UltraPoint, UltraScale,
Viewlets, VisualSRM are trademarks of EMC Corporation.
All other trademarks used herein are the property of their respective owners.

Revision Date: July 2012


Revision Number: MR-7CN-NSOSBOOT.5.0

Copyright 2012 EMC Corporation. All rights reserved

Introduction

The objectives for this module are shown here. Please take a moment to review
them.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System

The objectives for this lesson are shown here. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System

Layered Operating system


The innermost layer is the hardware that provides the services to the OS.
The middle layer is the kernel which interacts with the hardware and provides the services to the user
programs.
(The user programs dont need to know anything about the hardware).
The outmost layer has user programs which interact with the kernel through system calls. These calls
request services to be provided by the kernel such as:
file operations (open, close, read, write, link or execute)
records operation (starting/updating),
updates to file or directory attributes
enabling access to hardware devices, and
setting limits on system resources.
Multi-user and Multi-tasking
Many users can be logged into the system simultaneously, each running many programs.
The kernel keep each process and user separate and regulate access to system hardware.
File System
Inverted tree structure
Each inode is a file or a directory of files
An inode is a special file designed to be read by the kernel
Every directory or file is listed in its parent directory
A directory is a file that contains a table with the list of files contained within it
Program or Commands
Interact with the kernel to provide the environment and perform the functions called by the user:
Shell script (executable shell file)
Built-in shell command
Source compiled, object code file
System programs are usually binary, compiled from C source code, located in: /bin, /usr/bin, usr/local/bin,
/usr/ucb.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System

This slide shows a basic layout of a typical computer system and the position the operating
system plays.
At the lowest level is the physical hardware including:
network cards
HBAs
Direct-attached storage devices, and
other peripherals.
In the middle is the operating system. It is responsible for maintaining control over the
physical hardware and providing for:
User management
system services in UNIX we call them deamons, and
control of the file systems.
On top of the operating system are applications that either run at start up time or are
launched by individual users of the system. Access to system hardware by these applications
is provided by the operating system. Access to system hardware by users is also provided by
the operating system.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System

The core of any computer system is the hardware that works with the system software to perform
various tasks. The computer hardware is composed of different components which require an
operating system to make them work as a team. Operating systems are designed to instruct a
computer how to use its hardware to perform various tasks.
The operating system is the first software loaded it is also known as the kernel image. The kernel
allows the execution or all command, application and user programs. The kernel allocates the
hardware resources necessary for execution, memory, disks, tape drives etc. For example, the user
program must be read into physical memory for program execution to take place.
The kernel must be queried before any attempted hardware access can be performed to determine if
the user has the privileges to use those resources. If there are multiple programs to be run the kernel
uses a process called the schedule to equitably allocate resources to all programs. This is called time
sharing. All applications, (programs) loaded on a system are run after the operating system.
If you add new hardware you must also add the modules - drivers, that support that hardware. It is
similar to attaching a new printer to your PC. When the printer is purchased it comes with a cd that
contains the driver. However, unlike the PC the UNIX drivers may be added into the kernel image by
performing a kernel rebuild. This rebuild, allows the code to become part of the kernel image that is
loaded every time you boot the machine. This makes the addition of new devices possible. In Linux
the drivers are loaded as kernel modules. If it were not for these modules you would have to build
and compile a kernel with all drivers in it. This would eat up huge amounts of memory, wasting
memory, and users would be required to rebuild and reboot the kernel any time they wanted to add
a new driver. The kernel also insulates the user programs and applications from the different
hardware platforms allowing them to be independent and more portable.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System

The shell is responsible for providing and easy way to interface with the kernel and is responsible for
program execution. The shell reads input from the keyboard, called stdin and processes it , checking it
for syntax errors before passing it on to be processed. The shell also interprets any meta characters
on the command line. A meta character is any non alpha numeric character. The shell also has
programming features imbedded in its code. The features include the ability to perform for and while
loops, if/then/else statements and variable creation among other capabilities. It can also be used to
recall and edit previous command and allows for alias creation. In short, the shell is your user
environment.
The shell has the ability to connect commands together in a string called a pipeline. A pipeline allows
the output, stdout, to be connected to the input, stdin, of another command. The shell is the user
environment, and without it you cannot be logged into the machine. If you do not like your shell
environment you can simply run a different one.
Bourne Shell - is the original AT&T shell developed at Bell Labs by Stephen Bourne, you write it, you
get to name it. It provides all the features listed above but lacks some of the user-friendly capabilities
we expect. For example, command line recall and command line editing.
C Shell - developed at the University of California Berkeley (UCB), was the shell provided for Berkeley
Software Distribution (BSD), based machines. The C shell is short for the California shell. It is
supported by most versions of UNIX and has similar features to that of the Bourne shell. It has
additional capabilities such as command aliasing, command recall and command line editing.
Korn Shell - also written at Bell Labs by David Korn, is Bourne shell superset for the System V
environment. It has the same capabilities of the C shell but the code has been optimized to run faster
and more efficiently.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System

Utilities and applications are commands and programs activated in the shell. The utilities and
applications in the UNIX environment are called tools. The tools are designed with the same
modular concept. There are hundreds of tools at your disposal. For example, the ls
command will read the contents of a directory and display the attributes of the files to your
screen. The cd command will change the current directory location. The tools were created
by many different individuals. If there was not a program that fits your needs, you designed
and built a new one. This accounts for the lack of consistency in command syntax, but it
allowed users to be creative and flexible in the tool creation.
The tools cannot be run by the user. The user must have an interface to allow the command
to be run and to parse the command line for syntax and wildcards. This interface is called a
shell.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System

A user is any person who has a standard login account on the system. When a User logs in,
he can change only his personal work area. A user can run the graphical administration tools,
but the features of the tools that change system information are not available.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System

This slide lists the tasks for which a System administrator is responsible.
Root is the super user on UNIX and Linux Operating Systems. The root account and password
is setup during the Unix or Linux installation process. This login account is used by the system
administrator to perform specific administration tasks on the system.
Administrator is the user with privileges to manage Windows systems. For instance, a
member of the Users group can perform most of the tasks necessary to do his or her job,
such as logging on to the computer, creating files and folders, running programs, and saving
changes to files. However, only a member of the Administrators group can add users to
groups, change user passwords, or modify most system settings.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System

A home directory is a directory for the personal files of a user.


It is the directory that the system administrator assigns to you as part of creating your
account.
Home directories make it easier for an administrator to back-up user files and manage
user accounts by collecting many or all of a user's files in one location.
If a home directory is assigned to a user, the user's data can be stored in a central
location on a server and backup and recovery of data is easier and more reliable.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 10

The home directory for UNIX is usually the same as the login directory.
Additional directories the user creates all stem from the home directory.
The home directory is where you are placed after login.
The user home directory is where users keep all of their files.
After applying the correct security permissions to the users home directory, the default
configuration files such as .profile are copied into the users home directory. A .profile is
much like a profile in social networking environments. It is responsible for giving you a
consistent look and feel every time you login and configuring your shell to perform simple
task.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 11

By default, the home directory for new users created is drive:\Users, where drive is the letter
of the boot volume. You can specify a different directory as the root directory in which
the home directory for new users is created. To do this, create the registry key
HKLM\Software\Microsoft\ServerAppliance\UserGroup and then create a string value
named UserDir that contains the full home directory path.
Note: To specify a network path for the home directory, you must first create the network
share and set permissions that allow the user access. You can do this with Shared Folders
in Computer Management on the server computer.
To assign a home directory to a domain user:
1. Click Start> Programs > Administrative Tools,
2. Click Active Directory Users and Computers.
3. In the Details pane, right-click the applicable user account, and then click Properties.
4. In the Properties dialog box, click the Profile tab.
5. Under Home folder, type the directory information.
To assign a home directory to a domain user:
1. Click Start> Settings> Control Panel. Double-click Administrative Tools and then
double-click Computer Management.
2. In the console tree, click Users in Local Users and Groups.
3. Click the user account that you want to work with.
4. Click Action, and then click Properties.
5. Click the Profile tab, click Connect, and then specify a drive letter.
6. In the To box, type a path.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 12

This slide reviews specific information for user accounts.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 13

UNIX SYSTEMS

Each user must have a user account on the system to log in. All user accounts are defined in
the /etc/passwd file and contain the elements that identify each unique user to the system.

System administrators are responsible for creating and maintaining user accounts. The root
login account is used by the administrators to perform administration tasks on the system.

Each user account entry in the /etc/passwd file contains seven fields separated by a colon:
[Login ID]:[Placeholder]:[UID]:[GID]:[Comment]:[Login Directory]:[Default shell]
Where:
Login ID Contains the identification required by the system for a successful log in.
Placeholder Maintains the field for the password, which is kept in the /etc/shadow file.
The /etc/shadow file contains encrypted passwords and password aging information (for
example, when a user must change a password and how long a password must be in use
before it can be changed). This file can be read only by the system administrator.
UID Identifies the users unique numerical ID (UID).
GID Identifies the groups unique numerical ID (GID) within the system.
Comment Is traditionally the full name of the user.
Login directory Is referred to as the home directory and is where users create and store
their personal files.
Default shell Defines shell the users will be working in once they log in to the system.
Example: User1:x:102:10:johh smith extension 1111:/export/home/user1:/bin/ksh

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 14

Users must enter a password to prove their identity Security. A user must provide a user
name and password to gain access to a computer of the network or to any resource on that
computer.
Password Change
When an account is issued, the user is given an initial password.
It is important for system and personal security that the password for the account be
changed to one that the user chooses.
Passwords can be the weakest link in a computer security scheme. The application of strong
passwords is very important because of the continuous improvement of cracking tools, since
these software tools use one of three approaches: intelligent guessing, dictionary attacks,
and automation that tries every possible combination of characters.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 15

When a user logs into Unix, the user types in a user Login ID to identify him/herself to the
system. The system thinks of the user as a number called UID (User Identification), instead of
a variable length string. Also, the group the user belongs to is defined as another number
which is called GID (Group Identification).
The two numbers are required for the system to identify the users logged in and their
privileges upon the operation with files.
UNIX assigns the identification numbers to files when a users creates them. When the files
are accessed the UID on the file is referenced to the UID of the user attempting the access.
This insures that every attempted access is valid and authorized.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 16

In the /etc/passwd file, information is stored concerning each account. It is an ASCII file with
world read permission, but write permission only for the root account. The information
consists of records, each one is one line long, and stores the information concerning one
user. The lines are subdivided in seven fields, separated by colons (":"):
The login username
The encrypted password
The user number or UID that identifies the user in the system and must be unique
The Group Number or GID to which the user belongs
Comment about the account, which is usually used to put the Real user name and
some information about its organization or workplace
Home directory of the user: this is the directory where the user logs in to
It sets the shell that the user will use in the system
In the /etc/group file, each line on the file is a record, composed by four fields separated by
colons. One record declares a group.
The group's name, should be a name representative for the group
The password of the group, usually left blank
The Group ID (or GID)
The last field is a list of the users that belong to this group. Each user on this field is
separated by a comma ",".
In the example of /etc/group: The group represented by the number 10 is called staff and
User1 and User2 belong to this group
Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 17

This slide lists information about user accounts for a Windows environment.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 18

Within Unix and POSIX systems, membership in a group establishes one level of privilege.
Group membership is also often used to control or limit access to system resources. A
user can only be a member of one group at a time.
To make a new group requires adding a record to the /etc/group file, assigning the group a
unique ID. The usermod command lets a system administrator change the group to
which a user belongs.
In Windows NT user manager, a group is an account that contains other accounts, which are
called members. Permissions and rights granted to a group are also provided to its
members, making groups a convenient way to grant common capabilities to collections of
user accounts.

Four default groups (Administrators, Power Users, Users, and Backup Operators)
Three special groups (Interactive, Network, Terminal Server)
To associate a user to a group:
1. Click Start> Programs >Administrative Tools,
2. Click Active Directory Users and Computers.
3. In the Details pane, right-click the applicable user account, and then click Properties.
4. In the Properties dialog box, click the tab and associate the account to the proper
group.
The NetUserAdd function adds a user account and assigns a password and privilege level.

NET_API_STATUS NetUserAdd (LMSTR servername, DWORD level, LPBYTE buf,


LPDWORD parm_err).
Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 19

For a password to be strong and hard to break, it should:

Be at least six to eight characters long


Contain characters from each of the following three groups:
Letters (uppercase and lowercase)

A, B, C,...; a, b, c,...

Numerals 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Symbols (all characters not defined as letters or numerals) ` ~ ! @ # $ % ^ & * (
)_+-={}|[]\:";'<>?,./

Have at least one symbol character in the second through sixth positions
Be significantly different from prior passwords
Not contain your name or user name
Not be a common word or name

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 20

Follow these important tips to keep your password safe.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 21

The objectives for this lesson are shown here. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 22

Once the system has verified your password, the shell is started to provide command line
interpretation. Whitespace is used to separate the command from options and options from
arguments. Whitespace is defined as any space or number of spaces. Options on the
command line are typically preceded with a ( - ) hyphen or minus sign. Arguments can be an
ASCII string of characters, regular expression, or a list of files or directories. The shell does
not attempt to interpret the options and arguments for correctness. It simply checks to see if
the proper syntax ( spaces, hyphens, etc ) has been maintained on the line. The shell then
passes the argument list to the command for processing.
The carriage return is used to terminate the command line and submit it for execution. A
command is a program that tells the Unix system to do some action. The standard
convention for commands are shown on this slide.
Commands are case-sensitive (Only in UNIX and POSIX systems).
command and Command are not the same.
Options are generally preceded by a hyphen (-), and for most commands, more than one
option can be strung together:
command -[option][option][option]
For most commands, you can separate the options with spaces, preceding each with a
hyphen.
command -option1 -option2 -option3
Some commands have options that require parameters.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 23

In UNIX environments, letters are case-sensitive. Therefore, the files Bear and bear are
two different files; as are BEAR and beaR. However, in Windows environments, BEAR,
bear, Bear, and beaR, and so on, all represent the same file and may be
addressed/located as such. Attempts to access a file or run a command using the wrong case
will fail in a UNIX environment. Unless otherwise specified all UNIX commands and options
are in lowercase.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 24

The objectives for this lesson are shown here. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 25

Section 1 User Commands General commands that can be executed by any non-privileged
user.
Section 1m System Maintenance Lists all commands that are used by the system
administrator (root). Commands to setup the network, add users, manipulate print queues,
dump and restore disk data are found in this section.
Section 2 System Calls Pre-written entry points used to access kernel functions.
Section 3 Functions and Function Libraries Illustrates functions that are provided on the
system in binary format other than direct system calls. These are typically C Language
programs that can be included in the creation of a program; For example, the directory
/usr/lib contains the library math.h which includes many mathematical operations, square
root, exponents, pi etc.
Section 4 File Formats Documents the usage of fields, parameters, and structures of various
system configuration files
Section 5 Miscellaneous File descriptors, header files, character sets, macros, and manuals
are found in this section.
Sections can also be searched, but how it is done is specific to the UNIX variant you are
running. In the Solaris version of UNIX it can be done by running
# man s4 passwd

This command will search only section 4 for the file, not command, called passwd. It will
display the text to your screen.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 26

In the UNIX system documentation, every reference has multiple section headers. Each
header pertains to a type of information that can be found there. Below is a list of those
headers. Every command or word that you lookup will also contain the section of the man
pages that the command comes from. It will be in the format command ( n ), where
command is the keyword being searched for and n is the section it comes from. Each
manual page takes up more than one screen. It uses the paging utility program called more
to paginate it.
Use <space> to see the next page of text. Use <return> to see the next line. Use <q> to quit
the man command.
Name -A one line description of the command usage. This description can be searched,
using the man k command.
Synopsis -Displays the proper syntax of the command. Any text in square brackets [ ] is
optional. Any data followed with the ellipses ... indicate that the argument string can be
repeated until the maximum length of the command line is reached.
Description -Specific information on the command. The description will list all command line
options and the proper use. The description can be a page or in some cases 20 pages.
The man k option will search the NAME field for any keyword that you require. It is useful
when you have no idea what the command is you need. In some UNIX variants there is a
command used as a substitute for man -k. It is called apropos. Detailed command
information can be displayed using the man command which displays the man page. The
man page displays a description of the command, its usage syntax, and detailed options
information.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 27

man formats and displays the on-line manual pages. If you specify a section, man only looks
in that section of the manual. The name is normally the name of the manual page, which is
typically the name of a command, function, or file. However, if name contains a slash then
man interprets it as a file specification, so that you can do or even man /cd/foo/bar.1.gz
man can also be search for a keyword, like the word copy
# man k copy
Will search all sections for and command that has a description that contains the word copy.
This function must be added to the standard man pages by using the whatis database. To
create this database you must use this command
# catman -W

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 28

The objectives for this lesson are shown here. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 29

The delete and backspace keys on a Unix machine are the opposite of how your laptop is
setup for erasing characters and killing a command. The above command stty a will
list all the control sequences that are set up on you terminal connection in a putty
session.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 30

The default erase key is the del key and the default kill key is the backspace key. The keys
can be mapped to any configuration you require. This is evident when you look at the
German, French and Cyrillic keyboards of students from other countries.
The sane arguments may be needed if several parameters have changed making it difficult to
use the terminal, or if a program exits ungracefully your terminal can be left in "raw" mode.
For more information pertaining to this command such as options and arguments please use
the Online Manual by typing the following command:
man stty

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 31

The objectives for this lesson are shown here. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 32

The password is can only be changed by the user or the system administrator (root). The user
is prompted for a verification in order to confirm the change and limit typographical errors.
The password is not echoed to the screen and the requirements for its length and duration of
activity can be modified but there are some general rules.
Have at least 6 characters and a maximum of 8
Must contain at least 2 alpha and at least 1 number
Must differ from the old password by 3 characters
Typically any more than 8 characters is ignored.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 33

The ls command lists the names and the attributes of file(s) and directories. ls accepts more
options than listed above, and will accept as arguments both relative and absolute path
designations. If you supply a file as an argument, ls will display the file's attributes. If you
supply a directory argument, ls will display the contents of that directory. You can combine
options together and typically the order of the options is not significant.
$ pwd
/export/home/student1
The l option is used to display a long listing of the file, including the permissions, owner,
group, size, modification date, and name.
$ ls -l display the contents of the directory student1, listing all attributes
$ ls -ld /opt list directory file called color , not the contents
drwxr-xr-x 2 root system 1024 Jan 10 15:36 opt
The -a option of ls will list all files including hidden files i.e., files that start with a dot.
Remember, hidden file are typically shell configuration files.
The -F option will display a special character after the file to show the file type. A file name
followed by a slash ( / ) is a directory, by an asterisk ( * ) is an executable.
The -R option is to recursively display all directories, subdirectories and files to the bottom of
the hierarchy.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 34

The who command outputs on the screen who is logged in on the system. UNIX is a timesharing system that is capable of having multiple users logged in at the same time. The
commands output gives you all the user login names, the terminal the users are logged in
on, when they logged in. It will even display a user logged in multiple times. This can be
helpful on the control station to determine what users are logged on or if anyone is dialed
into the Control Station. This will also display the host the user is logged in from in the event
they are using telnet, rlogin or ssh.
One variation of the who command is whoami which displays your effective user
identification. The second variation of who is who am i (as three words) which displays your
real user login information, such as login name, terminal, and date and time logged in.

These two variations seem irrelevant at this time but in a later section we will see the
difference between real and effective user ids.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 35

The id command allows you to view the user and group identification numbers during the
interactive session. The identification number is used by the kernel to determine who the
user is and validate that users access to hardware and files. This information is stored in the
file called /etc/passwd.
The command also display the group identification number and name. Groups are a way to
allow multiple users to access a file or a set of files in a directory or allow access to an
application. A user can be a member of multiple groups. A list of all groups is stored in the
file called /etc/group.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 36

The echo command prints its arguments separated by white-space to the terminal screen.
The shell, during interpretation of the command line, will see two arguments. Remember,
excess space on the command line is seen as a single space, and the shell will ignore it. To
keep proper spacing among arguments, quotes must surround the arguments. The quoting
mechanism will tell the shell to interpret everything between the quotes as a literal string.
This means that the shell will see only one argument and pass it to the command echo. If you
want to display a syntax character without interpretation, then surround it in double quotes.
This command is used to display the value of variables, the interpretation of a wildcard, and
in shell scripts, to display text to the screen.
The echo command writes its argument to the standard output. With out the argument it will
just put out an empty line. The echo command is used in shell scripts to show an output to
the screen. It is also used to display the contents of variables. This topic has not yet been
discussed. The echo command writes its arguments to standard output. The echo command
is used in shell scripts to display an output to the screen. For example echo please type yes
to continue.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 37

This command is used to display the system diagnostic messages stored in the system log
files. This command is UNIX specific and is not available in all variants. This command can
also be used to display the world wide names of the HBAs attached to the system and what
world wide names the host is zoned to. The messages file in Solaris is the equivalent of the
event log in windows. The wwpns of the host HBA are needed in order to perform zoning on
the San switches

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 38

The script command is used to make a record of the terminal session that includes all input
and output to the screen. If a filename is not supplied on the command line the default file is
typescript. script creates a subshell that is used to record the session. All input from the
keyboard and output to the console screen are saved to a file. The script is ended when the
user types a ctrl-D at the prompt to end the file. The command is useful when you are
attempting an operation or, for example, an install
procedure which you are not familiar with. The record it provides can help you backtrack and
correct any problems that may have occurred or give the system administrator a reference
point to start troubleshooting.
To append the output to an existing file use the a option.

script a clariioninstall.log
The log script create can be used for validating your installation procedure and
troubleshooting your failed configuration.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 39

file - Used to determine the type of file, either text directory or binary. UNIX has no file
extensions so there is no indication by looking at the file name what commands you can use
with it. Is the file a executable, a log file, a directory? When you dont know file will tell you.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 40

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 41

These are the key points covered in this module. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 1: Unix Operating System 42

These are the module objectives. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems

These are the lesson objectives. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems

In the UNIX file system, files and directories are grouped together by the function that they
perform. The bin directory for example contains binary images (executables), such as the
command passwd that is used to change your password. The directory /usr is where the user
accessible files are stored, the
manual pages for example are stored in /usr/man. The top of the directory hierarchy is called
the root or simply (/). There is only one root directory
unlike Windows which has one on every drive letter. All files and subdirectories are stored
under this hierarchy. It is also very flexible. Directories can be created to store new
application software in a user friendly format.

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems

The dev directory is where UNIX stores the device special files. These files are used to access
the system resources you require. These files must be created in order to use the Clariion or
Symmtrix disks.
The tmp directory is used to store files that you may download over the net. This is not
permanent storage and is clear every time the system boots.

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems

The mode printed under the -l option consists of ten characters. The first character may be
one of the following:
- The entry is an ordinary file.
d The entry is a directory.
l The entry is a symbolic link.
b The entry is a block special file.
c The entry is a character special file.
The next 9 characters are interpreted as three sets of three bits each. The first set refers to
the owner's permissions; the next to permissions of user-group; and the last three are
everyone else that is not the owner or part of the owners group. The permissions are as
follows:
r The file is readable.
w The file is writable.
x The file is executable.
- The indicated permission is not granted.
The second field is the link count, the third is the owner of the file, and the fourth is the
group that the owner belongs to for that file. The fifth filed is the size of the file , the sixth is
the date/time created or modified and the last is the name of the file.

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems

UFS is the default disk-based file system for the Solaris environment.
Journaling does have an impact on performance because it writes all data twice, once to the
journal and once to the file system itself. A journaled file system maintains a journal of the
changes it intends to make, ahead of time. After a crash, recovery simply involves replaying
changes from this journal until the file system is consistent again.
The VxFS files system is now used as HPs primary file system. It is also used by IBMs AIX OS,
Linux, SUN and a number of other Unix operating systems. VxFS is also part of the Veritas
Storage Foundation which also has the Veritas Volume Manager now owned by Symantic.

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems

The mode printed under the -l option consists of ten characters. The first character may be
one of the following:
- The entry is an ordinary file.
d The entry is a directory.
l The entry is a symbolic link.
b The entry is a block special file.
c The entry is a character special file.
The next 9 characters are interpreted as three sets of three bits each. The first set refers to
the owner's permissions; the next to permissions of others in the user-group; and the last
three are everyone else that is not the owner or part of the owners group. The permissions
are indicated as follows:
r The file is readable.
w The file is writable.
x The file is executable.
- The indicated permission is not granted.
The second field is the link count, the third is the owner of the file, and the fourth is the
group that the owner belongs to for that file. The fifth filed is the size of the file , the sixth is
the date/time created or modified and the last is is the name of the file.

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems

The naming scheme for all files are the same, everything in UNIX is a file. Alpha-numerics,
dot, dash and underscore are the only characters to be used in a file name. The following are
examples of valid file names:
junk my.stuff file1 FILE1 this_is_my_file
There are no extensions in UNIX. A file called snow.txt could be a directory. The file called
home.dir could be a program. Remember the dot (.) is just another character in a file name, it
has no special meaning and can appear anywhere in a file name. The only time the dot (.) has
any significance is when it is the first character in a file name. That file is now called a hidden
file. A hidden file does not mean that it cannot be seen. A hidden file is typically a shell
startup file that configures a program environment. The file called .login is run by the C-shell
at login time. The .profile is run by the Bourne and Korn shell at login time. In order to view a
hidden file in a directory listing you must use the ls command with the -a option to see all
files.
$ ls -a
. .. .cshrc
.kshrc .login .profile
FILE1 file1 junk
Characters that are not to be used in a file name are called metacharacters. A file cannot be
named ski*
. Why? The asterisk is a wild card, it will be interpreted by the shell as ski followed by any
number of
characters.

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems

A ordinary or (regular) file contains whatever type of information you place in it. The
operating system does not require any specific format for the data that is being placed there.
The format of the file is left up to the utility program that creates it, for example:
vi stores ASCII text characters
cc compiles an image and stores binary executable data
It is also possible that the ASCII characters stored in the file can be a command procedure
known as a script.
A directory is a file that contains the names of files and other directories (sub-directories)
that are stored there. The directory file also contains a number called an index node or inode
number. This inode number points to data that describe the attributes of a file. The file
attributes are: access permissions, owner, size and location of the file on the disk
In UNIX, everything is a file, even devices. Tapes, disks, memory and terminals are all treated
as files. A special file (or device special file) is the user interface between the operating
system and the hardware. These files are stored in the /dev directory and must be present in
order to access a device.

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems

In the file system, a pathname is a list of the directories and subdirectories that must be
traveled through to reach a specific file or directory. When using a UNIX command you must
notify the command as to where the files to be manipulated are. The directory pathname is
passed as an argument on the command line. There are 2 types of path names full and
relative.
The full or (absolute) pathname defines the directories that must be traveled, starting at the
root, to get to a file or directory. By using absolute pathnames you are able to access any
directory regardless of your current location. Absolute pathnames always start with a /. For
example, the absolute pathname for your home directory in the vmware Solaris environment
is: /export/home/yourusername

Remember the / between export and home then home and your username separate the
directories from the subdirectories and the file. Different directories can have files with the
same name as other directories the only way to distinguish between the is the Full Path.

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems 10

The relative or partial pathnames will allow access to a file relative to where you are
currently located in the hierarchy. The key to using relative paths is knowing what directory
you are currently defaulted to. Your current directory is also known as your current working
directory (or cwd). In the following example, let us assume we are located in the directory
/export.
Absolute path

Relative path

#1 /export /home/john

home/john

#2 /export/home/john/bin

home/john/bin

You will see that the file name .profile is not a unique file name in the directory hierarchy.
The file .profile is relative to the directory it is located in. The difference between the
absolute path and the relative path is that the absolute path always starts at the root
directory or ( / ), and the relative path starts with a file name. The reason for using a relative
pathname is that it is shorter and easier to type. Note: In order to use relative paths
effectively, you must know your current location. The command pwd will display the present
working directory.
The relative or partial pathnames will allow access to a file relative to where you are
currently located in the hierarchy. Your current directory is also known as your current
working directory (or cwd).

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems 11

A directory contains at least 2 files, these 2 files are also directories and are called (.) and (..).
These 2 directories are used with relative pathnames to go up and down the directory
hierarchy. When you log into your system, you are placed in your personal home directory.
This directory will contain . and ..
The dot file always portrays the current directory you are working in. We can use it to
represent the current working directory. You will notice that the dot is redundant when
naming the relative path. That is because the single dot is defined as the current directory,
and the relative pathname begins at the current directory.
Note that we are in the john subdirectory and did a cp command to copy the license file
from our current directory to the /opt/Navisphere/bin directory.

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems 12

The directory .. is a relative path and is defined as the parent directory or the directory one
level above the current directory in the pathname. There can be multiple subdirectories in
one parent, but all the subdirectories have the same parent. If the current directory is
/export/home/john, what is the relative path for /export/home? It is simply ..
The .. in the pathname simply travels up the file system hierarchy one level. If you string
multiples together, using the slash, you can climb 2 or more levels at a time. This is a
convenient alternative instead of using the Full or Relative.

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems 13

These are the lesson objectives. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems 14

The pwd command displays your current directory location as an absolute pathname. When
working on the UNIX system, you will always have a default location in the file system
hierarchy. It is important to verify your present working directory location. When executing a
command, for example a remove, you will remove the file from your present working
directory.

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems 15

The cd command changes your directory location. To move throughout the file system, the
cd command is used with an argument. The argument can be an absolute pathname or a
relative pathname. If the cd command is executed without any arguments then you will
return to your home login directory that is defined in the /etc/passwd file.
$ pwd
/
$ cd ; pwd
/export/home/john
Some of the UNIX shells , POSIX and Korn for example, have additional capabilities that save
typing when moving between 2 directories. This capability comes from the shell which tracks
the directory that you were previously in through a variable called OLDPWD.
$ cd / ; pwd
/
$ cd - ; pwd
/export/home/john
$ cd - ; pwd
/

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems 16

Find searches the file system hierarchy for a list of files that have a particular attribute. A
pathname must be provided as an argument to determine the start of the search, recursively.
Next, an option must be provided to tell find which attribute to search for. The file attributes
are listed whenever you perform an ls command with the -l option. The find command can
list files by type, permissions, owner, group, and size. Files may also be listed by date of
creation, last modification, and last access. Last, an argument must be provided as the object
to be searched for. For example:
$ find / -atime 20 -print access time
$ find /users -group finance -print group name
$ find /tmp -user stu1 -print user name
$ find / -name junk.tmp -print file name
$ find /tmp -size +2 -print size
Search options may be combined to search for multiple file attributes, for example:
$ find / -name chap -user steve -print
After the command find we need to tell the system where to look, here we tell it to look
under the / file system. Since all filesystems are located under / we will look everywhere
on this host. The
-name is the option which tells the host what file name to look for
under /. The -print option tell the system to show the output on the screen. With some
Unix platforms the -print option is not need, it will automatically show the output on the
screen.

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems 17

These are the key points covered in this module. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 2: Unix File Systems 18

These are the module objectives. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands

These are the lesson objectives. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands

The cat command concatenates and prints files. The text of a file or files is displayed on the
terminal screen. The terminal screen is also defined as standard output (stdout). If the text of
a file is larger than one terminal screen, then the text will scroll on the screen until it reaches
the end of file. If you cat multiple files there is no beginning/end of file mark between them.
The files that are printed to the terminal screen will appear in the order that they appear on
the command line. The word concatenate means to combine. If no filename is supplied on
the command line, then the input for the cat command is taken from the keyboard. A ctrl^D
is used to terminate the input from the keyboard, it is known as an End Of File (EOF) mark.
Upon termination of input the typed text will be echoed to the terminal screen. The EOF
mark must be at the beginning of a line. The output to the terminal screen is called stdout.
The input to the cat command taken from the keyboard or a file is called standard input
(stdin).
The cat command will display only ASCII characters to standard output. There are times when
it may be useful to display control characters inside a file. Control characters are invisible
when displayed to the screen. The -v option will display the control characters on the screen.
UNIX also has the capability of compressing files. Compressed ASCII files cannot be viewed
using the cat command. The decompression and subsequent cat command requires a two
step approach. To view the compressed file without the decompress step use the command
zcat. Compressed files in UNIX end with a .Z extension.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands

The more command also has the ability to go forward and backwards in the text, one screen
at a time. The f will move forward and the b backwards. You may also move up and down
lines at a time using j for down, and k for up. The Space bar will also advance the display one
screen of text. The return key
will display the next line. The q command will quit the more command and return the
prompt. By using the help command you will find that the text being displayed can be edited
using vi. You will also find that you can search for text using the forward slash. The search
string must be an exact match. A search for the word , "the" , will find ( the, father, mother,
there, they, etc. ). UNIX is case sensitive, so when performing a search it would not find
"The".

This command functionality has been seen before. Remember when you used the man
pages, and they scrolled pages at a time. The man pages send the output to more to be
paginated. There is additional functionality to the more command. You can get help simply by
typing h while viewing a file with more, or by going to the man page entry for that command.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands

The head command displays the beginning lines of a file. By supplying the option -14 , we
are telling the head command to display the first 14 lines of the file. The default is the first 10
lines of the file.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands

There are a number of commands to use for viewing and processing files. The tail command
is used to display the ending lines of a file. Here we are viewing the last 15 lines of the file
indicated with the option -15. The default is the last 10 lines of the file.
When a program it in the process of writing a file you may wish to see the the contents of the
file while it continuously grows. This would be useful when observing a program error log
file.
The -f option, (f for follow), forces tail to continue to execute and display every new line as it
is appended to the file. The shell prompt will not be returned until you terminate the tail
output using a ctrl^C.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands

cp will make a copy of a file or an directory. The source file, is the object that you wish to copy.
The destination can be a file name or if you want to move it to a new location, a directory. If the
destination is a file, and it does not exist, the copy command creates the destination. If the
destination is a file that already exists, cp will overwrite the file. Users must be cautious when
using this command , cp gives no warning if it is about to overwrite a file. A commonly used
option to the cp command is -i, which gives an interactive warning that the destination file
exists, and asks for verification to overwrite the file. If the destination is a directory, the source
file is moved to the new destination and is given the same name.
$ cp -i /kernel/drv/sd.conf /save
overwrite (y/n)? y will overwrite the file, n will not, no answer is interpreted as no
To recursively copy an entire directory structure, the -r option can be used with the cp
command. For example, the following command will copy the directory /kernel/drv and all files
and subdirectories to the new directory /tmp:
$ cp -r /kernel/drv /tmp
The copy command can be used to change the file name when copying. The following
command will copy the /etc/passwd file to your home directory and call it passwd.old.
Remember to copy any customer file before you modify it.
$ cp /etc/passwd /export/home/steve/passwd.old
One additional option is the p . It is used to preserve the current owner and permission on the
source file when copying to another location.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands

mv can rename and/or move files between directories. This command does not perform a
copy operation. The source file will no longer exist under the original name, because it has
been moved. When moving source files and the destination does not exist it will be created.
If the destination does exist, it will be overwritten. The mv command gives no warning if it is
about to overwrite a file. A commonly used option to the mv command is -i, which is an
interactive warning that the destination
file exists. If the destination is a directory, the file will be moved into it. Users must be
cautious when moving files, so they do not overwrite existing files. When moving a directory,
it is recursive, all files and subdirectories move with it.
Question: What would happen if you attempt to move a directory to a directory that already
exists? Will it be overwritten?
mv - Moves file from one location to another or from one name to another. In most Unix or
Linux platform this is the rename command.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands

rm will remove file(s), confirmation of the remove is not required. Once a file is removed,
there is no way to retrieve the file, unless the system administrator has the file on a backup
tape. The -i option can be used to make the rm command interactive, and force the user to
verify if a file is to be removed.
$ rm -i log1 log2
log1? y
log2? n
$ ls -F
log2 dailylogs/

The -r option can be used with the rm command to recursively remove subdirectories and all
files contained in those directories. For example:
$ rm -r dailylogs recursively removes the dailylogs directory
The -f option to remove is for force, when forcing a remove the user will not receive any
warning messages. The -r option can be used to remove non-empty directories. PLEASE
USE CAUTION because this command will delete everything in the specified directory and
below!

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands

A symbolic or soft link will access a file through the filename, not the inode number, as in a
hard link. A softlink uses a filename pointer to access the data rather than the files attributes.
The softlink will also allow us to link to directories.
Soft or Symbolic links
Can link a file on one disk to a file on another disk.
Directories can be soft linked
Creating a symbolic link has no effect on the link count
If the source file is deleted, the soft link exists but the file it points to is gone.
ln -s /opt/Navisphere/Navicli/bin /navi Creates the softlink called /navi

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 10

The mkdir command is used to make directories. Users can create as many subdirectories
that they want in order to better organize their files. Two special directories are created
every time a mkdir command is issued, the . (dot) and .. (dot) (dot) directories. When
making a directory you must specify the absolute or relative path of the directory that is
being created. All the directories must exist except for the last one in the path, the one to be
created. In this example the directory junk does not exist
$ mkdir junk/car
junk: file does not exist
To successfully create both directories in the path use the -p option.
$ mkdir -p junk/car

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 11

This command will remove a subdirectory provided that it is empty. If you wish to have it
removed in a different directory you must specify which directory in the command. The
following example will remove the student subdirectory under the joe. In order to remove a
directory it must be empty. There can be no files in it other than . and ..
[root@linux1 root]# rmdir /export/home/joe

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 12

The diff command will compare multiple files and will output relative differences between
those files. diff can compare both file and directory contents.
When comparing files the output of diff will display the smallest set of differences between
the two files. The greater than (>) and less than (<) symbols denote which file must be
modified to make the two file equivalent. The less than (<) refers to differences in the first
file in you command string. The greater the (>) references differences in the second file. The
line numbers where the differences are located are separated by a letter. Theses letter
denote the type of difference: For example c meanschanged, d means deleted and a is
appended. The -i option can be used to ignore uppercase and lowercase differences.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 13

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 14

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 15

These are the lesson objectives. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 16

vi is a program like all other UNIX commands. It was written at the University of California
Berkeley. It is an interactive editor designed for video screen environments. It was also
designed to be terminal independent, where all commands are mapped to the standard
keyboard. This philosophy enabled its use across numerous terminal types and UNIX variants.
The changes you make to a file are based on cursor position. All insert, delete, cut and paste
functions occur relative to the cursor position inside the file.
vi commands are all 1 and 2 characters in length and are not echoed to the keyboard, once
the command is recognized it is executed, there is no carriage return required.
When you start a vi session you are placed in command mode, the keys of the keyboard are
assigned to different vi functions. Some commands will place vi into input mode where your
keyboard is now used as a standard typewriter and is used to enter text into the file. To exit
input mode simply press the esc key, this will return vi to command mode.
Exiting vi will be covered later in this

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 17

You can invoke vi using the name of an existing file or a newfile you what to create. If the
file exists, the lines are displayed to the screen. If there is not enough lines to fill the
screen, all lines that do not containing characters will be filled with a (~) in the first
column. The tilde is indicative of an unused line. The last line of the screen will
contain the file name, the number of lines in the file, and the number of characters in
the file.
If the filename invoked is a new file the first line on the screen is blank, the rest of the
lines will contain a tilde to indicate an unused line. When vi is started, a copy of the
file is placed into a temporary memory buffer to be edited. All the modifications to
the file will be made to this temporary file in memory. When editing is completed the
contents of this buffer will be saved to the disk. The file is not saved until you write is
to the disk. Because vi uses this temporary buffer the changes do not have to be
saved and can be ignored.
Note: vi does contain a set of keyword variables to aid in the use of vi. These variables
must be set in order to be effective. This is performed at the exit (:) prompt, one
variable commonly used is called showmode. This variable will display on the screen
the message input mode, when the keyboard is not in command mode. To set this
variable type
esc
:set showmode return

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 18

The cursor movement is performed by the use of the h, j, k, l, keyboard commands. Most
users like touse the up and down arrow keys, these are supported in most vi environments,
however with a little memorization and practice you should be able to adjust to keyboard
keys. As shown in the overhead, if a vi command, such as G, is prefaced with a number the
cursor will move to that line position.
Note: The vi editor is case sensitive and the use of uppercase and lowercase for the same
letter will provide different results.
In a later module we will discuss command line editing. Editing of the command line is
typically based on the vi editor. During command line editing you will be tempted to the
arrow keys for cursor movement. They will fail in most environments. You should become
familiar with the h, j, k, and l keys.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 19

All of the above commands with the exception of the (r) will place vi in input mode. If the
variable showmode is set, the words input mode will be displayed in the bottom right corner
of the screen. The only way to exit input mode is to hit the esc key. In input mode the
keyboard is used as a standard typewriter, if there is a need to erase a character the
backspace key will remove characters from the current input session. If there has been
multiple input sessions the backspace key will only remove keys to the beginning of the
current session. Why does vi have two ways of inputting text on a line? The i will insert text in
front of the cursor. This is useful when the cursor is at the beginning of a line, but, what if the
cursor is at the end of the line and you wish to insert text after the cursor. The input
command will not work. This is where the
use of the a for append becomes apparent. This also holds true for opening a new line. It
may be necessary to open a line before the first line, (capitol O ), or below the last line (
lowercase o ).

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 20

vi has the ability to delete words, line, entire sections of text. Once the text is removed it is
stored to a buffer that can be recalled. This capability is defined in most editors as cut and
paste. The commands for cut and paste will be covered on the next page. The key letter for
deleting text is d. It can be combined with other characters to perform complex delete
operations. For example dG, will delete text from the current cursor position to the end of
the file. The command d$ will delete text from the cursor to the end of the line. In the event
that you remove text inadvertently, it can be restored. The undo command will undo the last
file modification, only the last modification, i.e. it is a toggle mechanism. If the command
10dd was issued, the u will replace the 10 lines, another u will remove it again. If a 10dd is
followed by an
(x) to delete one character, the (u) will only undo the (x) command. Why? Because it was the
last file modification.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 21

The yank commands are similar to a copy command. Text that is yanked is stored to a buffer
to be replaced somewhere else in the file. If you perform multiple yank commands only the
last yank can be retrieved.
The paste commands will paste in whatever text is yanked or deleted. If lines are yanked,
then the lines will be pasted after the current line of text. If words are deleted or yanked,
then words will be pasted on the same line after the cursor. If you delete ten characters (10x)
then paste will paste 10 characters.
The paste command will paste multiple times. Caution paste will leave the cursor at the
beginning of text pasted, not at the end.
For those seeking the ability to use multiple delete and yank buffers, there are 26 named
buffers a-z. To delete 10 lines to buffer f type the command f10dd , to paste from this buffer
use the command fp

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 22

The dot command is very useful for repeating the last modification. If you delete 10 lines
with the command 10dd, the dot will repeat the delete each time it is depressed. If the last
modification was a delete to the end of the line, then it is repeated.
These commands will allow you to modify text in the file. The (cw) command will place a $ at
the end of the word as a place holder. If the changed word is longer than the current word
the line is expanded to fit the new word. If the changed word is smaller the line will be
truncated to fill the extra space. To stop the insertion of text type the escape key.
Using x and p commands, you can transpose two letters in a word spelled incorrectly. For
example these place the cursor on the e and delete the character. The cursor is now under
the s using the lowercase p will pasted the e after the current character.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 23

Pattern searching works well, however please remember that UNIX is case sensitive and if
you search for the pattern /one vi will find the words none and phone etc. If you search for
space one space in the following example it will not find one at the beginning of a line or at
the end of the line. For example;
/ one
Note: Pattern matching is exact match only, be careful what you ask for!
The lower and uppercase ns will allow the user to search for the next occurrence of the
string in the file. The lowercase for forward searches and the uppercase for backwards
searches. Both commands will autowrap and continue at the bottom and top of the file
respectively. The searching mechanism is useful in finding a value that needs to be replaced.
Once the value is found you can use the cw command to change the string. If you press
another n command the search will continue in the file. To replace the word a second time,
simply use the dot.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 24

When you complete making changes to the file, remember to save the buffer contents to the
disk. To save the file you must be in command mode, to enter command mode type the esc
key, followed by the appropriate exit sequence. For example, either
esc
ZZ
esc
:wq return
Note: Remember to periodically save your file, in the event of a powerfail the contents of the
buffer can be lost with all the modifications.

You can choose not to save the contents of the file when you exit. However, if the memory
buffer has been modified, vi will not allow you to exit using the q command. To force vi to
exit without saving the buffers you must use q!.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 25

Notepad is a basic text editor the user can use for simple documents, scripts or for creating
Web pages. To create or edit files that require formatting, use WordPad.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 26

Commands executed through the menu or CRTL keys


COMMANDS
CTRL + N Creates a new file
CTRL + O Open a file
CTRL + S Save the opened file
CTRL + P Print the opened file
CTRL + Z Undo change
CRTL + X Cut text selection
CTRL + C Copy text selection
CTRL + V Paste text selection into the file
DEL Delete character
CTRL + F Find string
F3 Find next occurrence of the string
CRLT + H Find and replace a string
CRTL + G Go to a specific line of the text
CRTL + A Select all lines of the text

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 27

Edit is the MS-DOS Editor, which creates and changes ASCII text files.

Used without parameters, edit just starts MS-DOS Editor.


edit [[Drive:][Path] FileName] [/b] [/g] [/h] [/nohi]
Where:
[Drive:][Path] FileName
Specifies the location and name of an ASCII text file. If the file does not exist, MS-DOS Editor creates it. If the file exists, MSDOS Editor opens it and displays its contents on the screen.
/b
Displays MS-DOS Editor in black and white. Use this command-line option if a monochrome monitor does not display MSDOS Editor correctly.
/g
Uses the fastest screen updating possible for a CGA monitor.
/h
Displays the maximum number of lines possible for the current monitor.
/nohi
Enables you to use eight-color monitors with MS-DOS Editor. Typically, Windows XP uses 16 colors.
/?
Displays help at the command prompt.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 28

Home Move to the start of the current line


End Move to the endof the current line
Ctrl + Up Scroll up one line
Crlt + Down Scroll down one line
PageUp Scroll up one screen
PageDown Scroll down one screen
Ctrl + PgUp Scroll left one screen
Ctrl + PgDn Scroll right one screen

Ctrl + Home Scroll to the start of the document


Crtl + End Scroll to the end of the document
Ctrl + Left Move left one word
Ctrl + Right Move right one word

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 29

SELECT REGIONS
Shift Use the shift key in conjunction with the cursor movement functions to select regions
CTRL + C Copy the current selection to the buffer
CTRL + X Delete the current selection and copy it to the buffer
Delete Delete the current selection
Tab Indent the selected lines
Shift + Tab Unindent the selected lines
FINDING AND REPLACING TEXT

CTRL + Q + F Find text


CTRL + Q + A Find text and replace it.
F3 Repeat the last search

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 30

6. Exit insert mode and copy this line and paste it to the last line of the file 5 times.
7. Go to line 1 of the file and search for the word love using the /
8. Using the cw command change the word love to hate.
9. Search for the next appearance of the word but dont change it. Search for the 3 rd
appearance of the word hate and change it.
10. Delete the 5 lines you just added for the file using dd. Go to line 1 and paste them above
the cursor
11. Go to line 3 and replace the exclamation point with a question mark. Use r to replace 1
character

12. Save the current contents to the file myfile.new. In other words to a save as but do not
exit vi.
13. What file are you editing now the old one or the new one?
14. Exit the vi editor and dont save the changes/

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 31

These are the key points covered in this module. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 3: Unix File Commands 32

These are the objectives for this module. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands

These are the objectives for this lesson. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands

id is used to view the user and group identification numbers during the interactive session.
Thevcommand will show you a user identification number, which is used by the operating
system to determine user identity during file access. The username and uid number are
stored in the /etc/passwd file.
The id command will also display the group identification number for the user, and the group
name. Groups are used as a way to allow multiple users to access a file or set of files in a
directory. Groups are created and maintained by the system manager, and a list is stored in
the file /etc/group. A user can be a member of many groups and the groups are typically
defined by the department the users work in. For example; engineering, finance, shipping
etc.

Groups are not handled the same in all UNIX environments. In some environments a user can
only be an active member of one group at a time. In other environments a user is an active
member of all groups simultaneously. UID is the Users identification number and GID is

the Group identification number.

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands

The who utility can list the user's name, terminal line, login time, elapsed time since
activity occurred on the line, and the process-ID of the command interpreter (shell) for each
current UNIX system user. The following operands are supported:
am i
am I In the C locale, limits the output to describing the invoking user, equivalent to the -m
option. The am and i or I must be separate arguments.
For more information pertaining to this command such as options and arguments, use the
Online Manual by typing the following command:

man who

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands

Information about the users are kept in 3 files, they are used by the login program to
authenticate users and set up their environment. The first is the /etc/passwd, the second is
the /etc/shadow and the third is the /etc/group file. The password file contains seven fields
of information pertinent to a users login environment.
The first field is the username, which is associated with the user identification number from
field 3. This is how the system identifies the user for all file access and file execution
permissions.
Field two is the encrypted password. The passwords in most environments are between 6
and 8 characters. They will encrypt to 13 characters regardless of length. For example, you
may see the word nologin, this will disable the account. If there is no encryption and no
characters in this field, then the account has no password. The password is changed with the
command passwd.
The third field is the user identification number. This is the value associated with the
username.
The fourth field is the group identification number, which sets the user login default group.
Groups allow the system administrator to assign permissions for a resource to a large
number of users at a time. The user can belong to multiple groups.
The fifth field is the finger information. The field typically contains any information about the
user. For example, the first name, last name
The sixth field is the users home directory. It is the directory the user will be placed in login
and when the user runs the cd command.
The seventh field is the shell that is started by default when the user logs into the UNIX
system. There are many possibilities including the Korn, Bourne, C and POSIX shells.
Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands

/etc/shadow is an access-restricted ASCII system file that stores users' encrypted passwords
and related information. The shadow file can be used in conjunction with other shadow
sources, including the NIS maps passwd.byname and passwd.byuid and the NIS+ table
passwd. The fields for each user entry are separated by colons. Each user is separated from
the next by a newline. Unlike the /etc/passwd file,
/etc/shadow does not have general read permission.
The fields are defined as follows:
First: The user's login name (UID).
Second: An encrypted password for the user generated by pwconv from the /etc/passwd file.

Third: last change, the number of days between January 1, 1970, and the date that the
password was last modified.
Fourth: The minimum number of days required between password changes.
Fifth: The maximum number of days the password is valid.
Sixth: Warn, the number of days before password expires that the user is warned.
Seventh: Inactive, the number of days of inactivity allowed for that user. This is counted on a
per machine basis; the information about the last login is taken from the machine's last log
file.

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands

The /etc/group file contains four fields.


The first field is the group name. This identifies a set of users to the system to be treated as
one entity. This allows permission to be set for multiple users without the need of individual
fields.
The second field is the password field. It is of historical significance and is not used in this
environment.
The third field is the group identification number. It is associated with the group name, and is
used by the operating system to identify the group.
The fourth field is the member list. This is a comma separated list of users that are members
of the group. The list can continue indefinitely.
Information about the users are kept in 3 files, they are used by the login program to
authenticate users and set up their environment. The third is the /etc/

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands

su is an acronym for substitute or switch user. su will let you substitute your user id number
to that of another user, by logging into a users account. In order to gain access to a users
account, a password must be supplied. Then a sub-process is created for you, so you can
enter commands as this new user.
The user environment will not change, this command does not run the new users login
scripts. To end the session type a ctrl-D and you will return to the original process. If the
username is not provided after the su command is issued, then you will be switched to the
system administrators account. Of course, you must know the root login password in order
to gain access to the account.
What is the difference between the su and the su - commands? It is simple, the difference is
that su - runs the login scripts for the user and the environment now reflects that of the new
user. You will notice that the command appears to log the user into the system. It does not,
instead it starts a child process to handle the pseudo login and runs the users environment
files to set up the system variables and aliases

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands

UNIX uses 3 classes of users to determine who has access to a particular file. The first of
three classes is called the user, or simply u. The user is the owner of the file. It is determined
by comparing the user's uid in the /etc/passwd file against the uid stored in the files inode.
The second class is that of the group, or g. The group is a set of individuals that are to have
access to a file. Rather than limiting the access to a single person on the machine the group
can be as small as one user or as many as the system manager requires. The groups that are
defined on the machine and its members are listed in the file called /etc/group.
The last class of user is other or o. Other is defined as any user id that is not the owner of the
file or does not belong to the group that is stored in the files inode. The other class of user
could be anyone on the Internet.

The ls -l command will be used to display the owner and the group associated with the file.

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands

User Name or Login ID


It contains the identification required by the system for a successful log in. Depending on the
system administrator, login IDs are usually some combination of a users first and last names.
For example, user John Does login ID might be johnd, jdoe or doej.
Unix systems
Login ID must be unique.
Accept a limit of 8 alphanumeric characters entered in lowercase.
Windows systems
Up to 20 characters of length
It must be unique to the domain or computer being administered.
It can contain any uppercase or lowercase characters except the following: " / \ [ ] : ; | = , +
*?<>
A user name cannot consist solely of periods (.) and spaces.

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands 10

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands 11

Within Unix and POSIX systems, membership in a group establishes one level of privilege.
Group membership is also often used to control or limit access to system resources. A user
can only be a member of one group at a time.
To make a new group requires adding a record to the /etc/group file, assigning the group a
unique ID. The usermod command lets a system administrator change the group that a user
belongs to.
In Windows NT user manager, a group is an account that contains other accounts, which are
called members. Permissions and rights granted to a group are also provided to its members,
making groups a convenient way to grant common capabilities to collections of user
accounts.

4 default groups (Administrators, Power Users, Users, and Backup Operators)


3 special groups (Interactive, Network, Terminal Server).
To associate a user to a group:
Click Start, point to Programs, point to Administrative Tools, and then click Active Directory
Users and Computers.
In the Details pane, right-click the applicable user account, and then click Properties.
In the Properties dialog box, click the tab and associate the account to the proper group.

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands 12

These are the objectives for this lesson. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands 13

File access The default permissions for a file are: Owner rw- or an octal 6. For the Group it
is r- - or an octal 4. Other is also r- - or an octal 4. Read permission means you can view its
contents. Write permission means you can alter its contents. Execute permission means
you can run the file as a program.
Directory access - The default permissions for a file are: Owner rwx or an octal 7. For the
Group it is r- x or an octal 5 and Other is also r- x or an octal 5. Read permission means you
can list its contents. Write permission means you can create or remove files and directories
in that directory. Execute permission means you can change to the directory using the cd
command.

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands 14

The chmod command can manipulate permission using a 3 digit octal number which
represents the files mode will be used. Each permission bit carries a binary weighted value.
4=read
2=write
1=execute
If you require read and write permissions, 4 + 2 = 6. If read and execute are required, 4 + 1 =
5. In UNIX, there are 3 classes of users and the permissions can be changed using one octal
digit for each class of user.
$ chmod 750 filename

The hundreds digit is associated to the user class permission, 4 + 2 + 1 = 7, provides read,
write and execute permission for the owner of the file.
The tens digit is associated to the group class permission, 4 + 1 = 5, provides read and
execute permission.
The ones digit is associated to the other class permission, 0 = 0, provides no permissions.

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands 15

The chgrp command is used to change the group that is associated to a file. The group name
must exist in the /etc/group file, and only the owner of a file can change the group for a file.
The names of the groups and the members of those groups are maintained by the system
administrator.
You must be a member of the group that you are associating the file to. To list the groups
that you are a member of use the groups command, or cat the /etc/group file. The groups
command does not exist in all variants of UNIX.
$ cat /etc/group
system::0:root,admin
The option -R will change the group owner of directory and all of its files and subdirectories
Arguments: new_group filename or directoryname
Syntax: chgrp -options new_group filename

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands 16

The chown command is used to change a files ownership. Only the owner of a file, or root
can change the files ownership. Once the ownership of a file has been changed, only the
new owner or root may change it back.
The only valid owners are listed in the /etc/passwd file. If you attempt to change ownership
to a username not listed there you will get an error message.
If you copy a file from another user, who owns it once it is copied? You do! The copy
command changes the ownership during the copy operation.
In some UNIX variants, it is possible to change both the owner and group identifiers using the
chown command. Options: -R Change the owner of a directory and all of its files and
subdirectories
Arguments: new_owner filename or directoryname
Syntax: chown -options new_owner filename

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands 17

Users must enter a password to prove their identity Security. A user must provide a user
name and password to gain access to a computer of the network or to any resource on that
computer.
Password Change
When an account is issued, user will be given an initial password.
It is important for system and personal security the password for the account be changed to
one that
the user chooses.
Passwords can be the weakest link in a computer security scheme. The application of strong
passwords is very important because of the continuous improvement of cracking tools, since
these software tools use one of three approaches: intelligent guessing, dictionary attacks,
and automation that try every possible combination of characters.

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands 18

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands 19

Changeable code assigned to a user account and known only by its owner.
Passwords are case sensitive.
Password should be typed exactly as issued.
For a password to be strong and hard to break, it should:
Be at least seven characters long.
Contain characters from each of the following three groups:
Letters (uppercase and lowercase) A, B, C,...; a, b, c,...
Numerals 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Symbols (all characters not defined as letters or numerals) ` ~ ! @ # $ % ^ & * ( ) _ + - = {} | [


]\:";'<>?,./
Have at least one symbol character in the second through sixth positions.
Be significantly different from prior passwords.
Not contain your name or user name.
Not be a common word or name.

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands 20

1. Use vi to edit the /etc/passwd file and add a user account to your vmware solaris
environment, it should look like the root account. Make your uid anything between 100
and 1000. your group id will be 1, the group called system.
2. Create a home directory for your user account, in Solaris it must reside in
/export/home/yourusername
3. Edit your username into the /etc/group file
4. Create the entry in the shadow file for your account. You may need to consult the man
pages on creating this entry
5. Copy files from the skeleton directory into you home directory and change them so you
own them and they belong to your group. Where is the skeleton directory? You have the
ability to find it.
6. Can you copy them without having to change the user ownership once they are in the new
location in your home directory.
7. What is the command to create new user account described above, without having to edit
any

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands 21

Copyright 2012 EMC Corporation. All rights reserved

Module 4: Unix Users Commands 22

These are the module objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells

These are the lesson objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells

The shell is a program designed to interface between the users and the operating system
(kernel) image. The shell displays a command line prompt, typically a dollar sign, at the
terminal and waits for interactive user input. Every time a command is typed and the return
key pressed, the shell attempts to parse the command line and pass the interpreted
command to the kernel image for execution. There are many features to the shell that will be
discussed in this chapter.
Command line interpreter - Analyzes the command line, its arguments, expands syntax and
passes the command to the kernel
Variable substitution - Assigns values to variables and allows the variable use on the
command line

File name substitution - Interprets the use of wildcards, the * , ?, and [], before execution
I/O redirection - Allows the input, output and error output to be channeled to a file
Pipelines - Connects the standard output of one command to the standard input of another
Command substitution - Use the results of a command on the command line
Alias creation - Creates a pseudo name for command or command strings
Programming language - Testing of strings, numbers and files; Decisions and branching
capabilities with if-then-else and looping constructs.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells

The Bourne shell is the standard shell that is distributed with any AT&T/System V version of
UNIX. The shell can execute commands from a terminal or the commands can be stored in a
file for a batch execution, called a script. It is also a programming language and a command
line interpreter. It does however, lack some of the elegance of the other shells. For example,
there is no aliasing capability,
nor the ability to perform command line editing.
The Korn shell is a superset of the Bourne shell, that is it has all the Bourne shell features,
plus command line editing and command recall etc. It also contains the aliasing, history and
job control capabilities.
The C shell contains many of the same features of the Korn shell but was created for the BSD
variant of UNIX produced at the University of California, Berkeley. The C shell is known for its
C language like syntax and capabilities, however it lacks a easy to use ability of command line
editing.
Bash is the shell that will appears in some UNIX operating system variants. Bash is an shcompatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh).
It is POSIX compliant and has many improvements of sh.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells

The sh (Bourne shell) is a standard shell and command interpreter. The sh utility is a
standards compliant shell. This utility provides all the functionality of ksh (korn shell), except
in cases where differences in behavior exist.
This slide shows the login shell, which is a ksh or Korn shell. The sh command opens a Bourne
shell. Note that users can have different types of shells open simultaneously.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells

The C shell is a command interpreter with a syntax reminiscent of the C language. As with the
Bourne shell, the C shell has variable, command, and filename substitution.
However, it has a number of convenient features that are not available in the Bourne shell,
including filename completion, command aliasing, history substitution, job control, and a
number of built-in commands.
This slide shows a login shell, which is a ksh or Korn shell. The csh command opens a C shell. This shows again that users can
have different types of shells open simultaneously.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells

The Korn shell is a shell which was developed by David Korn in the early 1980s. It is
backwards compatible with the Bourne shell and includes many features of the C shell as
well, such as a command history.
The main advantage of ksh over the traditional Unix shell is in its use as a programming
language. Since its conception, several features were gradually added, while maintaining
strong backwards compatibility with the Bourne shell.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells

Bash is intended to be a conformant implementation of the IEEE POSIX Shell and Tools
specification. When bash is invoked as an interactive login shell, or as a non-interactive shell
with the --login option, it first reads and executes commands from the file /etc/profile, if that
file exists. After reading that file, it looks for bash_profile, ~/.bash_login, and ~/.profile, in
that order, and reads and executes
commands from the first one that exists and is readable.
When an interactive shell that is not a login shell is started, bash reads and executes
commands from ~/.bashrc, if that file exists. If bash is invoked with the name sh, it tries to
mimic the startup behavior of historical versions of sh as closely as possible, while
conforming to the POSIX standard as well.

When invoked as an interactive login shell, or a non-interactive shell with the --login option,
it first attempts to read and execute commands from /etc/profile and ~/.profile, in that order.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells

These are the lesson objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells

The alias command is shorthand notation provided by the shell to allow the user to create
new commands for long command lines in the environment. The shell maintains a list of all
aliases that are created and will replace the shorthand command with the alias whenever it
is encountered on the command line.
There are times when aliases are just easier to use than the command you wish to type. For
example, the ls -la | more can be shortened to lsm. The alias command is followed by the
shorthand notation for the new command. It is then followed by the command string it is
going to apply to the alias. If the command string to be replaced should contain spaces it will
have to be enclosed in double or single quotes. Remember you are assigning a string of
characters to the alias; this string include spaces. The alias command will not assign multiple
arguments to the name.
The shell will perform all the normal command line processing and replace the alias with the
string assigned to it. The alias will appear to the shell as any other command and will be
parsed accordingly. When the user logs out the aliases are lost. Aliases are stored in local
memory by default and are not saved or passed from the parent process to the child. If you
would like an alias to be kept from session
to session, you must store it in one of the shell startup files, .cshrc for C-shell or .kshrc for
Korn or .bashrc for Bash.
unalias pattern removes the alias definition

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 10

Aliases are commonly used for a long strings that are frequently used. Alias lets you have a
smaller more familiar command or a name to execute a long string of commands. These
options are typically set in your Korn shell environment file ($HOME/.kshrc). Unlike the C
shell the ksh requires an equal (=) sign between the alias name and the value assigned to it.
The alias and unalias utilities create or remove a pseudonym or shorthand term for a
command or series of commands, with different functionality in the C-shell and Korn shell
environments. If the value includes spaces, you must enclose the entire value in quotes
("string and rest of string").
ksh
alias [-tx] [ name [ = value]...]
unalias name...
The following option is supported by unalias:
-a Removes all alias definitions from the current shell execution environment.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 11

These are the lesson objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 12

Options:
ignoreeof - Do not exit using <cntrl d>, type exit.
noclobber - Do not overwrite an existing file when using I/O redirection (>). Override using
the pipe symbol after the I/O redirection symbol (>|)
In order to perform command line editing the shell must know the editor you wish to use in
order to modify the shell history file, (.sh_history) . The command to use is set o vi.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 13

DO NOT use the arrow keys remember you are in vi on your keyboard to move the cursor
along a command line. Use the k or j keys to move backward and forward through the history
list. You are using vi command to edit the line. The letter x will delete a character and r will
replace one. To shift left and right on the line use h and l.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 14

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 15

csh
Display the history list. If argument n is given, display only the n most recent events.
-r Reverse the order of printout to be most recent first rather than oldest first.
-h Display the history list without leading numbers. This is used to produce files suitable for
sourcing using the -h option to the csh built-in command, source.
To turn on the command line history feature you must specify the number of commands to
be stored (set history = #). Default = 1. You can place this command in the .cshrc file.
Commands:
set history=# Enable history feature and store commands
History
Display list of stored commands
!<char>
Re-execute command from list that begins with <char>
!#
Re-execute a particular command by recalling its event number
!!
Recall the last you command you issued
^old^new
Modify the previous command and re-execute it (abbreviated form)
!!:s/old/new Re-execute the previous command, substituting new for old

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 16

To turn on the command line history feature you must specify the number of commands to
be stored (set history = #). Default = 1. You can place this command in the .cshrc file.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 17

At login, .cshrc is read first, then .login! The .login file is read once at login time and the
.cshrc file is read every time a C shell starts up.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 18

Linux Command Line History options:


history [n]
history -c
With no options, display the command history list with line numbers. Lines listed with a *
have been modified. An argument of n lists only the last n lines. If filename is supplied, it is
used as the name of the history file; if not, the value of HISTFILE is used.
Options, if supplied, have the following meanings:
-c Clear the history list by deleting all the entries.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 19

By using the up arrow key Linux will recall the last command in history. By continuing hitting
the up arrow key history will recall the previous command. The down arrow key will reverse
the command recall.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 20

All processes in the UNIX environment must run in memory. When a program is started areas
are set aside to hold the executable image, the local variables and the environment or global
variables. The purpose of these variables is twofold. Some are used to modify just the
current program, while others are passed from program to program in what UNIX refers to as
a parent child relationship. In this
module we will discuss the parent child relationship and the users ability to modify the
existing shell environment to fit his/her personal tastes. The user environment is made up of
variables that define the:
Home directory
The terminal type
The shell that is being executed
The search path used to find an executable image
What the shell prompt is set to
The current working directory
The user environment can be customized at any time, for any application. To make the
customizations available every time you log in they must be placed in a user login profile.
This file is called .login for the C-shell and .profile for Korn and Bash shell.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 21

The user environment can be manipulated from user to user. It can be changed to fit the
individual's needs and capabilities on a given machine. As you can see from above, the
environment, and its variables can be reassigned at any time. The modifications that you
make remain intact only until you
logout, at which time your changes will be lost. To keep these changes, login after login, you
must save them in a environment file. Many of your settings are stored in the file .kshrc .
The .kshrc lists all the parameters that you would like to keep and changes you have made to
your environment. This file is run at login time to recreate customizations you have made.
Changes can be made to this file with an editor. The set command will list the environment of
the shell at that point in

time. The information to the left is a variable. All information to the right is the data that is to
be assigned to the variable.
There are 3 files that the user can customize in the C-shell environment. They are /etc/profile
.profile and .kshrc .

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 22

There are many other global variables, including the current directory (PWD), the shell
(SHELL), and the terminal type (TERM).

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 23

After you make changes to your .profile file you can log out then log back in to the system to
have the changes take affect or you can run .profile with the . (dot) command (. .profile). The
dot (.) command is a shell command that takes a file and causes your current shell to read
and execute the commands in it.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 24

The user environment can be manipulated from user to user. It can be changed to fit the
individual's needs and capabilities on a given machine. As you can see from above, the
environment, and its variables can be reassigned at any time. The modifications that you
make remain intact only until you logout, at which time your changes will be lost. To keep
these changes, login after login, you must save them in a environment file. Many of your
settings are stored in the file .cshrc .
The .cshrc lists all the parameters that you would like to keep and changes you have made to
your environment. This file is run at login time to recreate customizations you have made.
Changes can be made to this file with an editor. The set command will list the environment of
the shell at that point in time. The information to the left is a variable. All information to the
right is the data that is to be
assigned to the variable. The setenv command will list the environmental variables. There are
3 files that the user can customize in the C-shell environment. They are .login .cshrc and
.logout .

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 25

Global variables also include the current directory (pwd), the shell (shell), and the terminal
type (term) along with many others. Notice that in the C shell the varaibles are in lower case,
whereas in the Korn shell they are in the upper case.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 26

Shown here after changing to the /kernel/drv directory, we used the $HOME variable with
the cd command to get back to the / directory. A variable can be used on any command line
simply by preceding it with a dollar sign ($). The dollar sign forces the shell to perform a
function called variable substitution. It replaces the variable on the command line with the
data stored in it.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 27

Any command that sends output to the terminal screen by default can have its output
redirected to a file using the > and >> symbols. When the shell recognizes the > symbol on a
command line, it knows to create the file name which follows this symbol. Unfortunately, if
that filename already exists, then it will be overwritten with no questions asked. When the
shell recognizes the >> symbol on a command line, it knows to either create the filename
which follows this symbol (if it does not already exist), or to append output to the bottom of
this file. Using the cat command you can combine multiple source files into one destination
file, this is known as concatenation.
Note: Under the C and Korn shells, precautionary measures can be taken so that files will not
be overwritten if the > symbol is used. The shells have the ability to test for the existence of
a file before any creation attempt, using a shell variable called noclobber. The following
commands can be typed in at the prompt..
C shell

$ set noclobber

Korn shell

$ set -o noclobber

To override noclobber

$ cat >| filename

$ unset

noclobber
$ set +o noclobber

These are only good for the users current session, they will be reset after logout. If you wish
for them to be permanent, they must be entered into the .kshrc or .cshrc startup files.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 28

Any command that sends error messages to the terminal screen by default can have its error
output redirected to a file using the 2> or 2>> symbols. When the shell recognizes the 2>
symbol on a command line, it knows to create the filename which follows this symbol.
However, if that file name already exists, then it will be overwritten with no questions asked.
When the shell recognizes the 2>> symbol on a command line, it knows to either create the
filename which follows this symbol (if it does not already exist), or to append errors to the
bottom of this file.
Note: It is also possible to redirect standard output and standard error to the same file using
the following syntax, 2>&1.
The redirection of error output is very useful when you are submitting command procedures
to the background, or when using the system batch queues. The file will contain the error
that occurred while the procedure was running overnight. This will aid in the recovery or
modification of your command procedure.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 29

With the ; character multiple commands are run one after another.
With the > character the standard output is sent to a file or to another device instead of to
the screen. If the file already exists, it deletes the contents and places the new data into the
fie.
With the >> character the standard output is appended to a file.
With the < character the standard input is taken from your keyboard or from another file or
device.
With the 2> standard error messages are sent to your screen and can be redirected to a file
or another device instead.

For more information pertaining to these Special Characters, please use the Online Manual
by using the man command.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 30

With the & you can run a command in the background. Normally when running a
command, your prompt does not come back until the command is finished. If you are
going to run a command that takes a long time and you need to run another
immediately use let & (ampersand) at the end of the command.
With the | (pipe), run the standard output of one command to the standard input of another command.
With the $, you can access the value of a variable.
With the \, you turn off the special meaning of the next character.

For more information pertaining to these Special Characters, please use the Online
Manual by using the man command.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 31

With the *, asterisk (splat), you can match any and all characters of unhidden file names.
With the ?, You can match any single character.
With the " , escape the meaning of a special character except $, " ", \, and ' (apostrophe).
With the 'Apostrophe, you can escape the meaning of " .
For more information pertaining to these Special Characters, please use the Online Manual
by using the man command.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 32

With the `` back quote, you can use the output of a command as an argument.
The . Dot is the current directory. You can use it instead of typing the full path in a command.
The .. Dot dot, is the parent directory. You can get to the directory above the subdirectory
that you are currently working.
For more information pertaining to these Special Characters, please use the Online Manual
by using the man command.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 33

These are the key points covered in this module. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 34

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 35

Copyright 2012 EMC Corporation. All rights reserved

Module 5: Unix Shells 36

These are the module objectives. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands

These are the lesson objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands

Every process on the system is assigned a Process Identification number known as a PID. The
ps command will display all the current information about the existing processes on the
machine. This information includes the user running the process, the parent pid and start
times. The reason for this command is to display information about the running processes so
that the system administrator can decide if the process is running in a loop, is hung or is a
normal system event. If the process does not belong in the environment then the system
administrator will kill the process using the PID number.
PID - The process identification number is a unique number assigned by UNIX to every
process on the system
TTY - The terminal line number from which the process was run

TIME - The amount of CPU accumulated time the process has used
COMMAND - The name of the process that is being executed
The following options are supported:
-e Lists information about every process now running.
-f Generates a full listing.
-l Generates a long listing

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands

This table describes some fields that are reported by the ps command. Which fields are
displayed depends on which option you choose as noted on the previous page.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands

The UNIX operating system is a multi-tasking operating system. You can run more than one
process at a time. You can enter new commands in the foreground while one or more
commands are still running in the background. Background processes are useful for running
slow programs whose output you do not need immediately.
The ampersand is a metacharacter to the shell to designate a background process. To run a
command as a background process, add the & character at the end of the command line
before you press the [ return ] key. The shell will assign a process ID to the process and print
out the PID and the job number to the screen. The prompt will return as soon as the
command is submitted. In the above example the output is redirected to a file. The reason
for this is so that the user can continue on with other work without being interrupted by the
output being displayed on the screen.
Standard input is controlled by the shell. The processes running in the background will not
be able to accept input from the keyboard. It is useful to put the & at the end of a command
that bring up its own windows like a web browser or emacs. When the background process
finishes, the work done will be displayed to the screen to inform the user that the job is
complete. Background jobs cannot be stopped with the normal ctrl-C from the keyboard.
The jobs can only be terminated with a kill command.
Note: The background job should also have its error output redirected. If it is not it will still
appear on the screen. This does not cause your current command to fail but it does make it
difficult to read.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands

The kill command is used to terminate and stop any process including background and nohup
commands. The kill command can also send a signal type to force the termination of a
process. The owner of a process or root, can kill any process.
There are many different types of signals to kill with. Some signals are user generated while
others are software or hardware interrupts.
The kill command is used to terminate a background process or a process running in another
terminal window. The kill command can send signals to a process. Signals are to tell the
process the type of exit to perform. There are many types of signals. Some are keyboard
generated, like the cntl-C. While others are hardware generated, like the power state
indicator, which informs the system of a power fail situation.

The signals in UNIX offer different aspects to interrupt a process, they do not actually kill the
process. The most you can do is ask the process to kill itself. The kill signal is sent to the
process and it is processed at the beginning of the next execution cycle time. By default, the
kill command will send the TERM signal to the process. However, processes can be written
to ignore signals sent to them. The most popular kill signal is -9 or KILL. The KILL signal
cannot be ignored or trapped by the programmer. To kill a background process you must use
jobs discover the job number and use:
$ kill %jobnumber

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands

In the shell, processes can be placed in the foreground or background. They can also be moved from foreground to
background and vice-versa. The percent sign is used by most of the commands above to designate a job number. The job
number is used to start and stop the processes. The only exception to this is the cntl-Z command which is used to stop a
foreground job from executing and returning control of the keyboard back to the shell.
Jobs in the foreground can be suspended with the ^Z. The program will pause, and the shell will respond with the system
prompt. The job can be continued in either the background or foreground using the bg and fg commands. For example;
$ jobs
[ 1 ] + stopped

ls -laR | grep `sysnames` > config.files

$ bg %1
$ jobs
[ 1 ] + running

ls -laR | grep `sysnames` > config.files

Jobs started in the foreground using the fg command will run without allowing the user to continue working with the shell.

You can enter background process control commands at the system prompt in order to suspend or terminate a process. If
you want to temporarily suspend a background process, you can enter the command;
$ stop %n
Where n is th job number that is displayed when the background process is first entered. To terminate a process that is
running in the foreground you can use the ctrl-C.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands

All processes on a UNIX machine are allocated a time slice in order to run their code. This is
the essence of a time-sharing environment. The basis for this allocation of time is called
priority. The better the priority of a process the more processor resource time the program
will receive.
The nice command is another of the UNIX prefix commands that allow the user to alter the
priority of their process. The lower the priority value of a process the better the more
processor time it will receive. A + priority will force the process to run slower, a - priority
number will grant the process additional processor cycles i.e. more CPU time.
The value assigned to nice can be between 1 and 19. The default increment, if not defined, is
10. A process with a higher nice value will essentially have a lower system priority. That is to
say that a negative nice value will grant a process better overall execution time. The superuser may run commands with priority higher than normal by using a negative increment such
as -10. A negative increment assigned by an unprivileged user is ignored. The ps command
will display the priority of a process in the PRI field, and the relative nice value in the field
called NI.
The following options are supported:
-increment | -n increment
increment must be in the range 1-19; if not specified, an increment of 10 is assumed.
An increment greater than 19 is equivalent to 19.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands

Note the command give the name of the host you are log on. Another form of this
command is the uname command.

For more information pertaining to this command such as options and


arguments please use the Online Manual by typing the following
command:
man hostname

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands

The /etc/hosts file is a static lookup table for hosts that you want to be able to communicate
with over the network. Each host will have its own entry on one line, there are 3 fields for
each entry in this file.
The first field is the IP address for the host, the second filed is the host name. The third field
is an alias name for the host. In our example the alias for the host name sun1 is loghost.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 10

These are the lesson objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 11

Remote Login to a computer. User interface to a remote system using the TELNET protocol.
UNIX and Windows
telnet [options] [ remote_host [ port_number ] ]
Where:
remote_host
specifies the hostname or IP address of the remote computer to connect to.
port_number
specifies the port number or service name.
Common Options for UNIX systems:

-l user
user will be sent to the remote system as the value for the ENVIRON variable USER.
-n tracefile
Opens tracefile for recording trace information.
-r
Specifies a user interface similar to rlogin.
Telnet Commands:
open [ -l user ] [ [!] @hop1 [@ hop2 ...]@host [ port ]
Open a connection to the named host. If no port number is specified, telnet will attempt to contact a TELNET
server at the default port.

close
Close any open TELNET session and exit telnet. An EOF (in command mode) will also close a session and exit.
z
Suspend telnet. This command only works when the user is using a shell that supports job control, such as
sh(1).

For more information pertaining to this command such as options and arguments please use
the Online Manual by typing the following command:
man telnet

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 12

Each host has its official name, which is the first name in the database entry, and can have
one or more optional nicknames. The remote hosts have a file named /etc/hosts.equiv which
is a list of trusted hostnames with which it shares usernames. Users that have the same
username on both the local and remote hosts may rlogin from the hosts that are listed in the
remote host /etc/hosts.equiv file without giving a password. Users may set up a similar lists
with the file .rhosts in their home directories. Each line in this file contains two names: a
hostname and a username separated by a space.
Hostnames are listed in the hosts database, which can be contained in the /etc/hosts and
/etc/inet/ipnodes files, the Network Information Service (NIS) hosts map, the Internet
domain name server, or a combination of these.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 13

ssh (Secure Shell) is a program to log into another computer over a network, to execute commands in a remote machine,
and to move files from one machine to another. It provides strong authentication and secure communications over
unsecured channels. It is intended as a replacement for rlogin, rsh, and rcp. Additionally, ssh provides secure X connections
and secure forwarding of arbitrary TCP connections.
The traditional BSD 'r' - commands (rsh, rlogin, rcp) are vulnerable to different kinds of attacks. Somebody who has root
access to machines on the network, or physical access to the wire, can gain unauthorized access to systems in a variety of
ways. It is also possible for such a person to log all the traffic to and from your system, including passwords (which ssh never
sends in the clear).
The X Window System also has a number of severe vulnerabilities. With ssh, you can create secure remote X sessions which
are transparent to the user. As a side effect, using remote X clients with ssh is more convenient for users.
Users can continue to use old .rhosts and /etc/hosts.equiv files; changing to ssh is transparent for them. If a remote site
does not support ssh, a fallback mechanism to rsh is included.
COMMAND ssh [-l login_name] [hostname |user@hostname][command]
Options:
a
Disables forwarding of the authentication agent connection
-c blowfish | 3des Selects the cipher to use for encrypting the session. 3des (triple-des) is an encrypt-decrypt-encrypt
triple with three different keys. It is presumably more secure than the des cipher, which is no longer fully supported in ssh.
blowfish is a fast block cipher; it appears very secure and is much faster than 3des.
-C Requests compression of all data.
-l login_name Specifies the user to log in as on the remote machine. This also may be specified on a per-host basis in the
configuration file.
For more information pertaining to this command such as options and arguments please use the Online Manual by typing
the following command:
man ssh

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 14

Each filename or directory argument is either a remote file name of the form:
hostname:path, such as sun2:/kernel/drv/sd.conf or a local file name which does not
contain any ":" (colon) characters, "/" (backslash) before any ":" (colon) characters).
rcp copies files between hosts providing the proper permission are in place. The example
above is a push to a destination machine 10.127.30.196. In order to perform this function
you must either have write permission on the directory you are copying to or by having the
same user name on the remote system that you are currently logged in as on the local
system. This can be rendered moot by having the /etc/hosts.equiv or a .rhosts file in place.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 15

Secure Copy (SCP) - Remote file copy program


The scp utility copies files between hosts on a network. It uses ssh for data transfer, and uses the same authentication and
provides the same security as ssh. Unlike rcp, scp will ask for passwords or passphrases if they are needed for
authentication.
Any file name may contain a host and user specification to indicate that the file is to be copied to/from that host. Copies
between two remote hosts are permitted.
Command:
scp [-pqrvC46] [-S program] [-P port] [-c cipher] [-i identity_file] [-o option] [user1@]host1:]file1 [[user2@]host2:]file2
[...]
OPTIONS:
-B Selects batch mode.
-c cipher selects the cipher to use for encrypting the data transfer.
-C Compression enable
-i identity_file Selects the file where the identity (private key) for RSA Authentication is read.
-o option The given option is directly passed to ssh
-p Preserves modification times, access times, and modes from the original file.
-P port Specifies the port to connect to on the remote host.
-r Recursively copies entire directories.
-S program Specifies the name of the program to use for the encrypted connection.
-v Verbose mode.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 16

The ftp command is the user interface to the Internet standard File Transfer Protocol (FTP).
FTP transfers files to and from a remote network site. The command is common to UNIX and
Windows systems. ftp also has 2 modes of transfer binary and ascii. When copying a binary
file set the copy mode to binary. Failure to do so will corrupt the image and render the file
contents useless. When downloading a file (get), the copy will be stored in the directory
defaulted to when you execute the ftp command.
ftp [options] [remote_host [port_number]]
Where:

remote_host specifies the hostname or IP address of the remote computer to


connect to.

port_number specifies the port number or service name.


Common Options:

-d

Enables debugging.

-i

Turns off interactive prompting during multiple file transfers.

-T timeout Enables global connection timer, specified in seconds (decimal).


-v

Shows all responses from the remote server, as well as report on data transfer
statistics.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 17

binary

Sets the "representation type" to "image".

bye

Terminates the FTP session with the remote server and exit ftp.

cd remote-directory

Changes the working directory to the remote-directory.

delete remote-file

Deletes the file remote-file on the remote machine.

get remote-file [ local-file ] Retrieves the remote-file and store it on the local machine.

mdelete remote-files

Deletes the remote-files on the remote machine.

mget remote-files

Receive a list of remote files

dir [ remote-directory ] [ local-file ] Prints a listing of the directory contents in the directory,
remote-directory, and, optionally, placing the output in local-file.
lcd [ directory ] Changes the working directory on the local machine.
ls [ remote-directory | -al ] [ local-file ] Prints an abbreviated listing of the contents of a
directory on the remote machine.

mkdir directory-name Makes a directory on the remote machine.


mput local-files

send a list of local files to remote machine.

open host [ port ]

Establishes a connection to the specified host FTP server.

recv remote-file [ local-file ] A synonym for get.


rename from to

Renames the file.

rmdir directory-name

Deletes a directory on the remote machine.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 18

nslookup has two modes: interactive and non-interactive.


Interactive mode allows the user to contact servers for information about various hosts and
domains or to display a list of hosts in a domain.
Non-interactive mode is used to display just the name and requested information for a host
or domain.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 19

The ifconfig command is used at boot time to define the network address of each interface
present on the host. It may be used at a later time to change the interface's address or other
operating parameters.
Following are some of the options available:
-a Apply the command to all interfaces of the specified address family. If no address family
is supplied, either on the command line or by means of /etc/default/inet_type, then all
address families will be selected.
-d Apply the commands to all "down" interfaces in the system.
-D Apply the commands to all interfaces not under DHCP (Dynamic Host Configuration
Protocol) control.
-u Apply the commands to all "up" interfaces in the system.
-4 Apply the commands to all IPv4 interfaces.
-6 Apply the commands to all IPv6 interfaces.
For more information pertaining to this command such as options and arguments please use
the Online Manual by typing the following command:
man ifconfig

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 20

rsh connects to the specified hostname and executes the specified command. rsh copies its
standard input to the remote command, the standard output of the remote command to its
standard output, and the standard error of the remote of the remote command to its
standard error.
If you omit command, instead of executing a single command, rsh logs you in on the remote
host using rlogin(1).
rsh will not return the exit status code of command.
For more information pertaining to this command such as options and arguments please use
the Online Manual by typing the following command:
man rsh or remsh

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 21

These are the lesson objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 22

The uptime command prints the current time, the length of time the system has been up,
and the average number of jobs in the run queue over the last 1, 5 and 15 minutes.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 23

The netstat command displays the contents of certain network-related data structures in
various formats, depending on the options you select. The netstat command has the several
forms:
The command with no arguments displays a list of active sockets for each protocol.
The -g, -p, and -s options display information from various network data structures.
The -m option displays STREAMS memory statistics.
The -i option shows the state of the interfaces.
The -r option displays the routing table.
The -M option displays the multicast routing table.
The -D option displays the state of DHCP

For more information pertaining to this command such as options and


arguments please use the Online Manual by typing the following
command:
man uptime

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 24

The vmstat command reports virtual memory statistics regarding kernel thread, virtual
memory, disk, trap, and CPU activity. On multi-processor systems, vmstat averages the
number of CPUs into the output. For per-processor statistics, see mpstat. The vmstat
command only supports statistics for certain devices. For more general statistics, use sar,
iostat, or sar.
The following options are supported:
-c Report cache flushing statistics. By default, report the total number of each kind of
cache flushed since boot time. The types are: user, context, region, segment, page, and
partial-page.
-i Report the number of interrupts per device. count and interval does not apply to the -i
option.
-p Report paging activity in details.

For more information pertaining to this command such as options and


arguments please use the Online Manual by typing the following
command:
man vmstat

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 25

The iostat command reports terminal, disk, and tape I/O activity, as well as CPU utilization. The first line of output is for all time since boot; each subsequent
line is for the prior interval only.

The following options are supported:


-c Report the percentage of time the system has spent in user mode, in system mode, waiting for I/O, and idling.
-C When the -n and -x options are also selected, report extended disk statistics aggregated by controller id.
-d For each disk, report the number of kilobytes transferred per second, the number of transfers per second, and the average service time
in milliseconds.
-D For each disk, report the reads per second, writes per second, and percentage disk utilization.
-e Display device error summary statistics. The total errors, hard errors, soft errors, and transport errors are displayed.
-E Display all device error statistics.
-i In -E output, display the "Device Id" instead of the "Serial No". The "Device Id" is a unique identifier registered by a driver through
ddi_devid_register(9F).
-I Report the counts in each interval, rather than rates.
-l n Limit the number of disks included in the report to n; the disk limit defaults to 4 for -d and -D, and unlimited for -x. Note: disks explicitly
requested are not subject this disk limit.
-m Report file system mount points. This option is most useful if the -P or -p option is also specified.
-M Display data throughput in MB/sec instead of KB/sec.
-n Display names in descriptive format (for example, cXtYdZ, rmt/N, server:/export/path).
-p For each disk, report per-partition statistics in addition to per-device statistics.
-P For each disk, report per-partition statistics only, no per-device statistics.
-r Display data in a comma-separated format.
-s Suppress messages related to "state changes."

For more information pertaining to this command such as options and arguments please use the Online Manual by typing
the following command:
man iostat

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 26

The ping command utilizes the ICMP (ICMP6 in IPv6) protocol's ECHO_REQUEST datagram to
elicit an ICMP (ICMP6) ECHO_RESPONSE from the destination host or network gateway. If
host responds, host is alive, will be on the standard output and exit. If there is a timeout, it
will write: no answer from host
The default timeout is 20 seconds.

For more information pertaining to this command such as options and


arguments please use the Online Manual by typing the following
command:
man ping

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 27

The key is a string of characters containing exactly one function letter (c, r, t, u or x) and zero
or more function modifiers (letters or digits), depending on the function letter used.
c

Create. Writing begins at the beginning of the tarfile, instead of at the end.

r Replace. The named files are written at the end of the tarfile. A file created with
extended headers must be updated with extended headers.
t Table of Contents. The names of the specified files are listed each time they occur in
the tarfile.
u Update. The named files are written at the end of the tarfile if they are not already in
the tarfile, or if they have been modified since last written to that tarfile.

x Extract or restore. The named files are extracted from the tarfile and written to the
directory specified in the tarfile, relative to the current directory. Use the relative path
names of files and directories to be extracted.
Example explanation:
The c function means create the archive. The v outputs a message explaining what tar is
doing. The f indicates that the tarfile is being specified (/dev/rmt/0 in this example). The dot
(.) indicates the current directory and is the arguments of the f function modifier.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 28

These are the lesson objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 29

NFS, like many other protocols, builds on the Open Network Computing Remote Procedure
Call (ONC RPC) system.
The nfs file resides in directory /etc/default and provides startup parameters for the nfsd(1M)
and lockd(1M) daemons. The nfs file format is ASCII; comment lines begin with the
crosshatch (#) character. Parameters consist of a keyword followed by an equals (=) sign
followed by the parameter value, of the form:
keyword=value
Typically used by Unix hosts but can be used by others such as MAC OS, Microsoft Windows, Novell, and IBM
AS400 hosts.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 30

Typically used by Unix hosts but can be used by others such as MAC OS, Microsoft Windows, Novell, and IBM
AS400 hosts.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 31

Typically used by Unix hosts but can be used by others such as MAC OS, Microsoft Windows, Novell, and IBM
AS400 hosts.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 32

These are the key points covered in this module please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 33

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 34

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 35

Copyright 2012 EMC Corporation. All rights reserved

Module 6: System Network and Status Commands 36

These are the module objectives. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager

These are the lesson objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager

These are the lesson objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager

Use the format utility to view all disks that are available to the SUN host.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager

Shown here is a small selection of the disks available to this host. Type the number of the
disk you wish to configure. In this example, we use number 5, which is actually disk
c4t19d20.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 10

If the disk has never been used or formatted it asks if you want to label it now. Label means
to write or save the work done to the disk. It is not necessary to label at this time since you
have not done anything to it.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 11

This is the Format or Main menu. At EMC disk, we only use a few of these options because
the Symmetrix and Clariion perform many of these tasks.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 12

The p option invokes the Partition menu. You use a number of the options on this menu,
such as label, print and the partitions 0 7. You can invoke an option by typing a single
character, such as l for label and p for print.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 13

The print option shows all of the available partitions for a SUN disk. Shown here are
partitions 0, 1, 2 and 6. There are default partitions on an EMC Symmetrix after a vtoc has
been run on it.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 14

When you select a partition it lists its current status and provides the option to change it.
The first item to change is its Tag ID; the default is always in brackets [ ] . There are only
certain names that are allowed; to view them type ?. To take the default press Enter or
type one of the items shown.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 15

Specify the permission flag. Enter ? to see available options.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 16

To simplify the partitioning of this disk you should erase, or zero out, the existing partitions.
In this example, we zero out partition 0 by making its partition size be 0 mb.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 17

Continue zeroing out partitions 1 and 6 as we did with partition 0. This makes it much easier
to place your new partitions onto the disk.
partition> 1
Part

Tag Flag

Cylinders

swap wu

0 - 68

Size

Blocks

32.34MB (69/0/0) 66240

Enter partition id tag[swap]:


Enter partition permission flags[wu]:
Enter new starting cyl[0]: 69
Enter partition size[66240b, 69c, 137e, 32.34mb, 0.03gb]: 0
partition> p
Current partition table (unnamed):
Total disk cylinders available: 956 + 2 (reserved cylinders)

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 18

Part

Tag Flag

Cylinders

Size

Blocks

0 unassigned wm

(0/0/0)

1 unassigned wu

(0/0/0)

backup wu

0 - 955

3 unassigned wm

(0/0/0)

4 unassigned wm

(0/0/0)

5 unassigned wm

(0/0/0)

usr wm

138 - 955

7 unassigned wm

448.12MB (956/0/0) 917760

383.44MB (818/0/0) 785280


0

(0/0/0)

partition>
partition> 6

Part
6

Tag Flag
usr wm

Cylinders
138 - 955

Size

Blocks

383.44MB (818/0/0) 785280

Enter partition id tag[usr]:


Enter partition permission flags[wm]:
Enter new starting cyl[138]:
Enter partition size[785280b, 818c, 955e, 383.44mb, 0.37gb]: 0
partition>

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 19

l, or label labels or writes (i.e., save) our work on this disk.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 20

These are the lesson objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 21

The ioscan command completes the task of scanning for new LUNs for the OS to recognize.
ioscan probes the host hardware then lists usable I/O system devices or kernel I/O system
data structures. By default, ioscan displays the hardware path to the hardware module, the
class of the hardware module, and a brief description.
The types of hardware reported include processors, memory, interface cards, and I/O
devices. Scanning the hardware may cause some drivers to become unbound and others
bound in their place in order to match actual system hardware. Objects that cannot be
scanned are not listed.
The command option used when verifying scanning for new LUNs is fnC. The f option
provides a full listing of the device properties, the n option displays the device file name,
and the -C option restricts the output to devices belonging to a class of devices. In the
example, the disk class is listed which limits the output to devices that are in the disk class. .
For more information pertaining to this command, such as options and arguments, access
the online manual by typing the command man ioscan.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 22

While logged in as Administrator (root) issue the command ioscan with the fnC disk at the
system prompt. The output from the ioscan command is displayed here. Each LUN that is
recognized is claimed by the host OS as a LUN it recognizes. The report on each claimed LUN
includes the device file names, the fibre channel HBA, and its hardware path. You can use the
hardware path to devices identified here keep track of configurations and check installation
status.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 23

In this slide, the hardware path for device c14t3d0 is highlighted. Definitions were provided
earlier for the bus converter, adapter, domain Id and F_Port. The part of the hardware path
in the yellow boxes identify the LUN address on the array.
Using the logical unit addressing method defines the hardware path of the bus converter
(which is identified by a number between 0 and 7), the target (identified as a number
between 0 15), and the LUN (identified by a number between 0 and 7).
Note: The example shown is the output of an HP in the Loop with the Symmetrix. The Port is
the loop id of the FA port of the Symmetrix (FA-1). The Bus, Target, LUN field directly reflect
the 3 digit Target/LUN configured in the bin file on the Symmetrix array.
The three numbers in the middle represent the port and are not addressed in this course.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 24

By default, HP-UX uses certain naming conventions for physical volumes, volume groups, and
logical volumes. You need to refer to LVM devices or volume groups by name when using
them within SAM, with HP-UX commands, or when viewing information about them.
Note that each disk has a block device file and a character or raw device file, the latter
identified by the r. Which name you use depends on what task you are doing with the disk. In
the notation above, the first two names represent block device files while the second two are
raw device files.
Use a physical volumes raw device file for these two tasks only: when creating a physical
volume. Here, you use the device file for the disk. For example, when restoring your volume
group configuration this might be /dev/rdsk/c3t2d0 if the disk were at card instance 3, target
address 2, and device number 0 (the absence of a section number beginning with s indicates
you are referring to the entire disk). For all other tasks, use the block device file. For example,
when you add a physical volume to a volume group, use the disks block device file (such as
/dev/dsk/c5t3d0) for the disk.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 25

The example shows the output of a ioscan fnC disk. Notice that each LUN has a block device
file and a character or raw device file. The raw device files are identified by rdsk in the
device address. Raw device files are contained in /dev/rdsk while block device files are
contained in /dev/dsk.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 26

By default, HP-UX uses certain naming conventions that must be used when referring to
physical volumes, volume groups, and logical volumes. In this example, the controller
instance is 14, the target address is 3, and the device number 0. The absence of a slice
number preceded by an s indicates that there are no slices; thus the device address
identifies the whole disk.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 27

Disks are grouped together into volume groups. A physical volume group can consist of one
or many disks. The maximum number of volume groups on a system is 255. The default
value is 10. This can be changed by using the kernel parameter max_vgs (the values are 1
256). Volume groups are mapped into pools of data storage called physical extents (PEs)
which, by default, are 4 MB each.
A volume groups number of extents determines the size of a logical volume. The logical
volumes can then be allocated as file systems, swap, or raw file systems. The maximum
number of logical volumes per volume group is 255. The maximum size of a logical volume
that will be allocated as a file system is 4 GB for HP-UX version 10.01, and 128 GB for HP-UX
version 10.20 and up.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 28

Logical volumes are disks (or pieces of disks) for storing file systems, swap or raw areas.
Logical volumes can also be expanded or reduced.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 29

To use the LVM, a disk must first be initialized into a physical volume (LVM disk). Once one or
more physical volumes have been initialized, you can assign them to one or more volume
groups. A given disk can only belong to one volume group. Each volume group can, by
default, contain up to 16 physical volumes. Disk space from a volume group is allocated into
logical volumes. A volume group can contain up to 255 logical volumes and can reside on
portions of many disks, or on only one disk.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 30

The character special file for a volume group is called group and lives in the /dev/vg##
directory. The directory name is the name of the volume group. By default, these directories
are named vg00, vg01, vg02...vg##, in the order they are created.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 31

vgdisplay lists names and corresponding information for all defined volume groups. A volume group must be activated
before it can be displayed. You can view information about a particular volume group by including the name in the
command, for example, vgdisplay johnvg.
The v or verbose option gives complete information about the volume group(s).
hp1 / vgdisplay -v
--- Volume groups --VG Name
/dev/vg00
VG Write Access
read/write
VG Status
available
Max LV
255
Cur LV
8
Open LV
8
Max PV
16
Cur PV
1
Act PV
1
Max PE per PV
2500
VGDA
2
PE Size (Mbytes)
4
Total PE
2169
Alloc PE
2036
Free PE
133
Total PVG
0
Total Spare PVs
0
Total Spare PVs in use 0
Continued on
the next page

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 32

The lv_path is the block device path name of a logical volume, for example, /dev/vg00/lvol1. With
the v option all information about the logical volume will be displayed.
hp1 / lvdisplay -v /dev/vg00/lvol1
--- Logical volumes --LV Name
/dev/vg00/lvol1
VG Name
/dev/vg00
LV Permission
read/write
LV Status
available/syncd
Mirror copies
0
Consistency Recovery
MWC
Schedule
parallel
LV Size (Mbytes)
128
Current LE
32
Allocated PE
32
Stripes
0
Stripe Size (Kbytes)
0
Bad block
off
Allocation
strict/contiguous
IO Timeout (Seconds)
default
Continued on
the next page

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 33

These are the lesson objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 34

With lsdev you can display information about all devices in the Customized Devices object
class. To select a subset of the customized devices, use a combination of the following flags: c Class, -s Subclass, -t Type, -l Name, -p Parent, and -S State.
Command:

/usr/sbin/lsdev

Purpose:

Display devices in the system and their characteristics

Options:

-C All devices

arguments:

N/A

-c class

Comments: This command displays information about devices in the Device Configuration
Database. There are many ways to display information with the lsdev command.

Examples:

1. lsdev -C
2. lsdev -Cc disk

For more information pertaining to this command, such as options and arguments, access
the online manual by typing the command man lsdev.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 35

Command:

/usr/sbin/lsvg

Purpose:

Displays information about a volume group

Options:

-p physical volume info


-l logical volume info

arguments:

vol_group_name

Comments: This command with the -l option displays the LV, Type, LPs, PPs, PVs, LV state,
and mount point. The -p option displays the PV, PVstate, Total PPs, Free PPs and distribution
of PPs.
For more information pertaining to this command, such as options and arguments, access
the online manual by typing the command man lsvg.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 36

The lslv command displays the characteristics and status of the logical volume or lists the
logical volume allocation map for the physical partitions on the physical volume. The logical
volume can be a name or an identifier.
Command:

/usr/sbin/lslv

Purpose:

Displays information about a logical volume

Options:

-l list physical volume info


-m list logical partition info

arguments:

log_vol_name

Comments: This command displays the status and characteristics of the logical volume.
The -l option displays the PV name, copies, and PP distribution. The -m option displays LPs
and PVname.
Examples:

1. lslv yournamelv
2. lslv -l yournamelv

For more information pertaining to this command, such as options and arguments, access
the online manual by typing the command man lslv.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 37

These are the lesson objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 38

Volume Groups are like a virtual disk. The storage capacity of a volume group can be divided
into logical volumes (LVs), like virtual disk partitions. The size of a logical volume is in
multiples of physical extents (PEs). The size of the physical extents can be configured at
volume group creation time. If a logical volume is too small or too large you can change its
size at run time.
For more information pertaining to this command, such as options and arguments, access
the online manual by typing the command man lvm.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 39

Purpose:

vgdisplay - display attributes of volume groups

Options
-A --active volumegroups, -c --colon Generate output, -d, --debug, -D --disk
Show attributes from the volume group, -h --help Print a usage message, -s --short Give a
short listing
arguments: vgdisplay [-A|--activevolumegroups] [-c|--colon] [-d|--debug] [-D|--disk] [-h|-help] [-s|--short] [-v[v]|--verbose [--verbose]] [--version] [VolumeGroupName...]
Comments: vgdisplay allows you to see the attributes of a Volume Group Name (or all
volume groups if none is given) with its physical and logical volumes, their sizes, etc.
For more information pertaining to this command, such as options and arguments, access
the online manual by typing the command man vgdisplay.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 40

lvdisplay diplays the attributes of a logical volume including size, read/write status, snapshot information, etc.
OPTIONS
-c, --colon
Generate colon separated output for easier parsing in scripts or programs. The values are:
* logical volume name
* volume group name
* logical volume access
* logical volume status
* internal logical volume number
* open count of logical volume
* logical volume size in kilobytes
* current logical extents associated to logical volume
* allocated logical extents of logical volume
* allocation policy of logical volume
* read ahead sectors of logical volume
* major device number of logical volume
* minor device number of logical volume

For more information pertaining to this command, such as options and arguments, access the online manual by
typing the command man lvdisplay.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 41

These are the lesson objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 42

During boot-up sequence, the Windows OS loads the driver for the storage host bus adaptors
(HBAs). The OS then performs a SCSI Inquiry command to get information about all of the
attached storage devices. Each disk drive that it discovers is assigned a number in a semibiased, first come, first served method, based on HBA installation location. Semi-biased
means that the Windows system always begins with the controller in the lowest-numbered
PCI slot where a storage controller resides. Once the driver for the storage controller is
loaded, the OS selects the adapter in the lowest-numbered PCI slot to begin the disk drive
discovery process.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 43

The naming convention for physical drives is simple and is always the same for the software
applications using them. A raw device under Windows is accessed by the name
\\PHYSICALDRIVEXXX, where XXX is the drive number. For example, assume three HBAs are
installed, HBA1 in slot1, HBA2 in slot 2, and HBA3 in slot3, and one device is connected to
each port using Fibre Channel protocol. Then assignments are: \\PHYSICALDRIVE0 is attached
to HBA1, \\PHYSICALDRIVE1 is attached to HBA2 and \\PHYSICALDRIVE2 is attached to HBA3.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 44

The Inquiry command (inq) displays several fields that can help you determine which storage
volume is associated with a particular device as seen by the host.
Example:
The following figure shows a sample output of inq when run from the host console
connected to a Symmetrix system. The output fields are as follows:
DEVICE = full pathname for the SCSI device
VEND = Vendor information
PROD = Product name
REV = Revision number for a Symmetrix, this will be the microcode version
SER NUM = Serial number, in the format SSVVVDDP, where:
SS = last two digits of the Symmetrix serial number
VVV = Logical volume number
DD = Channel director number
P = port on the channel director
CAP = Size of the device in kilobytes

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 45

Disk Management is a utility that enables you to perform most disk-related tasks without
restarting the system or interrupting system users. Disk Management can initialize disks,
make volumes, create file systems with FAT, FAT32, or NTFS file systems types, and create
fault-tolerant disk systems.
The majority of configuration changes take effect immediately.
Microsoft Disk Manager duplicates functionality available in Logical Volume Managers.
Logical Volumes can be created. They can span disks in a manner similar to the way logical
volumes span disks associated in Volume groups. Logical volumes can be mirrored,
expanded, removed, and migrated to other systems.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 46

These are the key points covered in this module. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 47

Copyright 2012 EMC Corporation. All rights reserved

Module 7: Logical Volume Manager 48

These are the module objectives. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems

These are the lesson objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems

Linux is a Unix-like operating system that was designed to provide personal computer users a
free or very low-cost alternative to Unix.
Linux has a reputation as a very efficient and fast-performing system that has as many
applications as any other server OS. Listed above are some of the many versions of Linux,
some of which can be downloaded.
Some of the FTP distributors are Sunsinte.org.uk, Sunsinte.unc.edu, and www.isoimages.org.
Information on Linux can be found at the URLs www.linux.com, www.linix.com, and
www.xfree86.com.

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems

EMC uses Red Hat Enterprise Linux, one of the more popular Linux distributions. It supports
multiple architectures such as Intel X86, Intel Itanium, AMD AMD64 and IBM zSeries, POWER
Series, and S/390. There is increased kernel and user address space for X86 systems, which
allows support for 64GB of main memory and larger user applications. Native Posix Thread
Library is a new high-performance multi-threading capability, which provides improved
performance for multi-threaded applications.
Red Hat Enterprise Linux uses the latest stable Linux kernel with numerous additions from
the Linux 2.5/2.6 kernels.
Support for larger SMP, memory and I/O systems allows version 3 to support servers
approximately twice the size of version 2.1. There is forward compatibility: version 3
includes compatibility libraries, so it can run version 2.1 applications without modification.
For more information, access the online manual by typing the command man intro.

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems

The Linux kernel has a modular design. At boot time, only a minimal resident kernel is loaded
into memory. Thereafter, whenever a user requests a feature that is not present in the
resident kernel, a kernel module, sometimes referred to as a driver, is dynamically loaded
into memory.
During installation, the hardware on the system is probed. Based on this probing and
information provided by the user, the installation program decides which modules need to be
loaded at boot time. The dynamic loading mechanism works transparently.
If new hardware is added after installation and the hardware requires a kernel module, the
system must be configured to load the proper kernel module for the new hardware. When
the system is booted with the new hardware, the Kudzu program runs, detects the new
hardware if it is supported, and configures the module for it. The module can also be
specified manually by editing the module configuration file, /etc/modules.conf.

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems

As with Unix systems, run levels can be accessed via the init command. For example, to go to
level 3, enter init 3. The run levels are listed above. Run Levels define the current boot state
of the system.

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems

These are the lesson objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems

Linux uses the File system Hierarchy Standard (FHS), which dictates the locations of the
directories and structure. The system kernel is located under /boot or /. There are precise
guiding principles for each area of the file system, which specifies the minimum files and
directories required. The default Linux directories created on install are:
bin - Essential command binaries
boot - Static files of the boot loader
dev - Device files
etc - Host-specific system configuration
lib - Essential shared libraries and kernel modules
media - Mount point for removable media
mnt - Mount point for mounting a file system temporarily
opt - Add-on application software packages
sbin - Essential system binaries
srv - Data for services provided by this system
tmp - Temporary files
usr - Secondary hierarchy
var - Variable data
See also http://www.pathname.com/fhs/

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems

The /boot directory contains static files required to boot the system. Do not remove the
/boot/ directory. Doing so renders the system unbootable.
The /dev/ directory contains file system entries, which represent devices that are attached to
the system.
The /etc/ directory is reserved for configuration files that are local to the machine. Some
examples of configuration files under /etc are the X Window System configuration files, such
as XF86Config (found in /etc/X11/), and "skeleton" user files (found in /etc/skel/), which are
used to populate a home directory when a user is first created. No binaries are to be put in
/etc/. Any binaries that were once located in /etc/ should be placed into /sbin/ or /bin/.

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems

/sbin/ contains binaries essential for booting, restoring, recovering, and/or repairing the
system. Programs executed after /usr/ is known to be mounted (when there are no
problems) are generally placed into /usr/sbin. Locally-installed system administration
programs should be placed into /usr/local/sbin.

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems 10

The /usr/ directory is often in its own partition and is mounted read-only. Under the /usr/
directory:
bin/ - executables
dict/ - non-FHS compliant documentation pages
etc/ - system-wide configuration files
games - games
include/ - C header files
kerberos/ - binaries and other Kerberos-related files
lib/ - object files and libraries that are not designed to be directly utilized by users or shell
scripts
libexec/ - small helper programs called by other programs
sbin/ - system administration binaries that do not belong in the /sbin/ directory
share/ - files that are not architecture-specific
src/ - source code
X11R6/ - XWindow System (XFree86 on Red Hat Enterprise Linux)

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems 11

These are the lesson objectives. Please take a moment to read them.

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems 12

The high-level device drivers in the SCSI subsystem are:


sd Direct access (disks)
sg SCSI generic interface
sr Data CD-ROMs
st Tapes
The sg driver is character-based while the other three drivers are block-based. The sg driver
is used primarily for scanners, CD writers, and printers. The sg device files are dynamically
mapped to SCSI IDs/LUNs on the SCSI bus starting with the first SCSI controller.
A native device file name for block devices take the following form: /dev/sdln where l is a
letter denoting the physical drive and n is a number denoting the partition on that physical
drive. When host bus adapters discover attached storage, Linux defines the devices in device
files /dev/sd[l][n].

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems 13

The above example defines a file /dev/sda1/ where the physical device is a and a partition
is 1.
Linux kernel reserves 16 major numbers for SCSI devices. Each major number can have 0-255
minor numbers. These minor numbers include the partitions for a SCSI device. Linux supports
one to 15 partitions per disk device. Partitions 1 through 4 are the primary partitions, while
partitions 5 and greater are the logical or extended partitions; these limitations are specific
to the Intel platform. By default, slices are not used in Linux. Therefore, the product of 16
major numbers and 16 minor numbers yields 256 SCSI devices. As a result, the kernel is able
to scan logical devices ranging from 0 through 255. Red Hat Linux distributions and SuSE SLES
7 support a maximum of 128 SCSI devices as opposed to the SuSE SLES 8 distribution, which
supports all 256 SCSI devices. The total of 256 SCSI devices includes any non-EMC storage
array devices, such as local disks.

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems 14

In the Linux kernel, the SCSI addresses are not used in the device names as they are in other types of
UNIX (Sun, SGI, HP-UX, and BSD, for example). Recall that block device filenames take the form
/dev/sdln, where l is the letter denoting the physical drive and n is the number denoting the partition
on that physical drive. Device names are assigned dynamically at boot time or device loading time in
the order of discovery.
Depending upon the hardware configuration, if a device is added and the system rebooted, the
device numbering might change, possibly rendering the host's mount table inaccurate. For the most
consistent results and to reduce the possibility of mount table inaccuracies, new devices should be
appended (if possible) to the list of already attached devices. For example, if the host contains
multiple HBAs, it would be best to append the new device to the last HBA and to the end of the
device list attached to that HBA. This would eliminate the need to alter the pre-existing entries in the
mount table, since the new device could be appended to that as well. If a new device were added to
the first out of two HBAs and the system rebooted, the devices would all shift by one number and the
mount table entries would also need to be shifted by one device. If there is only one HBA, the new
device can more easily be appended to the list of the regularly attached devices and the mount table
altered accordingly.
Linux currently lacks an actual command built into the kernel that allows for a dynamic SCSI channel
reconfiguration like drvconfig or ioscan.
The mechanisms for reconfiguring devices on a Linux host include:
System reboot
Unloading and reloading the modular HBA driver
Echoing the SCSI device list in /proc
Executing a SCSI scan function through attributes exposed to /sys
Executing a SCSI scan function through HBA vendor scripts
EMC recommends that all I/O on the SCSI devices should be quiesced prior to attempting to rescan
the SCSI bus.

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems 15

These are the key points covered in this module. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems 16

These are the key points covered in this training. Please take a moment to review them.

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems 17

Copyright 2012 EMC Corporation. All rights reserved

Module 8: Linux Systems 18

S-ar putea să vă placă și