79
EMC Education Service Operating System Bootcamp Workshop April 2013

OS Bootcamp Workshop v1.4 - MR-5CN-GSAPICSOS

Embed Size (px)

Citation preview

Page 1: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Service

Operating System Bootcamp

Workshop

April 2013

Page 2: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Service

Copyright

Copyright © 1996, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 EMC

Corporation. All Rights Reserved. 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, Data Domain, RSA, EMC Centera, EMC ControlCenter, EMC LifeLine, EMC OnCourse, EMC

Proven, EMC Snap, EMC SourceOne, EMC Storage Administrator, Acartus, Access Logix, AdvantEdge,

AlphaStor, ApplicationXtender, ArchiveXtender, Atmos, Authentica, Authentic Problems, Automated Resource

Manager, AutoStart, AutoSwap, AVALONidm, Avamar, Captiva, Catalog Solution, C-Clip, Celerra, Celerra

Replicator, Centera, CenterStage, CentraStar, ClaimPack, ClaimsEditor, CLARiiON, ClientPak, Codebook

Correlation Technology, Common Information Model, Configuration Intelligence, Configuresoft, Connectrix,

CopyCross, CopyPoint, Dantz, DatabaseXtender, Direct Matrix Architecture, DiskXtender, DiskXtender 2000,

Document Sciences, Documentum, elnput, E-Lab, EmailXaminer, EmailXtender, Enginuity, eRoom, Event

Explorer, FarPoint, FirstPass, FLARE, FormWare, Geosynchrony, Global File Virtualization, Graphic

Visualization, Greenplum, HighRoad, HomeBase, InfoMover, Infoscape, Infra, InputAccel, InputAccel Express,

Invista, Ionix, ISIS, Max Retriever, MediaStor, MirrorView, Navisphere, NetWorker, nLayers, OnAlert,

OpenScale, PixTools, Powerlink, PowerPath, PowerSnap, QuickScan, Rainfinity, RepliCare, RepliStor,

ResourcePak, Retrospect, RSA, the RSA logo, SafeLine, SAN Advisor, SAN Copy, SAN Manager, Smarts,

SnapImage, SnapSure, SnapView, SRDF, StorageScope, SupportMate, SymmAPI, SymmEnabler, Symmetrix,

Symmetrix DMX, Symmetrix VMAX, TimeFinder, UltraFlex, UltraPoint, UltraScale, Unisphere, VMAX, Vblock,

Viewlets, Virtual Matrix, Virtual Matrix Architecture, Virtual Provisioning, VisualSAN, VisualSRM, Voyence,

VPLEX, VSAM-Assist, WebXtender, xPression, xPresso, YottaYotta, the EMC logo, and where information lives,

are registered trademarks or trademarks of EMC Corporation in the United States and other countries.

All other trademarks used herein are the property of their respective owners.

© Copyright 2013 EMC Corporation. All rights reserved. Published in the USA.

Revision Date: DATE 04/01/2013

Revision Number: MR-5CN-GSAPICSOS.1.2

Page 3: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 3

Document Revision History

Rev # File Name Date

1.0 OS Bootcamp Workshop v1.0 - MR-5CN-GSAPICSOS.docx 1/9/2013

1.1 OS Bootcamp Workshop v1.1 - MR-5CN-GSAPICSOS.docx 2/21/2013

1.2 OS Bootcamp Workshop v1.2 - MR-5CN-GSAPICSOS.docx 4/1/2013

Page 4: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 4

Table of Contents

COPYRIGHT ................................................................................................................................. 2

DOCUMENT REVISION HISTORY ............................................................................................ 3

PREFACE: HISTORY OF UNIX .................................................................................................. 5

PREFACE: HISTORY OF BSD .................................................................................................... 6

PREFACE: HISTORY OF LINUX ............................................................................................... 7

PREFACE: COMMAND STRUCTURE ....................................................................................... 8

LAB EXERCISE 1: NAVIGATION ............................................................................................ 12

LAB 1: PART 1 – THE MAN & METACHARACTERS ....................................................................... 13

LAB 1: PART 2 – PROCESSES – PS, VMSTAT, TOP, UPTIME, KILL, AND DSMEG ............................... 14

LAB 1: PART 3 – LS, LN, AND FILE SYSTEM STRUCTURE ............................................................... 18

LAB 1: PART 4 – PWD AND HOME ................................................................................................. 21

LAB 1: PART 5 – CD, MKDIR, RMDIR, AND HISTORY ...................................................................... 22

LAB 1: PART 6 – PROMPT USING PS1 ........................................................................................... 25

LAB 1: PART 7 – IDENTITY – WHO, WHOAMI, ID, UNAME, ARCH, AND HOSTNAME ........................ 27

LAB EXERCISE 2: FILE AND DIRECTORY COMMANDS ................................................... 30

LAB 2: PART 1 - FILE COMMANDS – MORE, TOUCH, CP, CAT, MV, AND RM .................................... 31

LAB 2: PART 2 – TEXT EDITOR - VI................................................................................................ 35

LAB 2: PART 3 – PERMISSIONS - CHMOD....................................................................................... 38

LAB 2: PART 4 - FILE PACKAGING - TAR AND ZIP ......................................................................... 41

LAB EXERCISE 3: FINDING THINGS WITH GREP, WHEREIS, AND FIND ..................... 44

LAB 3: PART 1 – FIND COMMAND ................................................................................................. 45

LAB 3: PART 2 – WHEREIS COMMAND .......................................................................................... 46

LAB 3: PART 3 – GREP COMMAND ................................................................................................ 47

LAB EXERCISE 4: NETWORKING ......................................................................................... 49

LAB 4: PART 1 - NETWORKING – IFCONFIG, PING, AND TRACEROUTE ............................................ 50

LAB 4: PART 2 – REMOTE ACCESS – SSH, FTP, SCP, AND RSYNC .................................................... 51

LAB 4: PART 3 – MOVING DATA REMOTELY ................................................................................. 52

LAB EXERCISE 5: LOCAL STORAGE AND FILE SYSTEMS .............................................. 56

LAB 5: PART 1 – FILE SYSTEM – FDISK, CFDISK, MKFS, MOUNT, AND DF ...................................... 57

LAB 5: PART 2 – LVM – LVMDISKSCAN, PVSCAN, PVDISPLAY, AND PVCREATE ............................ 61

LAB 5: PART 3 – VOLUME GROUPS – VGCREATE, VGEXTEND, VGEXPORT, AND VGIMPORT .......... 63

LAB 5: PART 3 – LOGICAL VOLUMES – LVCREATE, LVDISPLAY, AND LVEXTEND ......................... 66

LAB EXERCISE 6: NETWORKED STORAGE ....................................................................... 70

LAB 6: PART 1 – FILE LEVEL - NFS & CIFS ................................................................................. 71

LAB 6: PART 2 – BLOCK LEVEL USING FC AND FCOE ................................................................ 73

LAB 6: PART 3 – BLOCK LEVEL USING ISCSI ................................................................................ 75

SUGGESTIONS FOR FURTHER STUDY ................................................................................. 78

END OF WORKSHOP ....................................................................................................................... 79

Page 5: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 5

Preface: History of UNIX

In the 1960s Ken Thompson of Bell Labs had access to M.I.T’s early time-sharing operating system Multics. Ken

wrote simulations for the new file and paging system on it. He also programmed a game called Space Travel on a DEC

PDP-7. On this PDP-7, a team of Bell Labs researchers developed a hierarchical file system, the concepts of computer

processes and device files, a command-line interpreter, and some small utility programs. In 1970, Peter Neumann coined

the project name Unics (UNiplexed Information and Computing Service) as a pun on Multics, (Multiplexed Information

and Computer Services). Unics could eventually support multiple simultaneous users, and it was renamed UNIX.

When Bell Labs Computer Science Research Group wanted to use UNIX on a PDP-11/20 machine, this led to

financial support from Bell. Bell Labs used this initial text processing system, consisting of UNIX, roff, and the editor, for

text processing of patent applications. Roff soon evolved into troff, the first electronic publishing program with a full

typesetting capability. The UNIX Programmer's Manual was published on 3 November 1971. Versions of the UNIX

system were determined by editions of its user manuals. For example, "Fifth Edition UNIX" and "UNIX Version 5" have

both been used to designate the same version.

AT&T made UNIX available to universities and commercial firms, as well as the United States government,

under licenses. The licenses included all source code including the machine-dependent parts of the kernel, which were

written in PDP-11 assembly language. Copies of the annotated UNIX kernel sources circulated widely in the late 1970s

this led to a plethora of different UNIX versions both inside and outside Bell Labs. AT&T licensed UNIX System III,

based largely on Version 7, for commercial use, the first version launching in 1982. AT&T continued to issue licenses for

older UNIX versions. To end the confusion between all its differing internal versions, AT&T combined them into UNIX

System V.

Bell Labs released its’ final version on UNIX in 1989 as v10. A new project was start to build on those ideas

learned it was called Plan 9. It was developed primarily for research purposes as the successor to UNIX by the Computing

Sciences Research Center at Bell Labs between the mid-1980s and 2002. Plan 9 continues to be used and developed by

operating system researchers and hobbyists.

Other companies began to offer commercial versions of the UNIX System for their own mini-computers and

workstations. AT&T licensed many of these new UNIX flavors developed from UNIX System V. There are over 40

different flavors of UNIX; here are the most significant;

Microsoft announced Xenix UNIX for Z8000 CPU in 1980 and then Intel 8086, (merged into SCO 1987)

SunOS (Solaris) was created in 1982 to run on Motorola 68000, Sun386i, and now the Sun SPARC.

o Sun released OpenSolaris in 2008, but Oracle closed it (now continued on as OpenIndiana)

Santa Cruz Operation (SCO) ported to the Intel 8086 in 1983 (OpenServer v6 was the final release in 2005).

HP-UX was released in 1984 for Motorola 68000, HP 9000 processors, and now the Intel IA64.

DG/UX (Data General UNIX) was built in 1985 for both Motorola 68000 and then Intel x86

o DG was purchased by EMC in 1999 and all production of DG/UX ended by 2001

