Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Windows Command Line Interface (AKA DOS commands) Prof. Yitzchak Rosenthal.

Similar presentations


Presentation on theme: "1 Windows Command Line Interface (AKA DOS commands) Prof. Yitzchak Rosenthal."— Presentation transcript:

1 1 Windows Command Line Interface (AKA DOS commands) Prof. Yitzchak Rosenthal

2 2 What I did uptown help, help dir dir, dir /w, dir /? fullpath, relative path, dot dot, dot cd, md, rd, rd /s, rd /s/q type what is a binary number ASCII files, binary files diff bet notepad, word, excel, copy, del notepad TODO –.exe files –batch files –dir /od, dir /o-d

3 3 What is the Windows Command Line Interface (CLI)? The windows command line interface (CLI) provides a way to control your computer by typing "English-like" commands instead of clicking on buttons, icons, menus, etc. For example you can use the windows CLI to –start a program –create a folder –remove a folder –copy a file –remove a file –rename a file –etc.

4 4 What is “DOS” The Windows CLI commands are sometimes referred to as "DOS" commands. –DOS was the name of the operating system that predated Windows (it stands for Disk Operating System). –The only way to control DOS was to use these commands –The commands in the modern Windows Command Line interface are very similar to the original DOS commands, but there are some differences and some completely new commands.

5 5 CLI vs. DOS Terminology –Even though it's not totally accurate to call the Windows CLI commands "DOS" commands, we will continue to use that term since many people use that term. –Sometimes we will simply use the term “DOS” without the word commands. The following terms will be used interchangeably –Windows CLI –DOS commands –DOS

6 6 Why should you use the command line interface (i.e. DOS commands) ? Many windows users will never have a need for the DOS commands DOS commands are useful or required for many administrative or programming tasks For example, using DOS commands one can write programs to automate many administrative tasks.

7 7 DOS Commands that we will discuss (there are many others) Basic DOS commands –help –dir [/w][/s][/?][/od][/o-d][/oe][/o-e] etc. –cd –md –rd[/s][/q] –move –copy –xcopy [/s][/e] –del / erase (these are synonyms) –ren –type –tree [/f][/a] –cls –ver –fc –find File and folder paths –dot (i.e..) –dot dot (i.e...) –full path (AKA absolute path) –relative path Types of files –ASCII files –Binary files –"type" only works with ASCII files –notepad vs. word

8 8 DOS Commands that we will discuss (there are many others) Redirection –>overwrite –>>append –|pipe Filter commands (can use with | ) –more –sort Running programs –Filename extensions (eg..txt.doc.xls) –executable files (.exe) –running a program –windows explorer - view | details tools | folder options | view Environment variables –set –set = –path –%VarName% –control panel | system | advanced | environment variables

9 9 More DOS commands File attributes (hidden, read only, archive) –attrib DOS Command –windows explorer - file properties Commands for scripting –rem –echo –echo on –echo off –@ –exit –start –goto command and labels Command line arguments –%1 %2 %3... %9 –shift

10 10 Scripting Commands for if pause echo echo on echo off @ shift

11 11 Programs (AKA “external” DOS commands) notepad cmd regedit

12 12 running / executing starting a program or DOS command is known as “running” the program/command OR “executing” the program/command

13 13 Case In-sensitive DOS commands are case in-sensitive. This means that you can type the commands in either UPPER CASE, lower case OR a mixture of uPpEr AnD lOwEr CaSe. For example the following are all equivalent ways of typing the “dir” command dir DIR dIr DIr dIR

14 14 Type ENTER You must press the ENTER key after typing any DOS command for it to actually do anything.

15 15 Conventions for this presentation This presentation will use the following conventions when describing the commands: –Any part of a command that must be typed exactly will be shown as regular text. (see example below) –Words between “angle brackets” are placeholders which you must fill in when you run the command. –For example the following command is used to delete a file. del The description shows that you must type the word “del” (without the quotes) followed by the name of the file you want to delete. For example to actually delete the file named “myDocument.doc” you would type the following (and then press the ENTER key) del myDocument.doc

16 16 More conventions This presentation will use the following conventions when describing the commands: –If a part of a command is optional it will be shown in square brackets. –For example the following command is used to get help about the DOS commands. help [ ] –The description above shows that you can type the word “help” alone or type the word “help” followed by the name of a specific DOS command. If you type the word “help” alone you will see a list of all the DOS commands and a short description of what each command is used for. Example (don’t forget to press the ENTER key): help You can also type the word “help” followed by the name of a specific DOS command to get more extensive help on that particular command. Example (don’t forget to press the ENTER key): help dir

