1 / 107

Windows Command Line Interface (AKA DOS commands)

Windows Command Line Interface (AKA DOS commands). Prof. Yitzchak Rosenthal. 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,

santos
Télécharger la présentation

Windows Command Line Interface (AKA DOS commands)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  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. 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. 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. 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. 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. Basic DOS commands help help <command name> 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 DOS Commands that we will discuss(there are many others)

  8. 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 <var name> set <var name> = <value> path %VarName% control panel | system | advanced | environment variables DOS Commands that we will discuss(there are many others)

  9. 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 More DOS commands

  10. Scripting Commands • for • if • pause • echo <message> • echo on • echo off • @ • shift

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

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

  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. Type ENTER • You must press the ENTER key after typing any DOS command for it to actually do anything.

  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 <file name>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. 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 [<command name>] • 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): helpYou 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. THECOMMAND PROMPTWINDOW

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

  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. 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. THEHELPCOMMAND

  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. 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. 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. help <command> • 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 dircommand

  26. | MORE

  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. 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. 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. "CTRL-C" (i.e. CONTROL-C)

  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. INCREASE THE SIZEOF THECOMMAND WINDOW

  33. Changing the propertiesof 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. 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. 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. result - larger command window

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

  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. 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. OUTPUT OF DIR EXPLAINED (1 of 2) 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) These are the names of files and directories (i.e. folders) that are contained in the directory being listed (i.e. C:\) A line with <DIR> on it indicates a directory name. Line without <DIR> show file names.

  41. OUTPUT OF DIR EXPLAINED (2 of 2) 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). The date and time are the date/time that the file or directory was created or last modified.

  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 "<DIR>" 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. 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. 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. 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. 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. DOS vs. Windows Explorer DOS DOS shows the same files and folders as Windows Explorer does Windows Explorer

  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. TREE command DOS • The TREE command shows the hierarchy of directories • You can see the same info from Windows Explorer Windows Explorer

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

More Related