IBM introduced AIX in 1986 to run the IBM 6150 RT workstation and now the PowerPC processors.

Minix was created in 1987 for a variety of CPUs and the source code was made freely available for universities.

Bell Labs’ final version of UNIX V10 was released in 1989

o Plan 9 replaced UNIX in 1992 (Plan 9 v4 was released in 2002)

Page 6: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 6

Preface: History of BSD

Berkeley Software Distribution (BSD, sometimes called Berkeley Unix) is a UNIX operating system derivative.

BSD has been considered a branch of UNIX—"BSD UNIX", because it shared the initial codebases and design with the

original AT&T UNIX Sixth Edition operating system. Berkeley Software Distribution (1BSD), which was released in

March 1978. 1BSD was an add-on to UNIX rather than a complete operating system in its own right.

Defense Advanced Research Projects Agency's (DARPA) decision to fund Berkeley University of California's

Computer Systems Research Group (CSRG), which would develop a standard UNIX platform for future DARPA research

in the VLSI Project (state of the art in microprocessor design). CSRG released 4BSD in October 1980.

The final release from Berkeley was 1995's 4.4BSD-Lite Release 2, after which the CSRG was dissolved and

development of BSD at Berkeley ceased. Since then, several variants based directly or indirectly on 4.4BSD-Lite (such as

FreeBSD, NetBSD, OpenBSD and DragonFly BSD) have been maintained.

In addition, the permissive nature of the BSD license has allowed many other operating systems, both free and

proprietary, to incorporate BSD code. For example, Microsoft Windows has used BSD-derived code in its implementation

of TCP/IP and bundles recompiled versions of BSD's command-line networking tools since Windows 2000. Also Darwin,

the system on which Apple's Mac OS X is built, is a derivative of 4.4BSD-Lite2 and FreeBSD. Various commercial

UNIX operating systems, such as Solaris, also contain varying amounts of BSD code.

BSD code remains actively developed and widely used today. This can be attributed to the ease with which it could

be licensed. BSD is even the basis for many embedded devices like iPhones, iPads, network switches, and even Mac OS

X. Here are the most popular variants of BSD;

FreeBSD derivatives -> DragonFly BSD, PC-BSD, MacOS X and iOS

NetBSD

OpenBSD

EMC Isilon OneFS

NetApp's ONTAP

Juniper Networks JunOS

F5 Networks BIGIP

Page 7: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 7

Preface: History of Linux

In 1991 while attending the University of Helsinki, Torvalds became curious about operating systems and

frustrated by the COSS licensing of MINIX, which limited it to educational use only. He began to work on his own

operating system which eventually became the Linux kernel. Torvalds began the development of the Linux kernel on

MINIX, and applications written for MINIX were also used on Linux. GNU applications also replaced all MINIX

components, because it was advantageous to use the freely available code from the GNU project. Linux was originally

developed as a free operating system for Intel x86-based personal computers. It has since been ported to more computer

hardware platforms than any other operating system. It is a leading operating system on servers and other big iron systems

such as mainframe computers and supercomputers: more than 90% of today's 500 fastest supercomputers run some variant

of Linux. Linux also runs on a variety embedded systems (like; routers, storage devices, cell phones, cameras, DVRs,

industrial control systems, televisions, game consoles, and even refrigerators). The Android system in wide use on mobile

devices is built on the Linux kernel.

The development of Linux is one of the most prominent examples of free and open source software collaboration:

the underlying source code may be used, modified, and distributed—commercially or non-commercially—by anyone

under licenses such as the GNU General Public License. Typically Linux is packaged in a format known as a Linux

distribution for desktop and server use. Some popular mainstream Linux distributions include Debian (and its derivatives

such as Ubuntu and Linux Mint), Red Hat Enterprise Linux (and its derivatives such as Fedora and CentOS),

Mandriva/Mageia, OpenSUSE, and Arch Linux. Linux distributions include the Linux kernel, supporting utilities and

libraries and usually a large amount of application software to fulfill the distribution's intended use.

A distribution oriented toward desktop use will typically include the X Window System and an accompanying

desktop environment such as GNOME or KDE Plasma. Some such distributions may include a less resource intensive

desktop such as LXDE or Xfce for use on older or less powerful computers. A distribution intended to run as a server may

omit all graphical environments from the standard install and instead include other software such as the Apache HTTP

Server and an SSH server such as OpenSSH. Because Linux is freely redistributable, anyone may create a distribution for

any intended use. Applications commonly used with desktop Linux systems include the Mozilla Firefox web browser, the

LibreOffice office application suite, and the GIMP image editor.

Now there are over 600 different Linux distros! The most popular today are;

Red Hat derivatives –> Fedora, RHEL, CentOS, Oracle Linux, Scientific Linux, and Mandrake

Debian derivatives –> Ubuntu, Mint, Corel, Knoppix, and Zorin

MCC Interim derivatives –> Slackware, SUSE , and SunJDS

CRUX derivative –> Arch

Gentoo

Page 8: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 8

Preface: Command Structure

Kernel

In computing, the kernel is the main component of most computer operating systems; it is a bridge between

applications and the actual data processing done at the hardware level. The kernel's responsibilities include managing the

system's resources (the communication between hardware and software components).[1] Usually, as a basic component of

an operating system, a kernel can provide the lowest-level abstraction layer for the resources (especially processors and

I/O devices) that application software must control to perform its function. It typically makes these facilities available to

application processes through inter-process communication mechanisms and system calls.

Operating system tasks are done differently by different kernels, depending on their design and implementation.

While monolithic kernels execute all the operating system code in the same address space to increase the performance of

the system, microkernels run most of the operating system services in user space as servers, aiming to improve

maintainability and modularity of the operating system. A range of possibilities exists between these two extremes.

The kernel, being the core of the UNIX system, is loaded at system start up (boot). The kernel is a memory

resident control program that manages the entire resources of the system. The kernel presents resources to you and every

other user as a coherent system. The kernel provides service to user applications such as device management, examples;

Managing the machine's memory and allocating it to each process.

Scheduling the CPU so that the work of each user is carried out as efficiently as is possible.

accomplishing the transfer of data from one part of the machine to another

interpreting and executing instructions from the shell

enforcing file access permissions

Page 9: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 9

Shell - Whenever you login to a UNIX system you are placed in a shell program. The shell is a command interpreter; it

takes each command and passes it to the operating system kernel to be acted upon. Each shell also includes its own

programming language. Command files, called "shell scripts" are used to accomplish a series of tasks.

A shell is software that provides an interface for users of an operating system to access the services of a kernel.

However, the term is also applied very loosely to applications and may include any software that is "built around" a

particular component, such as web browsers and email clients that are "shells" for HTML rendering engines. The name

shell originates from shells being an outer layer of interface between the user and the internals of the operating system

(the kernel).

Operating system shells generally fall into one of two categories: command-line and graphical. Command-line

shells provide a command-line interface (CLI) to the operating system, while graphical shells like the Windows Shell

provide a graphical user interface (GUI). In either category the primary purpose of the shell is to invoke or "launch"

another program; however, shells frequently have additional capabilities such as viewing the contents of directories.

The relative merits of CLI- and GUI-based shells are often debated. CLI proponents claim that certain operations

can be performed much faster under CLI shells than under GUI shells (such as moving files, for example). However, GUI

proponents advocate the comparative usability and simplicity of GUI shells. The best choice is often determined by the

way in which a computer will be used. On a server mainly used for data transfers and processing with expert

administration, a CLI is likely to be the best choice. However, a GUI would be more appropriate for a computer to be used

for image or video editing and the development of the above data.

In expert systems, a shell is a piece of software that is an "empty" expert system without the knowledge base for

any particular application.

The most influential UNIX shells have been the Bourne shell and the C shell. The Bourne shell, sh, was written

by Stephen Bourne at AT&T as the original UNIX command line interpreter; it introduced the basic features common to

all the UNIX shells, including piping, here documents, command substitution, variables, control structures for condition-

testing and looping and filename wildcarding.

The most commonly available shells are;

C shell (csh): Written for BSD in 1978

Almquist shell (ash): Written as a BSD-licensed replacement for the Bourne Shell

Debian Almquist shell (dash): A modern replacement for ash in Ubuntu and Debian.

Bourne shell (sh) (RedHat default)

Bourne Again Shell (bash)

Korn shell (ksh) - (all POSIX commands)

BusyBox

Page 10: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 10

Runlevel - Refers to a mode of operation in one of the computer operating systems that implement Unix System V-style

initialization. Each runlevel designates a different system configuration and allows access to a different combination of

processes. A good sysadmin would strive to have the system running at the lowest possible runlevel and still be able to

perform its’ role, here by minimizing the number unnecessary services running.

Seven runlevels exist, numbered from zero to six; though up to ten, from zero to nine may be used. S is

sometimes used as a synonym for one of the levels. Only one "runlevel" is executed on boot up - run levels are not

executed sequentially, i.e. either runlevel 2 OR 3 OR 4 is executed, not 2 then 3 then 4.

"Runlevel" defines the state of the machine after boot. Different runlevels are typically assigned to:

single-user mode

multi-user mode without network services started

multi-user mode with network services started

system shutdown

system reboot[Reboot]

The exact setup of these configurations will vary from OS to OS and from one Linux distribution to another. For

example, runlevel 4 might be multi-user, GUI, no-server on one distribution, and nothing on another. Note the difference

in the Red Hat and Slackware distributions charted in this article. However, "runlevels" do commonly follow patterns

described in this article. When installing Linux, it is best to consult that distribution's available user guides.

In standard practice, when a computer enters runlevel zero, it halts, and when it enters runlevel six, it reboots. The

intermediate runlevels (1-5) differ in terms of which drives are mounted, and which network services are started. Default

runlevels are typically 3, 4, or 5. Lower run levels are useful for maintenance or emergency repairs, since they usually

don't offer any network services at all. The particular details of runlevel configuration differ widely among operating

systems, and also among system administrators.

The runlevel system replaced the traditional /etc/rc script used in Version 7 Unix. The most commonly used are

