Upload
amice-holland
View
220
Download
0
Embed Size (px)
DESCRIPTION
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part. Learning OutcomesLearning Outcomes Open the Windows 7 or Windows 8 Command Prompt in the context of a Standard user or Administrator. Use various techniques to use commands at the Windows Command Prompt. Enter CLI commands at OS X’s Terminal window.
Citation preview
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Survey of Operating Systems, 4/eCh
apte
r
The Command-
Line Interface
9
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
“”
The Windows Command Prompt tool, and many of its commands, might seem boring or even relatively useless at first glance, but as anyone who has ever used the Command Prompt very often can tell you there’s much to love!
Tim FisherIn an article at about.com titled 21 Command Prompt Tricks and Hacks
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Learning Outcomes
Open the Windows 7 or Windows 8 Command Prompt in the context of a Standard user or Administrator.
Use various techniques to use commands at the Windows Command Prompt.
Enter CLI commands at OS X’s Terminal window.
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Introduction to the Windows Command PromptLO 9.1
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
The Windows Command Prompt is Not MS-DOS
MS-DOS was a small OS It had no security features It had a simple CLI and no native GUI The MS-DOS command interpreter was command.com The Command Prompt command interpreter is
cmd.exe Command Prompt is subject to Windows security
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
The Windows Command Prompt is Not Windows PowerShell
PowerShell is a CLI scripting environment for advanced users
PowerShell accepts some Command Prompt commands PowerShell works with three other types of commands Windows Command Prompt only accepts text as input PowerShell accepts text as well as software objects as input
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Opening Windows 7 Command PromptsOpen the Standard-User Command Prompt from the Accessories folder on the Windows 7 Start Menu
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Opening Windows 7 Command PromptsThe Windows 7 Command Prompt for the Standard-User context
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Opening Windows 7 Command PromptsOpen an Administrator Command Prompt in Windows 7From the Accessories menuright-click on Command Promptand select Run as administrator
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Opening Windows 7 Command PromptsThe Windows 7 AdministratorCommand Prompt
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Opening Windows 7 Command PromptsThe Windows 7 Safe ModeCommand Prompt
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Opening Windows 7 Command PromptsOpen the System Recovery Command PromptBoot from the Windows 7 disc and select Repair your computerto access Recovery Options
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Opening Windows 7 Command PromptsFrom the System Recovery Options menu select Command Prompt
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Windows 8 Command PromptsSelect Command Prompt from the Power User menu
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Windows 8 Command Prompts
Windows 8Standard-User Command Prompt
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Windows 8 Command Prompts
Windows 8AdministratorCommand Prompt
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Windows 8 Command Prompts
Windows 8RecoveryCommand Prompt
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Success at the Windows Command PromptLO 9.2
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
How does the Command Prompt use letter case?
Windows is case-aware, but not case-sensitive It will preserve letter case for file and folder names It does not require case to match when referencing
files Commands are interpreted by letter, not case To Windows (and the Command Prompt) dir is the
same as DIR
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
How does the Command Prompt interpret a command?
Command Prompt receives command Locates the command’s program code Loads the program code into memory Passes options from the command line to the program Command Prompt parses the command and options Spaces separate parameters Command Prompt issues error messages
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
The Command Prompt issues errormessages when commands are entered incorrectly
How does the Command Prompt interpret a command?
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
How is a program found and loaded? Command interpreter locates command’s program code It first checks if the program is an internal command Internal commands are stored in the operating system
code If no match, it searches the current directory Then searches paths described in the registry See the search paths used by Windows using the path
command
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Use the path command to see theWindows search paths
How is a program found and loaded?
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Type help and press ENTERSeveral pages scroll off the screen
Using the Help Command with Redirection
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Repeat the help commandand pipe it to more:help | morePress SPACEBAR to scroll onewindow at a time or pressENTER to display one line at a time
Using the Help Command with Redirection
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Repeat the help commandand redirect its output to a file:help > help.txtOpen the file in Notepad:notepad help.txt
Using the Help Command with Redirection
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
To find the syntax for the xcopy command enter this:xcopy /?
What is the Correct Syntax?
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
To find the syntax for the robocopy command enter this:robocopy /?
What is the Correct Syntax?
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Batch Files at the Command Prompt A text file that contains commands Batch files automate tasks Windows batch files should use the cmd extension The bat extension is for MS-DOS and very old
versions of Windows Both types will run in the Command Prompt
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Working with Files and Directories File and Directory Basics
Do not use reserved characters in a directory or file name Do not use names reserved by Windows in directory or file
names Use meaningful names Do not delete existing file name extensions when
renaming Use wildcards at the Command Prompt
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Working with Files and Directories Understand File Attributes
Read-only Archive System Hidden Volume Label Directory
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
The attrib command shows the attributes forfiles in the Documents directory.
File Attributes
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Managing Filesand DirectoriesThe dir command shows a listing of files and directories in the user’s home directory
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Managing Filesand DirectoriesCopy all text files from the home directory to the Documents directory:
copy *.txt documents
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Managing Filesand DirectoriesMove down one level down into the Documents directory:
cd documents
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Managing Filesand DirectoriesCheck that the files were copied:dir
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Managing Filesand DirectoriesCreate a directory in the Documents directory:md manuals
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Managing Filesand DirectoriesCreate a directory while copying the contents of the of the manuals directory into mybackup:xcopy manuals mybackup
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Managing Filesand DirectoriesUse robocopy to copy the mybackup directory into a directory named newbackup:robocopy mybackup newbackup
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Managing Filesand DirectoriesSee what was copied into newbackup:dir newbackup
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Working with Files and Directories Robust copying with robocopy
Sophisticated CLI file/directory copy command Provides a detailed report of the results Indicate source and destination: drive:\path or \\servername\
share\path It copies all files within a source No file names in source of destination File names can be used elsewhere on the robocopy command line File names must be after the source and destination and before
options unless part of an option
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Using Terminal in OS X
LO 9.3
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Introduction Terminal window is OS X CLI OS X security applies to Terminal Terminal shares features with other CLIs
Internal and external commands Uses command-line delimiters and options BASH command interpreter Search paths Supports batch files Many commands identical to Linux Terminal is case-sensitive and case-aware
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Launch TerminalApplications | Utilities | Terminal
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Launch TerminalAdd Terminal to the Dock
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
The Terminal WindowThe Terminal window(on right) with two tabs Shell menu open on left
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Shell Commands in TerminalPress TAB key twicePress Y to continue
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Shell Commands in TerminalA listing of the user’s home directory (at top) in TerminalA Finder window (bottom) open to the same directory
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Using the ManCommandDisplay the manpage for the ls command:man ls
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Using the ManCommandList both hidden and nonhidden files and directories:ls -a
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Using the ManCommandList both hidden and nonhidden files and directories and identify directories with a forward slash (/):ls -aF
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Using the ManCommandChange to the parent directory:cd ..Change to the Home directory:cd ~Change to the Documents directory:cd Documents
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Command CompletionUse the Tab keyto trigger commandcompletion
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner. This document may not be copied, scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
Creating and Navigating Directories