17 17 THE COMMAND PROMPT WINDOW

18 18 The "command prompt" window DOS commands are entered in a "command prompt" window:

19 19 Starting the command prompt window To start a command window from "Windows XP -Home" choose the following menu choice from the start menu: start | All Programs | Accessories | Command Prompt

20 20 The prompt The "c:\>" in the picture is called the "prompt" (your prompt may look slightly different, such as "d:\>", "c:\somefolder>" or something similar - we'll explain later). The prompt is automatically displayed by the computer. You type your commands after the prompt. In order for a command you typed to do anything, you must press the "ENTER" key. Commands may be entered either in UPPERCASE, lowercase.or MiXeDcAsE

21 21 THE HELP COMMAND

22 22 help command Type "help" follwed by the ENTER key to get a list of the valid commands (output of the "help" command is shown on the following slides)

23 23 Output of help command The help command prints a lot of text to the command window. Some of the text will scroll off the screen. use the scroll bar to view text that has scrolled off of the screen. (see next slide for example).

24 24 Output of help command Output of "help" command is very long and scrolls of the screen. Use the scrollbar to see the rest of the text

25 25 help To get detailed help about a specific command type the word "help" (without the quotes) followed by the name of the command. For example to get detailed help about the "dir" command, type the following: help dir Output of help dir command

26 26 | MORE

27 27 | more To view a lot of output, instead of using the scroll bar, you can force the output of most commands to be displayed one screen at a time. Type the command followed by "| more" (without the quotes), for example: c:\> help | more The vertical bar symbol (also called a pipe symbol) is located on the keyboard above the backslash ( \ ) character. On the keyboard it looks like a vertical line with a break in the middle` This is what you type followed by the ENTER key ` This is the prompt. It is printed by the computer

28 28 output of "help | more" When you use "| more", the output from the command is displayed one screenfull at a time Below is the output of the command "help | more" Press the spacebar to see the next screenfull of output. Press the ENTER key to see the next line of output. To quit seeing the output type "q" (for quit) or Ctrl-C (I’ll explain more about Ctrl-C soon)

29 29 Using “| more” with other commands You can add “| more” (without the quotes) to the end of most commands to have the output of that command displayed one page at a time. For example, we will learn about both the “dir” and “type” commands later, both of which can be combined with “| more”. The following are both legal: dir | more type myfile.txt | more (for this to work, there must be a file named myfile.txt) We will learn more about what the “|” means later.

30 30 "CTRL-C" (i.e. CONTROL-C)

31 31 Stopping programs with Control-C (i.e. Ctrl-c) Sometimes DOS commands may "get stuck" and never complete or take a loooonnnng time to complete. This is sometimes refered to as a program that is "hanging" To terminate any DOS program or command you can press the "Cntrl" key and the "c" key at the same time while the program is running. (try to remember "c" is for "cancel") This key sequence is known as "Control-C" or "Ctrl-C“ For example you can use Ctrl-C to terminate the "more" program instead of typing "q"

32 32 INCREASE THE SIZE OF THE COMMAND WINDOW

33 33 Changing the properties of the command window Another way to see more information at once is to increase the height of the command window To do that, "left click" on the icon in the upper left hand corner of the window and choose "Properties"

34 34 Increasing the height of the command window choose the "Layout" tab. change the value of the "Height" field in the "Window Size" section this is the number of lines of output that is displayed in the command window. (the default value is 24) press the "OK" button

35 35 Apply the changes finally, you will see this dialog box If you choose "Apply properties to current window only" then the next time you start a command window the new window will be the original size If you choose "Modify shortcut that started this window" then then next time that you start a command window it will be the larger size. Make a choice (either is fine) and press the "OK" button.

36 36 result - larger command window

37 37 BASIC COMMANDS (DIR, MD, CD, RD)

38 38 Directories (AKA Folders) In DOS, a "folder" is called a "directory" A folder and a directory are exactly the same thing - the words are interchangeable.

39 39 DIR command The DIR command shows the contents of a directory (AKA folder). This is the same information that you can see in Windows Explorer Simply type the word "dir" followed by the ENTER key The output of the command is shown on the next slide

40 40 OUTPUT OF DIR EXPLAINED (1 of 2) A line with on it indicates a directory name. Line without show file names. These are the names of files and directories (i.e. folders) that are contained in the directory being listed (i.e. C:\) This is the directory (i.e. folder) whose contents are being listed. C:\ means the top directory on the C: drive (AKA the “root” of the C: drive)

41 41 OUTPUT OF DIR EXPLAINED (2 of 2) The date and time are the date/time that the file or directory was created or last modified. These numbers indicate the size of the files in bytes. (Directories don’t display a size.) A file with a size of zero (0) is an empty file (i.e. it has nothing in it).

42 42 Files and Directories The output of the DIR command shows a list of files and directories The date/time at the start of each line is the last time that file or folder was modified. The names that are preceded by " " are directory names. The other names are names of files. For example, in the previous slide –"005-v01-chap2-partII.ppt"is a filename –"AUTOEXEC.BAT"is a filename –"Chap02"is a directory name –"Chap11"is a directory name –"CONFIG.SYS"is a filename –etc.

43 43 One directory (i.e. folder) at a time It is important to understand that the DIR command shows the contents of only one directory (i.e. folder) at a time. The output shown above shows the contents of the highest level folder (also known as the “root”) of the C: drive. You can see the same information in “Windows Explorer” (we’ll show you the output of the dir command compared with what you see with windows explorer)

44 44 Switching Drives To switch the disk drive that you are working with, type the letter for the diskdrive followed by a colon ( e.g. d: ) Don’t leave any spaces between the letter and the colon The prompt will change to show the new drive. You type this The prompt changes to show the new drive name

45 45 Directory of D: The DIR command will now show the contents of the folder at the top of the D: drive (i.e. the “root” of D: ) files and directories in the “root” directory of the D: drive

46 46 Switch back to C: drive To switch back to the C: drive type “C:” followed by ENTER. To switch to any drive by type the drive letter followed by a colon followed by ENTER

47 47 DOS vs. Windows Explorer DOS shows the same files and folders as Windows Explorer does DOS Windows Explorer

48 48 dot (.) and dot dot (..) DOS uses two special directories, dot (.) and dot dot (..), that don’t appear in Windows Explorer. We’ll describe these more later...

49 49 TREE command The TREE command shows the hierarchy of directories You can see the same info from Windows Explorer DOS Windows Explorer

50 50 NAMING DISK DRIVES, DIRECTORIES (AKA folders), AND FILES

51 51 DIR To display the contents of a different folder with DIR, you must specify the name of the directory. EXAMPLE: The following shows the contents of the “accounting” directory that is in the “schoolWork” directory that is in the root of the D: drive: DIR d:\schoolWork\accounting See next slide...

52 52 Example To see the contents of the accounting directory type dir d:\schoolWork\accounting Contents of accounting directory

53 53 Command Line Arguments The information that is specified after the name of the command are called command line arguments Example: In the following command: dir d:\schoolWork\accounting "dir" is the name of the command and "d:\schoolWork\accounting" is a command line argument

54 54 Accessing the hierarchy from DOS The hierarchy of disk drives, folders and files that is accessible from Windows Explorer is also accessible from DOS However you must how to name the following from DOS –disk drives –directories –files

55 55 Disk drive names DOS uses a single letter followed by a colon to name each disk drive. These are the same names that Windows Explorer shows in parentheses (see next slide). –A:is usually reserved for the floppy drive –C:is usually reserved for a local hard drive –Other drive letters are either for other local hard drives drives that are on another computer but which are accessible over the network Other types of drives such as CD-ROM or DVD drives.

56 56 Lets see Windows Explorer again (continued on next slide) DOS drive letters

57 57 Path to a file or folder The location of a particular file or directory is specified in DOS using a "path" A “full path” (or "absolute" path) is comprised of –the name of a disk drive that the file or folder is on, backslash ( \ ) characters, folder names and an optional file name. Example D:\otherStuff\NTFSDOS3\readme.txt drive letterfolder names file name

58 58 Example explained The example on the previous page is repeated here D:\otherStuff\NTFSDOS3\readme.txt This path represents the "readme.txt" file that is stored in the "NTFSDOS3" folder which is in turn stored in the "otherStuff" folder on the D: drive

59 59 Backslash (\) vs. Forward slash (/) Don't confuse the backslash (\) with the forward slash (/) ! On standard keyboards: –the backslash (\) is located directly above the ENTER key. –the forward slash (/) is located next to the shift key on the right hand side of the keyboard forward slash backslash

60 60 backslash in filenames forward slash for command options backslash is used for naming files and directories forward slash is used to provide options to DOS commands (we'll cover this later)

61 61 spaces in filenames If any folder or filename in a path contains spaces, you must surround the entire path with quotes when using it in a DOS command. Example dir "c:\my folder\my file.txt"

62 62 The root The top level of any disk drive is called the "root" of the disk drive. The root is indicated by a single backslash ("\") character. For example: –the root of the C: drive is C:\ –the root of the A: drive is A:\ –the root of the D: drive is D:\ –etc.

63 63 Trees, root, parent, child

64 64 The "current directory“ or “working directory” Windows –As noted above, the right hand pane of Windows Explorer shows the files that are in the folder which is currently selected in the left hand pane. –You can think of the currently selected folder as the "current folder" or "current directory". –From the snapshot on the previous slide, "NTFSDOS3" is the "current folder" DOS –In a similar way DOS uses the concept of a currently selected directory otherwise known as "the current directory" (sometimes the "current directory" is called the "working directory").

65 65 Which directory is the working directory? By default, the DOS prompt indicates which directory is the current directory, also known as the “working” directory. The prompt in the slides looked like:C:\> –"C:" indicates that the current directory is on the C: drive. –"\" after the colon indicates that the current directory is the top level directory (on the C: drive). –">" is not part of the name of the current directory. It is simply indicates the end of the prompt.

66 66 DOS command options and switches Most DOS commands can be run in different ways by specifying “options” (also known as “switches”). You specify an option by typing a forward slash (/) after the command name followed by one or more letters or characters that specify which option you want to use. See example on next slide

67 67 DIR /w The /w option for the DIR command shows the output in a “wide” format. Execute the command by typing “dir /w” output of “DIR” command

68 68 DIR /?

69 69 DIR /on

70 70 DIR /o-n

71 71 DIR /od

72 72 DIR /o-d

73 73 MD (make directory) command Use the MD command to make a new directory that will be stored under the current directory. The syntax is MD For example the following will create a directory named "entertainment" that is stored under the current directory md entertainment

74 74 MD command has no output If the MD command is successful it does not display any output

75 75 See the new directory To see the new directory run the DIR command (output of DIR command)

76 76 CD command (change the current directory) Use the CD command to change the current directory. The syntax is CD For example the following will change the current directory to the new "entertainment" directory. cd entertainment

77 77 CD command - changes the prompt If the CD command is successful it does not display any output However the prompt changes to reflect the new "current directory"

78 78 CD to a full path

79 79 CD to a longer full path

80 80 CD to a folder “below” the current folder

81 81 CD to the parent directory

82 82 CD to the parent of the parent directory

83 83 The contents of an “empty” directory

84 84 CD to a sibling directory by way of parent

85 85 “Full path” vs. “relative path”

86 86 drive letter

87 87 : (change drive command)

88 88 CD to a folder on a different drive

89 89 Each drive remembers its working directory

90 90 Making a directory (MD) using a full path or a relative path

91 91 OTHER COMMANDS

92 92 CLS Command Type the CLS command followed by ENTER to clear the screen.

93 93 Type

94 94 ASCII files vs. Binary Files

95 95 Difference between Notepad and Word

96 96 TODO tree hierarchy – parent, child, root, leaf help dir –options / switches –optional parts of command

97 97 wildcards * and ? dir with wildcards Files, extensions copy del vs, rd.exe files path rd ren set cmd /k

98 98 APPENDICES

99 99 MORE ABOUT DISK DRIVES

100 100 Fixed drives vs Removable Media drives There are two types of drives –Fixed Drives for example a hard drive –Removable media drives for example a floppy disk drive, CDROM drive or DVD drive

101 101 Removable media drives

102 102 Disk Drives and Media Examples of Disk Drives –Hard Disk drive –Floppy disk drive –CDROM drive –DVD drive Examples of Disk Drive Media –floppy disk –CDROM disc –DVD disc

103 103 COMPARING FILES date/time stamps and files sizes FC command

104 104 Date/time stamps and file sizes If two files have the same date/time and the same exact file size, then they probably contain the same exact information. However, it is possible that they contain different information The FC (file compare) command compares two files to see if they are exactly the same. This will tell you if two files are the same even if they have different date/time stamps. Example: FC file1.txt file2.txt For complete information on the FC command run FC /? or HELP FC

105 105 CONTROL CHARACTERS

106 106 Control characters Control-C is an example of a “control character” There are 26 control characters, one for each letter. There is no distinction between capital and lowercase letters: Ctrl-C (capital “C”) is the same as Ctrl-c (lowercase “c”) Some control characters have special meaning. For example: –Ctrl-H is another way of typing a backspace character (try it out in a command window) –Ctrl-M is another way of typing the ENTER key (try typing “dir” followed by ctrl-M) Sometimes control characters are shown with a ^ character followed by the letter. For example control-A can be shown as ^A

107 107 Control characters and ASCII The 26 control characters correspond to the first 26 numbers in the ASCII table. TODO: talk about ASCII


Download ppt "1 Windows Command Line Interface (AKA DOS commands) Prof. Yitzchak Rosenthal."

Similar presentations


Ads by Google