listed below;

0 = Halt, Shuts down the system

1 = Single-User Mode, For administrative tasks

2 = Multi-User Mode, Without any networking

3 = Multi-User Mode with Networking, Starts the system normally CLI only.

4 = Not used/User-definable

5 = Start the system with GUI, Same as runlevel 3 but with X11Windows System

6 = Reboot

Page 11: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 11

Utilities - UNIX provides several hundred utility programs, often referred to as commands.

Accomplish universal functions

editing

file maintenance

printing

sorting

A great resource to compare all the different commands in many of the different UNIX-like operating systems is the

“Sysadmin's Unixersal Translator or ROSETTA STONE” at http://bhami.com/rosetta.html

UNIX Command Syntax

UNIX commands must be entered in the following form: command -options arguments

The command is always the first word. The options modify the function the command performs. The

arguments identify the data (usually a file or files) upon which the command performs its function.

This syntax is almost universal within UNIX, but not quite. A few commands take options without the

preceding dash, and some commands accept dashes but don't require them. Some commands require a dash for

each option, instead of permitting you to group several options after one dash. If you have questions about a

command's syntax, refer to the man pages.

Three additional areas you should know about using UNIX commands are: abbreviations, upper- and lower-

case and wild-card characters. The first two are simply explained:

UNIX commands cannot be abbreviated.

UNIX distinguishes between upper- and lower-case. Because of this, UNIX recognizes a command

named ls as different from Ls and LS. If you enter a lowercase command in uppercase, UNIX will not

know what to do.

The third is only a little more complicated. UNIX shells have two wild-card characters: ? and *. The ?

character is used to match one character. For example, if you tell the system to find file ???, it will return all the

file names that are three characters long. The * character is used to match file names containing a varied number

of characters. For example, if you tell the system to find m*, it will return all the file names that start with `m'

(for example, `me', `mother', and `mary' would all be returned). The * character can also be used before partial file

names (for example, *.lis) and on both sides of partial file names (for example, *.*). A useful expression is .??*

which matches all files beginning with a `.' and are at least 3 characters long. Files beginning with `.' are

typically not displayed.

Page 12: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 12

Lab Exercise 1: Navigation

Purpose:

Like UNIX operating system, the files on a Linux system are

arranged in what is called a hierarchical directory structure. This

means that they are organized in a tree-like pattern of directories

(called folders in other systems), which may contain files and other

directories. The first directory in the file system is called the root

directory. The root directory contains files and subdirectories, which

contain more files and subdirectories and so on and so on.

Tasks: Students perform the following tasks:

man pages

processes

print working directory

changing directories

listing files and directories

prompts

References: Lecture material

Page 13: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 13

Lab 1: Part 1 – The Man & Metacharacters

Step Action

1. man page (short for manual page) is a form of online software documentation usually

found on a Unix-like operating systems. Topics covered include computer programs

(including library and system calls), formal standards and conventions, and even abstract

concepts. A user may invoke a man page by issuing the man command

press the letter “q” to quit a man page,

“space bar” or “page down” key to page down

“Enter” key to go down one line

Its basic syntax is: man [option(s)] keyword(s)

Type and read each of the following:

man pwd (Q: what does pwd stand for?_______________________________)

man chmod (Q: what does chmod do?__________________________________)

man grep (Q: what has the –y option been replaced by?__________________)

2. Regular expressions use metacharacters. Metacharacters are simply characters that have a

special meaning. The problem occurs when you want to use a regular expression in a

shell script. Will the shell do something special with the character? Or will it be passed

unchanged to the program? The “$” character is a good example. It could be the

beginning of a variable name or it could be part of a regular expression. If you need a

regular expression, you must know if any of the characters of the expression are

metacharacters, and must know the right way to quote that character so that it is passed to

the program without being modified by the shell.

meta function example

? Match one character. ls /dev/tty?1

* Match zero or more characters. ls /dev/tty*1

; Command separator ls; pwd

~ Home directory. cd ~

& Run program in background. sleep 10 &

> file Redirect standard output to file ls /root –lia > root_directory.txt

| Pipe standard output. cut -d: -f1 < /etc/passwd | sort

Try each one of these commands and notice this difference in the outputs.

Page 14: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 14

Lab 1: Part 2 – Processes – ps, vmstat, top, uptime, kill, and dsmeg

Step Action

1. Time to time when you are typing commands into a computer the process will stop responding or

continue running forever. It is important to know how to find and kill these processes.

2. If you just typed in a process and it just keeps running with your cursor is stuck in the process then you

can kill that process by typing ctrl+c

Basically Ctrl C sends the SIGINT (interrupt) signal while kill sends the SIGTERM (termination)

signal by default.

Let us try it this out. Log into the host assigned to you.

Type: ping 10.127.70.1

Unlike some other OS’es ping will run continuously by default in Linux. To kill the ping process

running and return your cursor to you press the control key then type c

Type: ctrl+c

Control+z is used for suspending a process by sending it the signal SIGSTOP, which cannot be

intercepted by the program, just sending the process to the background releasing the cursor. While

Control+c is used to kill a process with the signal SIGINT, and can be intercepted by a program so it

can clean its self-up before exiting, or not exit at all.

Page 15: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 15

Step Action

3. The Processes’ Status command will show you a list of processes running on your system. Notice the

difference in these options with the ps command.

Option Description

-T select all processes on this terminal

-a select all processes on a terminal, including those of other users

-C select by command name

-e Every process on the entire system

-f Full verbose format listing

-l All treads for a particular process

Try each one of these options, and notice this difference in the outputs.

Type: ps –e

Type: ps –ef

Type: ps –elf

Now let us make a process and send it to the background giving us our prompt back.

Type: ping 10.127.70.1

Type: ctrl+z (sending the ping process to the background giving us our prompt back)

Type: ps -T (to list the status of all the processes in your terminal session)

4. locate the ping process and record the PID number (Process ID) ________

Type: kill -9 *PID* (*PID* is the number you just recorded)

for example I had to type : kill -9 19293

Option Name Description

-1 SIGHUP Hang up signal, processes can act upon the kill command or not

-2 SIGINT Interupt signal, same as control+c in the program’s terminal window

-9 SIGKILL Kill signal – terminate the process and its children, doesn’t ask.

-15 SIGTERM Termination signal – asks program to terminate

Page 16: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 16

Step Action

5. uptime gives a one line display of the following information. The current time, how long the system

has been running, how many users are currently logged on, and the system load averages for the past

1, 5, and 15 minutes.

Type: uptime

Type: uptime –V

6. vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity. The

first report produced gives averages since the last reboot. Additional reports give information on a

sampling period of length delay. The process and memory reports are instantaneous in either case.

Option Description

-d Disk stats

-a Memory pages

-s Event counters

-n Header to be displayed

Try each one of these options, and notice this difference in the outputs.

Type: vmstat

7. The dmesg command is used to display the kernel messages in Linux to you.

Type: dmesg

Page 17: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 17

Step Action

8. top - dynamic real-time view of a running system. It can display system summary information as well

as a list of tasks currently being managed by the Linux kernel.

Option Description

-d Delay time interval

-u Monitor by user

-H Threads

-M Memory

Try each one of these options, and notice this difference in the outputs.

Type: top -M

Page 18: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 18

Lab 1: Part 3 – ls, ln, and file system structure

Step Action

1. ls - Lists the contents of a directory.

Option Description

-l prints permissions, owners, size, and when last modified.

-i prints the i-node number in the first column

-a Shows you all files, even files that are hidden

-q Force printing of non-printable characters as the character (?)

-R Includes the contents of subdirectories.

-x Displays files in columns.

Try each one of these options, and notice this difference in the outputs.

Type each of these and notice the output:

Type: ls

Type: ls –a

Type: ls –i

Type: ls -l

Type: ls –lia

Type: ls /root –liaR > root_directory.txt

( > will redirect command output to root_directory.txt)

Page 19: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 19

Step Action

2. There is no single standard UNIX/Linux file structure. Most UNIX systems however, follow a

general convention for file system organization at the highest level. List the contents of each one

of these directories below.

/ -(root) The top level directory. Contains all files in the file system.

/bin - Executable files for standard UNIX utilities

/dev - Files that represent input/output devices

/etc - Miscellaneous and system administrative files

/lib - UNIX program libraries

/tmp - Temporary space used by programs or users.

/usr/bin - less common utilities.

/usr/local - Programs installed by local site

/var - Variable sized files - can grow and shrink dynamically

Page 20: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 20

Step Action

3. Links in Linux are like short cuts in Windows. The ln will make links between files.

There are two types of links

symbolic links: Refer to a symbolic path indicating the abstract location of another file

hard links : Refer to the specific location of physical data.

Option Description

-p Physical – make a hard link directly to symbolic link

-s Symbolic – make link symbolic instead of hard

-f Force – remove existing destination file

Type: ln -s /home/joe/file1.txt /joe.file.txt

Type: ls –lia /

Page 21: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 21

Lab 1: Part 4 – pwd and home

Step Action

1. Since a command line interface cannot provide graphic pictures of the file system

structure, it must have a different way of representing it. Think of the file system tree as a

maze, and you are standing in it. At any given moment, you are located in a single

directory. Inside that directory, you can see its files and the pathway to its parent

directory and the pathways to the subdirectories of the directory in which you are

standing.

The directory you are standing in is called the working directory. To find the name of the

working directory, use the pwd command.

Type: pwd

2. Each user has a unique "home" directory. Your home directory is that part of the file

system reserved for your files. After login, you are "put" into your home directory

automatically. This is where you start your work.

Since you are logged in as root then you are left in root’s home directory. The location of

root’s home directory varies depending on distribution of Linux or flavors of UNIX or

BSD. Root’s home could be any of these;

/

/root

/user/root

/user/home/root

Type: echo $HOME to find where your home directory is, or type

note root’s home directory _________________________

3. The PATH is an environment variable that is a list of directories that the operating

system looks in to find commands issued by the user. The syntax for setting your path is

slightly dependent on which shell you are using. The default shell for RedHat 5.x and 6.x

is the bash shell.

Type: export PATH=$PATH:/usr/sbin/:/usr/local/bin

End of Lab Exercise

Page 22: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 22

Lab 1: Part 5 – cd, mkdir, rmdir, and history

Step Action

1. To change your working directory (where you are standing in the maze) you use the cd command. To

do this, type cd followed by the pathname of the desired working directory. A pathname is the route

you take along the branches of the tree to get to the directory you want. Pathnames can be specified in

one of two different ways; absolute pathnames or relative pathnames. Let's look with absolute

pathnames first.

An absolute pathname begins with the root directory and follows the tree branch by branch until the

path to the desired directory or file is completed. For example, there is a directory on your system in

which most programs are installed. The pathname of the directory is /usr/bin. This means from the root

directory (represented by the leading slash in the pathname) there is a directory called "usr" which

contains a directory called "bin".

Type: cd . ( . is your current directory, so you don’t go anywhere)

Type: cd .. ( .. is the parent directory to the one you are in, so you should be in / )

Type: cd / ( / is the absolute path that will always get you to / )

Type: cd tmp ( this relative pathname will put you in sub-directory tmp if one exists where you are)

Type: cd /usr/tmp (this absolute path that will always take you to /usr/tmp no matter where you are)

Type: cd /root (absolute path that will always get you to root’s home /root )

2. mkdir – make directory

Type: mkdir /root/mydir (will make a sub folder in /root called mydir)

Type: mkdir /home/YourName (will make a sub folder in /home named after you)

Type: ls

Page 23: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 23

Step Action

3. rmdir – removes empty directory

Type: rmdir /root/mydir (will remove the folder /root/mydir)

4. A particularly useful command is the history command. History show a list of recently-executed

commands, all recorded in a history list

Type: history

End of Lab Exercise

Page 24: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 24

This page intentionally left blank

Page 25: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 25

Lab 1: Part 6 – Prompt using PS1

Step Action

1. Most of us work with a shell prompt. By default most Linux distros displays hostname and current

working directory. You can easily customize your prompt to display information important to you.

Prompt is control via a special shell variable. You need to set PS1, PS2, PS3 and PS4 variable. If

set, the value is executed as a command prior to issuing each primary prompt.

PS1 - The value of this parameter is expanded and used as the primary prompt string.

2. How do I display current prompt setting? Simply use echo command, enter:

Type: echo $PS1

3. So when executing interactively, bash displays the primary prompt PS1 when it is ready to read a

command, and the secondary prompt PS2 when it needs more input to complete a command. Bash

allows these prompt strings to be customized by inserting a number of backslash-escaped special

characters that are decoded as follows:

Option Description

\h The hostname up to the first .

\H the FQDN hostname

\r carriage return

\s the name of the shell

\d The date in "Weekday Month Date" format (e.g., "Tue May 26")

\t the current time in 24-hour HH:MM:SS format

\u the username of the current user

\w the current working directory

Let us try to set the prompt so that it can display today’s date and hostname:

Type: PS1="\d \h $ "

Output: Tue Jan 08 OSBootcamp $

Now setup prompt to display date/time, hostname and current directory:

Type: PS1="[\d \t \u@\h:\w ] $ "

Output: [Tue Jan 08 15:56:16 root@OSBootcamp:/tmp ] $

Question: What would you type to change the prompt to username @ hostname: pwd >

Your Answer: _______________________________________________

Page 26: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 26

Step Action

4. Answer: PS1="\u@\h: \w >"

Page 27: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 27

Lab 1: Part 7 – Identity – who, whoami, id, uname, arch, and hostname

Step Action

1. Here are some commands that help identify the user and system itself.

2. who - show who is logged on

Type: who

3. whoami - print effective userid

Type: whoami

4. id - print real and effective UIDs and GIDs

Type: id

5. uname - print system information

Option Description

-a Basic information

-i Hardware info

-p Processor CPU type

-r Operating system info

-s System name Try each one of these options, and notice this difference in the outputs.

Type: uname

Type: uname –a (to print hardware and software info about the system)

Type: uname –i (to print machine hardware info)

Type: uname –r (to print operating system version info)

6. arch – Print machine architecture type

Type: arch

Page 28: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 28

Step Action

7. Hostname is the program that is used to either set or display the current host, domain or node name

of the system. These names are used by many of the networking programs to identify the machine.

To display the computer name as defined in the /etc/hosts file.

You could just type more /etc/hosts if you have the file permission to do so or:

Option Description

-a Display any alias

-d display DNS domain

-f Display the FQDN (Fully Qualified Domain Name)

-i Display the IP address of the host as resoled from DNS

-v verbose Try each one of these options, and notice this difference in the outputs.

Type: hostname

Type: uname –n

End of Lab Exercise

Page 29: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 29

Page 30: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 30

Lab Exercise 2: File and Directory commands

Purpose:

Listing creating, manipulating, and deleting files and directories

Tasks: Students perform the following tasks:

Making and removing directories

Creating, concatenating, listing files

Moving, copying, renaming, deleting files

Editing files using vi

Viewing and changing permissions

Packaging files

References: Lecture material

Page 31: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 31

Lab 2: Part 1 - File commands – more, touch, cp, cat, mv, and rm

Step Action

First go back to the directory you named after yourself.

Type: cd /home/YourName

1. touch - create new, empty files or change file access and modification time.

Option Description

-a change only the access time

-c do not create any files

-m change only the modification time

-t STAMP use this time MMDDhhmm instead of current time

Try each one of these options, and notice this difference in the outputs.

Type: touch file1.txt

Type: ls (to verify that your file has been made)

Page 32: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 32

Step Action

2. more - paging through text one screen full at a time

Option Description

-p clear the whole screen and then display the text.

-d more will prompt the user

-c paint each screen from the top

/pattern Search for the occurrence of regular expression.

Try each one of these options, and notice this difference in the outputs.

Type: more file1.txt (displays contents of empty file you created))

Type: ls /home –liaR > home_directory.txt ( > will redirect command output to file)

Type: more home_directory.txt (notice it lists the folders and their contents)

3. cp – copy a file

Option Description

-a archive

-b backup

-f force

-l link instead of coping

-r copy directories recursively

Try each one of these options, and notice this difference in the outputs.

Type: cp home_directory.txt file2.txt

(this makes a copy of the file and names it file2.txt)

4. cat - concatenate files and print on the standard output appending one file to the end of

another.

Type: cat file1.txt file2.txt > file3.txt

(this makes file3.txt from the contents of file1 and file2)

Page 33: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 33

Step Action

5. mv – move and/or renames a file

Option Description

-i interactive

-b backup

-f force

-t target directory

-u update - move only when the source is newer than the destination

Try each one of these options, and notice this difference in the outputs.

Type: mv file3.txt YourName.txt (this rename file3.txt to your name)

Type: mv YourName.txt /home/ (this move you’re the file named after you to /home)

Type: cd.. (moves your prompt to /home, you could have typed cd /home as well)

Type: ls –lia (do you see your file here at /home?)

Page 34: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 34

Step Action

6. rm – remove a file

Option Description

-i interactive - prompt before every removal

-f force - never prompt

-r recursive - remove directories and their contents recursively

-v verbose - explain what is being done

rm YourName.txt

End of Lab Exercise

Page 35: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 35

Lab 2: Part 2 – text editor - vi

Step Action

1. There are lots of command line editors; nano, pico, Emacs, vim, gEdit, gVim, Eclipse, but the

original is called vi.

vi- is a screen-oriented text editor originally created for BSD operating system in 1979. vi has

been available for all versions of BSD, UNIX, and Linux since then, even Android and iOS.

When vi was written keyboards didn’t have all the keys they have today like the arrow keys so

other keys were assigned functions. Newer versions of vi now do use the added keys like

arrows. Here is a list of the most key functions;

Cursor movements

h or (left arrow) left one character

l or (right arrow) right one character

j or (down arrow) down one line

k or (up arrow) up one line

Deleting and Pasting

d delete

i insert text before cursor

x delete character cursor is on

r replace one character

a append text after cursor

y yank or copy into temporary buffer)

Y yank or copy line cursor is on

p paste below cursor line (deleted or copied text)

u undo last editing command

Exiting vi

:w write edit buffer to disk

:w filename write edit buffer to disk as filename

:q! quit without writing edit buffer to disk

:wq! write and quit even if it is read-only

2. Perhaps the most puzzling aspect of vi is that it is a modal editor. These are the two modes of

operation:

Insert mode: If you're in insert mode and type an x, the letter is added to the document

at the current cursor point. In insert mode, the letters you type form words and

sentences. Unlike many word processors, vi starts up in command mode.

Command mode: If you're in command mode, the x command causes the letter under

the cursor to be deleted, not added. In command mode, the letters of the keyboard

perform editing functions (like moving the cursor, deleting text, etc.). To enter

command mode, press the escape <Esc> key.

Page 36: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 36

Step Action

3. Type: cd /home/YourName

vi *YourName.txt* - The filename can be the name of an existing file or new file to create.

4. insert mode, now whatever keys you press the character will be represented there.

Type: i

5. type “joe was here” – notice the text you type is appearing in the file

6. To insert text in a line:

Position the cursor where the new text should go.

Type i - telling vi you want to enter insert mode

Enter the letter “w” so that now it reads “joe was where”.

The text is inserted BEFORE the cursor. Press <Esc> to get back to command mode.

7. To replace one character with another:

Move the cursor to the “w” character to be replaced.

Type r – telling vi you want to replace a single character

Type the replacement character “t” so now it reads “joe was there”.

The new character will appear, and you will still be in command mode.

8. To add text to the end of a line:

Position the cursor on the last letter of the line.

Type a – you could have moved the cursor to the end of the line and type i

Enter the new text “, but Karen was not here”

This adds text AFTER the cursor. Press <Esc> to get back to command mode.

9. To undo your most recent edit, type

u

To undo all the edits on a single line, type U

Undoing all edits on a single line only works as long as the cursor stays on that line. Once you

move the cursor off a line, you cannot use U to restore the line.

10. press the ESC key to exit from insert mode to command mode

11. The vi editor is built on a 1978 BSD text editor called ex. ex commands can be used within vi.

ex commands begin with a : (colon) and end with a <Return>

Type :wq! Then press Enter this is telling vi w=write, q=quit, !=now

if you just want to exit vi without saving you would just type :q!

End of Lab Exercise

Page 37: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 37

Page 38: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 38

Lab 2: Part 3 – Permissions - chmod

Step Action

1. UNIX is a multi-user system. Every file and directory in your account can be protected from or

made accessible to other users by changing its access permissions. Permissions for a file or

directory may be any or all of:

r - read

w - write

x - execute = running a program

Each permission (rwx) can be controlled at three levels:

u - user = yourself

g - group = can be people in the same project

o - other = everyone on the system

owner read (r)

owner write (w)

owner execute (x)

group read (r)

group write (w)

group execute (x)

public read (r)

public write (w)

public execute (x)

Page 39: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 39

Step Action

2. The chmod command is used to change access permissions for files which you own.

Option Description

-f force - never prompt

-r recursive – change files and directories recursively

-v verbose - diagnostic for every file processed

These values are added together for any one user category:

0 = no permissions

1 = execute only

2 = write only

3 = write and execute (1+2)

4 = read only

5 = read and execute (4+1)

6 = read and write (4+2)

7 = read and write and execute (4+2+1)

So access permissions can be expressed as three digits. For example:

command user group others

chmod 210 file1.txt -w- --x ---

chmod 351 file1.txt -wx r-x --x

chmod 604 file1.txt rw- --- r--

chmod 752 file1.txt rwx r-x -w-

chmod 773 file1.txt rwx rwx -wx

Page 40: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 40

Step Action

3. Type: chmod 631 file1.txt

Type: ls -lia – look at the permissions for the file

Type: chmod 755 file1.txt

Type: ls –lia – look at the permissions for the file

Page 41: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 41

Lab 2: Part 4 - File packaging - tar and zip

Step Action

1. In UNIX, the name of the tar command is short for tape archiving, the storing of entire file

systems onto magnetic tape. Commonly tar is used to simply combine a few files into a single file,

for easy storage and distribution.

option Function

-c Create – a tar file

-r Replace – the named file

-u Update – update files to the end of the tar file

-x Extract – The named file is extracted from tar file

-f File. Used the argument as the name of the file

-i Ignore - ignore directory checksum errors

-o Ownership - Assign to extracted files.

-v Verbose. Output the name of each file

-X Exclude – relative path names.

-z compress the tar file using gzip

-j compress files and directories using bzip2

2. To combine multiple files and/or directories into a single file, use the following command:

first let’s go home.

Type: cd /home/YourName

Type: tar -cvf file.tar file1.txt file2.txt

Type: ls –lia (is the new tar file there? Are your old files there?)

ok now make a new sub directory using mkdir

now move the tar file into that sub directory using mv

now change directory into the sub directory using cd

using ls display the contents of this directory, notice only the one tar file is here.

Page 42: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 42

Step Action

3. now let us untar the file using the tar command.

Type: tar –xovf file.tar

Type: ls (are the two text files there now?)

4. Compressed tar file - compress is a UNIX compression program based on the LZC compression

method. Files compressed by compress are typically given the extension .Z. Most tar programs will

pipe their data through compress when given the command line option -Z (tar in itself does not

compress, it just stores multiple files within one tape archive file).

Files can be returned to their original state using uncompressed. The usual action of the program is

not merely to create an uncompressed copy of the file, but to uncompress the compressed file (so

that the uncompressed version retains the timestamp and other attributes of the compressed file).

Type: tar -cjvf test.tbz /home/YourName

Type: ls

Page 43: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 43

Step Action

5. There are many compression programs available (gzip, rar, 7zip, xz, lbzip2, ect..) The original zip

and unzip programs are the most common and work almost exactly like their cousin PKZIP in the

DOS environment. You can compress a single file or bunch of files together into a zip file like this:

Type: zip compressed.zip file.tar (to compress the tar file)

Type: ls –lia (notice the new size of the compress tar file)

ok now make a new sub directory using mkdir

now move the newly zipped tar file compressed.zip into that sub directory using mv

now change directory into the sub directory using cd

Then you can extract the original files like this: unzip compressed.zip

Type: ls –lia

Page 44: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 44

Lab Exercise 3: finding things with grep, whereis, and find

Purpose:

find - The find command is used to locate files on a UNIX or Linux

system

grep - is a command-line utility for searching plain-text data sets for

lines matching a regular expression

Tasks: Students perform the following tasks:

find

whereis

grep

References: Lecture material

Page 45: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 45

Lab 3: Part 1 – find command

Step Action

1. The find command is used to locate files on a Unix or Linux system.

First change directory back to just home using cd /home

option Function

-maxdepth levels escend at most X levels

+n for greater than n

-n for less than n,

-name file name

-size

-type

-user owned by a specific user

Try and find the file2.txt file using the command below.

Type: find / -name file2.txt

2. Find every file under the directory /var/spool that was modified more than 60 days ago.

Type: find /var/spool -mtime +60

3. To locate files modified less than 10 minutes ago. I use this right after using some

system administration tool, to learn which files got changed by that tool:

Type: find / -mmin -10

4. Search for files which have specific set of permissions

Type: find . -perm 755

5. find will display the pathnames of all files in the current directory and all subdirectories.

Type: find . –print

Type: find .

6. You can use shell-style wildcards in the -name search argument:

Type: find . -name file\*txt

Note that wildcards in the name argument must be quoted so the shell doesn't expand

them before passing them to find. Also, unlike regular shell wildcards, these will match

leading periods in filenames. (For example find -name \*.txt )

Page 46: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 46

Lab 3: Part 2 – whereis command

Step Action

1. whereis locates source/binary and manuals sections for specified files. The supplied

names are first stripped of leading pathname components and any (single) trailing

extension of the form .ext, for example, .c. Prefixes of s. resulting from use of source

code control are also dealt with. whereis then attempts to locate the desired program

in a list of standard Linux places.

option Function

-b Search only for binaries.

-m Search only for manual sections.

-s Search only for sources

Try and find the file1.txt file using the command below.

Type: whereis file1.txt

This command will not work since it is not in the PATH

2. Find the executable file ls using the command below.

Type: whereis –b ls

Page 47: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 47

Lab 3: Part 3 – grep command

Step Action

1. The grep command searches the given file for lines containing a match to the given

strings or words. By default, grep prints the matching lines. Use grep to search for lines

of text that match one or many regular expressions, and outputs only the matching lines.

grep option function

-r search recursively the sub directories

-i ignore word case

-v Invert the sense of matching, to select non-matching lines.

-c count of matching criteria

Type: grep 'joe' file2.txt

now you try using grep on your own. Here is the syntax;

grep 'string1 string2' filename

cat otherfile | grep 'something'

command | grep 'something'

man grep for even more information and options.

remember pressing the letter “q” quits man

2. Combining find and grep - If you want to search every subdirectory beneath the current

directory for the string 'joe', you'd issue a find/grep command like this:

Type: find . -type f -exec grep 'joe' {} \;

End of Lab Exercise

Page 48: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 48

Page 49: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 49

Lab Exercise 4: networking

Purpose:

To discover network setting and use the network to login into

remote servers and copy file to and from them.

Tasks: Students perform the following tasks:

ifconfig

ping

traceroute

telnet and ssh

rlogin, rsh, and rcp

ftp

References: Lecture material

Page 50: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 50

Lab 4: Part 1 - networking – ifconfig, ping, and traceroute

Step Action

1. ifconfig (short for interface configuration)

A system administration utility in UNIX-like operating systems to configure, control, and

query TCP/IP network interface parameters from a command line interface or in system

configuration scripts. You may even see similar commands on network switches.

Type: ifconfig –a (all Ethernet interfaces)

Type: ifconfig eth1 (just Ethernet interface eth1)

2. ping (name comes from active sonar terminology)

The ping command operates by sending Internet Control Message Protocol (ICMP) Echo

Request messages to the destination computer and waiting for a response. How many of

those responses are returned, and how long it takes for them to return, are the two major

pieces of information that the ping command provides. The ping command sends one

datagram per second and prints one line of output for every response received. Round-

trip times and packet loss statistics are calculated and displayed.

option Function

-t ttl Time To Live in ms

-a resolve, if possible, the hostname of an IP address

-c number of ICMP Echo Request messages to send

-I Use this option to specify the source interface (i.e. eth0, eth1, eth2, ect)

-s (size) Set the size, in bytes, of the packet (32 to 65,527)

Try each one of these options, and notice this difference in the outputs.

Type: ping 10.127.70.1

Type: ping 10.127.70.1 –c 3

Type: ping 10.127.70.1 –s 9000

3. traceroute

The traceroute command prints the route that IP packets take to a network host. It is

intended for use in network testing, measurement, and management.

option Function

-6 Explicitly force IPv6 traceouting.

-I Use ICMP ECHO for probes

-T Use TCP SYN for probes

-r Bypass the normal routing tables and send directly to a host on an

attached network.

Try each one of these options, and notice this difference in the outputs.

Type: traceroute 10.127.70.1

End of Lab Exercise

Page 51: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 51

Lab 4: Part 2 – remote access – ssh, ftp, scp, and rsync

Step Action

1. telnet

Telnet is a bidirectional interactive text-oriented (CLI) communication utility that allows

a computer user at one site to make a connection, login and then conduct work on a

computer at another site. For example, you can use the telnet command to run a program

in your directory on a supercomputer thousands of miles away.

Most network equipment and operating systems with a TCP/IP stack support a Telnet

service for remote configuration (including Windows, BSD, Mac OS, Linux, and UNIX).

However, because of serious security issues when using Telnet over an open network

such as the Internet, its use for this purpose usage has waned significantly in favor of

SSH. Most enterprise customers will not allow telnet to be used on the network and

disable the services on most clients and servers. Because of this we will not be doing any

telnet labs.

2. rlogin and rsh

rlogin (remote login), rsh (remote shell) and rcp (remote copy) are three utilities which

allow you to perform tasks on other machines without requiring the usual login

authentication. All three utilities depend upon a .rhosts file located in your /home

directory.

rlogin: Allows you to login to a remote machine. It is nearly identical to telnet in function and

appearance, however if your .rhosts file is setup accordingly, you will be able to login to

your account on another machine without having to enter a userid and password.

rsh: The remote shell command can be used to execute a command on remote host or log into

remote host. With the proper .rhosts file, authentication is not required.

3. ssh

Secure Shell (SSH) is a cryptographic network protocol for secure data communication,

remote shell services or command execution and other secure network services between

two networked computers that connects, via a secure channel over an insecure network.

ssh was designed as a replacement for telnet, rsh, and rlogin which send information,

notably username and passwords, in plaintext.

ssh xxx.xxx.xxx.xxx or ssh fqdn

From a GUI you can use any number of ssh clients like PuTTY.

You have been using ssh this entire time, so all your labs are ssh labs.

End of Lab Exercise

Page 52: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 52

Lab 4: Part 3 – Moving data remotely

1. ftp ftp stands for File Transfer Protocol. File transfer provides a means for you to obtain computer files

(text, image, sound, etc.) from other computers over the network.

ftp can also be used to send (upload) files from your computer to another computer, providing you

have write permission or a real account on the machine you are uploading.

FTP Command options

open <IP Address> open an ftp session to a fqdn or address

close <IP Address> close connection you can also use bye

bin set to transfer for binary and text files

hash display progress during get # for every 1024 bytes

mget multiple get – download files in to current directory

mput multiple put – upload files from current directory

lcd Change the working directory on the local machine

Type: cd /home/YourName

Type: uname –a (record the OS version and CPU type of your host________________)

Type: ftp ftp.emc.com (username: anonymous / password: [email protected])

2. Type: bin (there are 2 modes of ftp ascii for text only and binary for everything, always just use

binary for all your ftp file transfers)

Type: hash (hash places a #### symbol every time 8kb of data is transferred, letting you know

the ftp is moving files and not locked up)

Page 53: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 53

3. Type: pwd

Type: ls

Type: cd /pub/elab/inquiry/v7.3.2.0 (there is a free scsi inquiry utility that EMC publishes)

Type: ls (there is a version for most of the operating systems they support)

Type: mget inq.LinuxAMD64 (download the correct version for your OS)

4. bye (to close our ftp connection to ftp.emc.com)

Type: ls –lia (to verify your file has downloaded)

5. Type: chmod 755 inq.LinuxAMD64 (change permission so you can execute the file)

Type: ./inq.LinuxAMD64 ( ./ tells the OS to look in your current directory to execute the file)

Rename inq.LinuxAMD64 executable and put it where it will always be in out path.

Type: cp inq.LinuxAMD64 /sbin/inq (now we can just type inq no matter where we are)

Page 54: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 54

6. rcp: Remote Copy enables you to copy files between different systems. With the proper .rhosts file, no

authentication is required.

7. scp Secure Copy was designed as a secure replacement for ftp and rcp. SCP 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. SCP will ask for passwords as they are needed for authentication.

Typically, a syntax of scp program is like the syntax of copy (cp):

Copying file to host:

scp SourceFile user@host:directory/TargetFile

Copying file from host:

scp user@host:directory/SourceFile TargetFile

scp -r user@host:directory/SourceFolder TargetFolder

Note that if the remote host uses a port other than the default of 22, it can be specified in the

command. For example, copying a file from host:

scp -P 2222 user@host:directory/SourceFile TargetFile

As the SCP protocol implements file transfers only, GUI SCP clients like WinSCP are rare, as

implementing it requires additional functionality

8. sftp

Compared to the earlier SCP protocol, which allows only file transfers, the SFTP protocol allows

for a range of operations on remote files – it is more like a remote file system protocol. An SFTP

client's extra capabilities compared to an SCP client include resuming interrupted transfers,

directory listings, and remote file removal.

SFTP attempts to be more platform-independent than SCP; for instance, with SCP, the expansion

of wildcards specified by the client is up to the server, whereas SFTP's design avoids this problem.

While SCP is most frequently implemented on Unix platforms, SFTP servers are commonly

available on most platforms.

SFTP is not FTP run over SSH, but rather a new protocol designed from the ground up by the IETF

SECSH working group. It is sometimes confused with Simple File Transfer Protocol.

9. rsync

rsync was originally written as a replacement for rcp and scp to synchronize files and directories

from one location (host) to another while minimizing data transfer by using deltas, to ensure only

changed data is copied.

rsync [OPTION] … SRC [SRC] … [USER@]HOST:DEST

End of Lab Exercise

Page 55: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 55

Page 56: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 56

Lab Exercise 5: local storage and file systems

Purpose:

Examining disks and partitions in Linux, displaying file system

information

Tasks: Students perform the following tasks:

Basic disk usage

Physical Volumes

Manipulating Volume groups

Manipulating Logical volumes

References: Lecture material

Page 57: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 57

Lab 5: Part 1 – File System – fdisk, cfdisk, mkfs, mount, and df

Step Action

Most versions of UNIX-like operating systems support a common way using basic disks. It is

very common to divide disks into logical storage units referred to as partitions, to treat one

physical disk drive as if it were multiple disks. This is a common way of segregating data

based on its’ purpose. For instance when we install Linux on a computer with 1 disk it would

partition it into several units. (/boots, /tmp, /user, /root, /var/log, swap) . A good Windows

administrator would also do something similar as well, putting Windows and Program Files

into one partition, application data into a second partition and Users data into a third partition.

The traditional way of using disk is with master boot record (MBR) partitioning scheme, as

used in DOS, Microsoft Windows and Linux among others on Intel compatible computer

systems. The total data storage space of a hard disk can be divided into at most four primary

partitions. If more than 4 are needed then one would create three primary partitions and an

extended partition, with up to 256 logical volumes in the extended partition. Then each

partition or logical volume can have its’ own unique file system.

For Intel compatible BIOS based system disks with 512-byte sectors, the MBR partition table

entries allow up to a maximum of 2.20 TB sectors × 512 bytes per sector). limitations of MBR

partition tables, which use 32 bits for storing logical block addresses and size information

A file system is an organization of data and metadata on a storage device. Linux supports a

large number of file systems, from journaling to clustering to cryptographic.

The most popular are:

name Attribute

ext Extended file system and was the first created specifically for Linux

ext2 allow for extended file attributes and 2 terabyte drives (Linux)

ext3 like just Ext2 with journaling (keeps track of the changes)

ext4 reduces file fragmentation, allows for larger volumes and files (Linux)

btrfs copy on write file system aimed at implementing advanced features while

focusing on fault tolerance, repair and easy administration. (Linux)

f2fs Flash-Friendly File System for SSD (Linux)

jfs Journaling File System that can be dynamically resized (AIX/OS2/Linux)

VxFS VERITAS File System (or VxFS; called JFS and OnlineJFS in HP-UX)

zfs Is Sun (now Oracle) file system. ZFS and zpools are easy to use, but use a lot of

cpu & ram. Drive pooling, snapshots, and dynamic disk striping

(BSD/SunOS/Mac OS/Linux)

fat FAT file system is a legacy file system which is simple and robust (most OSes)

ntfs New Technology File System is the replacement for FAT on Windows

Page 58: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 58

Step Action

1. Before we can make a file system we need to find block storage device to put the file system

on. There are a number of different ways to do this. The universal fdisk command will work

on almost all UNIX-like OS'es. fdisk can be difficult to use so there are a number of

alternatives depending on OS and distribution.

Type: fdisk –l (notice there are several various sizes devices called /dev/sd*)

Another way is to look into the /proc/scsi/scsi file can to find this info.

Type: cat /proc/scsi/scsi

cfdisk (is a text menu driven system alternative to fdisk)

Various distros of Linux prefer cfdisk instead of fdisk. cfdisk is a Linux partition editor,

similar to fdisk, but with a different user interface . It is part of the util-linux package of Linux

utility programs. If invoked without arguments, cfdisk attempts to read the current partition

table from the disk drive and present its findings.

Type: cfdisk (q quits cfdisk)

2. An easier way of seeing this info is to use EMC’s freely available inquiry command

ftp://ftp.emc.com/pub/elab/inquiry/

Type: inq –h (notice all the options for a SAN attached host to EMC storage)

Type: inq

Type: inq -btl (bus, target, lun address for the storage)

Type: inq -mapinfo (great for usage on a SAN)

Type: inq -dev /dev/sda –page0 (tons of unformatted info)

Page 59: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 59

Step Action

3. mkfs - Makes a file system on an entire device or just a partition

option Function

-t Specifies the type of file system to be built

-c Check the device for bad blocks before building the file system

Type: mkfs –t ext3 /dev/sdb (this command made a ext3 file system on the entire device)

Type: y (to proceed)

4. mount - mount File system

option Function

-a Mount all file systems (of the given types) mentioned in fstab file.

-r Mount the file system read-only.

-w Mount the file system read/write. This is the default

-t used to indicate the file system type ( iso9660 is default)

Type: mkdir /mnt/*YourName_FS* (make a directory to mount your file system)

Type: mount /dev/sdb/ /mnt/*YourName_FS* (mount your new fs to your directory)

Page 60: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 60

Step Action

5. df - display file systems

option Function

-a all - include dummy file systems

-h human - print sizes in human readable format (e.g., 1K 234M 2G)

-k kilobytes – block size = 1024

-T type - print file system type

--direct direct - show statistics for a file instead of mount point

--total produce a grand total

Try each one of these options, and notice this difference in the outputs.

Type: df –k (you can see the usage of your newly mounted file system)

Type: df –Tha (same info but easier to read)

6. Type: cd /mnt/*YourName_FS* (you can now put files on your new fs)

7. ***Note - Intel's proposed replacement for the BIOS using MBR is Extensible Firmware

Interface (EFI) using GUID Partition Table (GPT). GPT is a standard for the layout of the

partition table on a physical hard disk. GPT allocates 64 bits for logical block addresses and

therefore allows a maximum disk and partition size of 264 sectors. For disks with 512-byte

sectors, that would be 9.4ZB. Most current computer support EFI and most operating systems

can now use GPT.***

Page 61: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 61

Lab 5: Part 2 – LVM – lvmdiskscan, pvscan, pvdisplay, and pvcreate

Step Action

Using basic disks with partitions is a quick and easy way of utilizing disk space. In an enterprise

environment when host on a SAN could have hundreds of block devices, it becomes far too

cumbersome to just use basic disks.

Logical volume management or LVM provides a method of allocating space on mass-storage

devices that is more flexible than conventional partitioning schemes. In particular, a volume

manager can concatenate, stripe together, RAID, or otherwise combine partitions into larger

virtual ones that administrators can re-size or move, potentially without interrupting system use.

Volume management represents just one of many forms of storage virtualization; its

implementation takes place in a layer in the device-driver stack of an OS.

Most volume-manager implementations share the same basic design. They start with physical

volumes (PVs), which can be either being hard disks, partitions, or Logical Unit Numbers (LUNs)

of an external storage device. Volume management treats PVs as sequences of chunks called

physical extents (PEs).

The following commands will only work on Linux and HP-UX. Almost all UNIX-like OS’es have

some type of LVM with similar commands and like functionality.

1. lvmdiskscan scans all SCSI, (E)IDE disks, multiple devices and a bunch of other block devices

in the system looking for LVM physical volumes. The size reported is the real device size.

Type: lvmdiskscan

Type: lvmdiskscan -l

2. pvscan - scans all supported LVM block devices in the system

option Function

-e Only show physical volumes belonging to exported volume groups.

-n Only show physical volumes not belonging to any volume group.

-u Show Uniform Unique Identifiers in addition to device special names.

Try each one of these options, and notice this difference in the outputs.

Type: pvscan (once again notice that only one is in use)

3. pvdisplay - allows you to see the attributes of one or more physical volumes

option Function

-m Mapping of physical extents to logical volumes and logical extents.

-c Generate colon separated output for easier scripting.

-s Give a short listing showing the existence of volume groups.

Try each one of these options, and notice this difference in the outputs.

Type: pvdisplay –v (see that only one block device is used by the Logical Volume Manager)

Page 62: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 62

Step Action

4. pvcreate - initializes disk, physical volumes, or partition for use by the Logical Volume Manager

(LVM)

option Function

-u Specify the uuid for the device.

-y Answer yes to all questions

-v verbose output

Type: pvcreate /dev/sdc (this command just initialized that one block device for the LVM)

Type: pvscan (notice now one more block device is ready to be used be the LVM)

Type: pvdisplay –v

Type: pvcreate /dev/sde /dev/sdg (initialized the remaining block devices)

Type: pvscan

Type: pvdisplay –v

5. df - display file systems

Type: df –Tha (your new device doesn’t show up because there is no file system)

Page 63: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 63

Lab 5: Part 3 – Volume Groups – vgcreate, vgextend, vgexport, and vgimport

Step Action

A volume group (VG) is a logical collection of Physical Volumes (PV) into one

administrative unit. For purposeful grouping, of computer storage space that may span

multiple physical devices.

1. vgcreate - vgcreate creates a new volume group using the block special devices

option Function

-l Sets the maximum number of logical volumes allowed in this VG

-p Sets the maximum number of physical volumes allowed in this VG

-s Sets the physical extent size on physical volumes of this volume group.

Type: vgcreate YourName_VG /dev/sdc

2. vgdisplay - display attributes of volume groups

option Function

-A Only select the active volume groups.

-c Generate colon separated output for easier scripting.

-s Give a short listing showing the existence of volume groups.

-v Give a verbose listing showing the existence of volume groups.

Try each one of these options, and notice this difference in the outputs.

Type: vgdisplay (notice the attributes of the VG including the VG size)

Page 64: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 64

Step Action

3. vgextend - vgextend allows you to add one or more initialized physical volumes to an

existing volume group to extend it in size. Moreover, it allows you to re-add a physical

volume that has gone missing previously, due to a transient device failure, without re-

initializing it.

Type: vgextend *YourName_VG* /dev/sde (this added /dev/sde to your VG)

Type: vgdisplay (notice the attributes of the VG including the VG size)

4. vgscan - scan all disks for volume groups and build /etc/lvmtab and /etc/lvmtab.d/*

which are the database for all other lvm commands.

option Function

-l Sets the maximum number of logical volumes allowed in this VG

-p Sets the maximum number of physical volumes allowed in this VG

Type: vgscan –v

5. vgexport - Make volume groups unknown to the system (think snapshots and clones

used to export a volume group production server to a backup server.)

Type: vgexport *YourName_VG*

Type: vgdisplay –v (notice that your vg is now exported, perfect time to take a

snapshot)

Page 65: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 65

Step Action

6. vgimport - Makes a volume group known to the system which has previously been

exported (Import snapshots and clones to a backup server.)

Type: vgimport *YourName_VG*

Type: vgdisplay –v

Page 66: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 66

Lab 5: Part 3 – Logical Volumes – lvcreate, lvdisplay, and lvextend

Step Action

Logical volumes (LV) are mapped onto physical volumes or volume groups (VG). A logical

volume is the storage medium that is associated with a logical disk. It typically resides on one or

more hard disk drives.

1. lvcreate - creates a new logical volume in a volume group

option Function

-i number of stripes

-I stripe size in kilobytes

-l number of logical extents to allocate for the new logical volume.

-L size to allocate for the new logical volume.

-n name of logical volume

-p Set access permissions to read only or read and write.

Type: lvcreate -i 2 -I 8 -L 100 –n *your name_LV* *YourName_VG*

(creates a 100MB Logical Volume on your VG)

2. lvdisplay - Display attributes of a logical volume

option Function

-all Include information in the output about internal Logical Volumes

-c Generate colon separated output for easier scripting

-m Display the mapping of logical extents to physical volumes and physical

extents.

Try each one of these options, and notice this difference in the outputs.

Type: lvdisplay (see all of the logical volumes)

Type: lvdisplay -v /dev/*YourName_VG*/*YourName_LV*

Page 67: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 67

Step Action

3. lvextend - allows you to extend the size of a logical volume.

option Function

-l set the logical volume size in units of logical extents.

-L Extend or set the logical volume size in units of megabytes.

-i Gives the number of stripes for the extension.

-I Gives the number of kilobytes for the granularity of the stripes.

-n Do not perform fsck before extending file system .

-r Resize underlying file system together with the logical volume using fsadm

Type: lvextend -L +50 /dev/*YourName_VG*/*YourName_LV*

Page 68: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 68

4. mkfs - Makes a file system on your new logical volume

Type: mkfs –t ext4 /dev/*YourName_VG*/*YourName_LV*

5. mount - mount File system

Type: mkdir /mnt/*YourName_LV_FS* (make a directory to mount your file system)

To mount your new fs to your directory

Type: mount /dev/*YourName_VG*/*YourName_LV* /mnt/*YourName_LV_FS*

6. df - display file systems

Type: df –Tha (you can see your newly mounted file system and how much is used)

Page 69: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 69

Page 70: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 70

Lab Exercise 6: Networked Storage

Purpose:

Examining disks and partitions in Linux, displaying file system

information

Tasks: Students perform the following tasks:

Networked Storage

Fibre Channel and FCoE

iscsi

NFS (network file system)

References: Lecture material

Page 71: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 71

Lab 6: Part 1 – File level - NFS & CIFS

Step Action

The common ways of accessing networked file storage is to use NFS or CIFS.

Windows hosts use CIFS (also known as SMB) to access a network share by mapping a

network drive. This can be done via the command line with the net use command but is

most commonly done using the GUI itself.

Network File System (NFS) is a distributed file system protocol, allowing a user on a

client computer to access files over a network in a manner similar to how local storage is

accessed. It allows client system mount an exported file system from a server. This server

exporting the NFS mount could be any number of types of hosts, appliances, or storage

arrays like (Linux, Mac OS, UNIX, Windows, Iomega, NetApp, VNX, or Isilon)

1. Suppose we wanted to export the directory, /home from our UNIX-like host. First we

need to edit the /etc/exports file.

Type: ifconfig -a (record the inet address ______.______.______.______)

Type: vi /etc/exports

Add the following line to the bottom of the file, sharing the directory with the client, note

you must replace the xxx.xxx.xxx.xxx with the inet address of your host that you found

using ifconfig -a

add the line: /home xxx.xxx.xxx.xxx (rw,sync,no_root_squash,no_subtree_check)

****note this may be the only line in your /etc/exports file

2. Then verify the edit worked ok by typing

Type: more /etc/exports

3. Type: exportfs –a (enables the export on the server)

Page 72: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 72

Step Action

4. Now the client would mount the export being offered by the server or storage array.

Type: mkdir -p /mnt/nfs/home (create a new mount point for a NFS export on client)

Type: mount xxx.xxx.xxx.xxx:/home /mnt/nfs/home (mounts the export to the dir)

5. You can use the df –Tha command to check that the directory has been mounted to client.

Type: df –Tha

Page 73: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 73

Lab 6: Part 2 – Block level using FC and FCoE

Step Action

Fibre Channel SAN has been around since the early 1990s. Normally when a host is

accessing fibre channel LUNs it does so over a SAN using a hardware Host Bus Adapter

(HBA) for its’ initiator (there are no software fibre channel HBA). If this is the case then all

you have to do on the host is make sure the HBA driver is installed. Most HBAs are made by

Emulex or Qlogic and the drivers are built into most UNIX-like operating systems that support

them. That means there is nothing for us to do on the host except logical volume management

of block devices like we already did in lab 4. All the work is done on the SAN switches in the

form of zoning to create the connection between the HBA initiator and the target port on the

storage array.

FCoE is a relatively new arrival on the network storage scene, and still is not widely

implemented. Most of the time an FCoE LUN would be accessed over an Ethernet SAN using

a hardware Converged Network Adaptor (CNA) acting as the initiator. The labs we have been

doing so far have been done in a virtual environment using virtual machines with local virtual

disks (like scsi hard disks inside a physical computer), so we cannot put a physical CNA in

them and then install the drivers. It is possible to use software CNA initiators in some

operating systems.

DO NOT CONTINUE DOING THE HANDS ON PORTION OF THIS LAB: This is for information purposes only, skip to the next section.

Most server operating systems are capable of acting as an FCoE target, it is quite detailed to

setup. Our customers would be using FCoE to connect to an array like a VNX or VMAX. This

is a virtual lab environment and we do not have an FCoE target for your host to connect to.

NOTE: if you want to practice these FCoE labs you need to first setup an FCoE target on

another host. The page below describes how to do this;

https://access.redhat.com/knowledge/docs/en-

US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/fcoeconfig.html

1. The more common tasks someone may need to perform is setting up a software initiator on the

hosts’ operating system. The steps below demonstrate how to configure the software FCoE

initiator on your Linux host to connect to any type of FCoE target.

First we have to start the data center bridging daemon using the following command:

/etc/init.d/lldpad start

2. For networking interfaces that implement a hardware DCBX client, skip this step and move on

to the next.

For interfaces that require a software DCBX client, enable data center bridging on the Ethernet

interface using the following commands:

dcbtool sc ethX dcb on

Then, enable FCoE on the Ethernet interface by running:

dcbtool sc ethX app:fcoe e:1

Page 74: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 74

Step Action

3. Load the FCoE device now using:

ifconfig ethX up

4. Start the FCoE daemon using:

service fcoe start

5. After configuring the Ethernet interface to use FCoE, It is recommended that you start the

daemons to run at startup, use chkconfig to do this:

chkconfig lldpad on

chkconfig fcoe on

6. Now that you have added new LUNs to your host you will need to get your OS to scan for

them.

echo "- - -" > /sys/class/scsi_host/host0/scan

7. Before we can make a file system we need to find block storage device to put the file system

on. There are a number of different ways to do this. The universal fdisk command will work

on almost all UNIX-like OS’es. fdisk can be difficult to use so there are a number of

alternatives depending on OS and distribution.

fdisk –l (notice there are several various sizes devices called /dev/sd*)

8. mkfs - Makes a file system on an entire device or just a partition

mkfs –t ext3 /dev/sdd (this command made a ext3 file system on the entire device)

y (to proceed)

9. mount - mount File system

mkdir /mnt/YourName_FCoE (make a directory to mount your file system)

mount /dev/sdb/ /mnt/YourName_FCoE (mount your new fs to your directory)

10. df - display file systems

df –Tha (same info but easier to read)

Page 75: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 75

Lab 6: Part 3 – Block level using iscsi

Step Action

iSCSI (the scsi protocol encapsulated in TCP/IP) this makes iSCSI capable of using

existing Ethernet network technology and widely implemented TCP/IP. Since the packets are

using TCP/IP as the transport packets are able of being routed over long distances (unlike

FCoE). iSCSI has been implemented since early to mid-2000s by most operating systems

vendors as a soft adaptor. Even though hardware iSCSI adaptors like HBAs and TOEs (TCP

Offload Engine) are soft initiators are quite common so that is what we will practice setting

up.

DO NOT CONTINUE DOING THE HANDS ON PORTION OF THIS LAB: This is for information purposes only – skip to the next section.

Most server operating systems are capable of acting as an iSCSI target, it is quite detailed to

setup. Our customers would be using iSCSI to connect to an array like a VNX or VMAX. This

is a virtual lab environment and we do not have an iSCSI target for your host to connect to.

NOTE: if you want to practice these iSCSI labs you need to first setup an iSCSI target on

another host. The page below describes how to do this;

https://access.redhat.com/knowledge/docs/en-

US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/iscsi-target-setup.html

1. The more common tasks someone may need to perform is setting up a software initiator on the

hosts’ operating system. The steps below demonstrate how to configure the software iSCSI

adaptor on your Linux host to connect to any type of iSCSI target.

2. Configure the iqn name for the initiator:

vi /etc/iscsi/initiatorname.iscsi

edit or add the lines below

InitiatorName=iqn.2012-10.net.cpd:san.initiator01

InitiatorAlias=initiator01

3. Edit the iSCSI initiator configuration:

vi /etc/iscsi/iscsid.conf

edit or add the lines below

# To manually startup the session set to "manual". The default is automatic.

node.startup = automatic

# To enable CHAP authentication

node.session.auth.authmethod = CHAP

# To set a CHAP username and password for initiator

node.session.auth.username = iscsiadm

node.session.auth.password = iscsiadm123

4. Start iSCSI initiator daemon:

/etc/init.d/iscsid start

chkconfig --levels 235 iscsid on

Page 76: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 76

Step Action

5. Discovering targets in our iSCSI server:

iscsiadm --mode discovery -t sendtargets --portal xxx.xxx.xxx.xxx

xxx.xxx.xxx.xxx:3260,1 iqn.2012-10.net.cpd:san.target01

6. Trying to login with the iSCSI LUN:

iscsiadm --mode node --targetname iqn.2012-10.net.cpd:san.target01 --portal

xxx.xxx.xxx.xxx –login

7. update of iSCSI targets database for the files located in /var/lib/iscsi/ :

cat /var/lib/iscsi/send_targets/ xxx.xxx.xxx.xxx,3260/st_config

8. Checking the status session with the target:

iscsiadm --mode session --op show

9. Checking the UUID for disk:

blkid /dev/sdb1

/dev/sdb1: UUID="71e86162-011d-49f1-9b4a-9f95a277e6b5" TYPE="ext4"

10. Add the next entry in /etc/fstab file:

UUID=71e86162-011d-49f1-9b4a-9f95a277e6b5 /mnt/data ext4 _netdev,rw 0 0

11. With the mount option _netdev the script netfs is responsible of the mount to this device.

Without this option, Linux will try to mount this device before load the network support. We

have to check that netfs is enabled to run in the default runlevels:

chkconfig --list netfs

netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off

12. Now that you have added new LUNs to your host you will need to get your OS to scan for

them.

echo "- - -" > /sys/class/scsi_host/host0/scan

13. Before we can make a file system we need to find block storage device to put the file system

on. There are a number of different ways to do this. The universal fdisk command will work

on almost all UNIX-like OS’es. fdisk can be difficult to use so there are a number of

alternatives depending on OS and distribution.

fdisk –l (notice there are several various sizes devices called /dev/sd*)

14. mkfs - Makes a file system on an entire device or just a partition

mkfs –t ext3 /dev/sdf (this command made a ext3 file system on the entire device)

y (to proceed)

15. mount - mount File system

mkdir /mnt/YourName_iscsi (make a directory to mount your file system)

mount /dev/sdf/ /mnt/YourName_iscsi (mount your new fs to your directory)

Page 77: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 77

Step Action

16. df - display file systems

df –Tha (same info but easier to read)

Page 78: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 78

Suggestions for Further Study

There are a huge amount of resources to learn more about Operating Systems. The more you learn the more you

will see what they all have in common. It is easiest to just download install VMware Player on to your laptop or any

computer you want. http://www.vmware.com/products/player/overview.html

Fully built VMware VMs can be downloaded from the VMware Virtual Appliances Marketplace.

https://solutionexchange.vmware.com/store/category_groups/19

One of the best ways to learn a new operating system is to install it yourself. You can build a new VM in

VMware Player and install the OS by mounting up the ISO in the virtual dvd drive of the VM. The ISO of the install

DVD for operating systems can be found in many places. One of the best central places to find them is:

http://distrowatch.com/ and http://www.freeos.com/Compare

UNIX on the x86 Intel platform: webpage

UNIX System 7 – The root of all UNIX today http://www.nordier.com/v7x86/index.html

Plan 9 - purposed as the successor to Unix at Bell Labs http://plan9.bell-labs.com/plan9/

OpenSolaris - Good to practice Solaris http://www.osdisc.com/products/solaris/openindiana

OpenServer - previously SCO UNIX now owned by UnXis. http://www.sco.com/support/download.html

Minix – Mini UNIX for educational purposes http://www.minix3.org/download/

The biggest BSD distros are: webpage

FreeBSD – Most popular and grandfather to many others http://www.freebsd.org/

NetBSD – Focused on quality, stability, and performance http://www.netbsd.org/

OpenBSD – known open-source code and quality documentation http://www.openbsd.org/

FreeNAS - network-attached storage server for file and block http://www.freenas.org/

Hackintosh – a Apple Mac variant http://www.hackintosh.com/

Some of the most popular Linux distros are: webpage

CentOS – Identical to RHEL, commonly seen at EMC customers http://www.centos.org/

Fedora – very large community and user base http://fedoraproject.org/

Puppy Linux – Tiny 100MB, easy, and extremely friendly http://www.puppylinux.com/

Ubuntu – quite popular and has it’s own spin offs http://www.ubuntu.com/

Mint – A very popular version of Ubuntu http://linuxmint.com/

openSUSE – a popular distro in European datacenters http://www.opensuse.org/

Debian – a father to many other distros http://www.debian.org/

Mageia - Community project fork of Mandriva Linux http://www.mageia.org/

Damn Small Linux – only 50MB with a GUI! http://www.damnsmalllinux.org/

Android – Google’s brand of Linux http://www.android-x86.org/

OpenFiler - network-attached storage server for file and block http://www.openfiler.com/

Other x86 Operating Systems: webpage

Inferno - based on Plan 9 from Bell Labs http://www.vitanuova.com/inferno/downloads.html

BeOS - positioned as a multimedia platform http://www.bebits.com/app/2680

ReactOS- to be binary compatible with Windows http://www.reactos.org/

eComStation - operating system based on IBM OS/2 Warp http://www.ecomstation.com/democd/

Cosmos - is an open source os written in C# http://cosmos.codeplex.com/

MenuetOS - is an OS written entirely in assembly language http://www.menuetos.net/

FreeVMV – Free x86 clone of VMS http://www.freevms.net/article5.html

Page 79: OS Bootcamp Workshop v1.4 -  MR-5CN-GSAPICSOS

EMC Education Services written by [email protected] 79

End of Workshop