CTEC1335/2008F Using DOS ========= From the Start menu, choose Run, then enter: cmd Initially, the window will be set to a current drive and a current working directory (c.w.d.) on that drive. Each command prompt always has a current drive and c.w.d. Each command prompt has a c.w.d. for each drive on your computer. The prompt displays your current drive and c.w.d. For example, C:\Documents and Settings\Mike Boldin>_ ^^^ ^ ^ ^ ^^ ||| | | | || ||| | | | |Blinking cursor (waiting for command) ||| | | | | ||| | | | Prompt character ($G) ||| | | | ||| A top level directory| A subdirectory ||| immediately under | ||| root Separator ||| ||The root directory -- top of the drive || || |Separator | Current drive letter (C -- this is typically the active primary partition on the hard disk where Windows is installed) In the above example, C is the current drive \Documents and Settings\Mike Boldin is the c.w.d. on the drive C Each hard disk partition or physical disk or network share typically have a unique drive letter. For example, the primary partition of your hard disk is typically drive C. Floppy drives use A and B. CD-ROM/DVD-ROM/CD-RW/DVD-RW drives use D or whichever letter is available after your hard disk partitions are assigned a letter. On Windows NT operating systems (NT3.x,NT4,2000,XP,2003 Server,Vista, 2008 Server) the Disk Administrator tool (on XP, Administrative Tools -> Computer Management -> Disk Management) allows you to assign drive letters to each physical drive or partition. On every Windows, when you connect to a network share, you can choose the drive letter that is used. Each drive has a "root" (topmost) directory. Top-level directories are created off root. Subdirectories can be created in top-level directories. All modern operating systems have "hierarchical filesystems", which allow you to organize your files in directories and subdirectories. If you sketch the hierarchy, you start from root and draw downwards. It looks like an "upside-down tree." For example, C | / | +--------------+--------------+---------------------------+-- . . . | | | | WINDOWS boot.ini Program Files Documents and Settings | | | +----+------+-- . . . . . . +----------------+---+-- . . . | | | | win.ini SYSTEM32 All Users Mike Boldin | | | gdi32.dll . . . +-----------+-- . . . . . . | | Desktop Start Menu | | +-- . . . . . . | Command Prompt.lnk This is a partial sketch of a typical C drive. Windows XP is installed in the WINDOWS directory, a top-level directory off the root of C drive. There are also a few, mostly hidden and system, files in the root directory, such as boot.ini (the NT boot loader configuration file). WINDOWS contains many files (such as win.ini) and subdirectories, such as SYSTEM32, which in turn contains its own files and subdirectories. Similarly, the "Program Files" folder contains many subfolders. (I will use "directory" and "folder" interchangeably -- "directory" is a DOS/ command line term, and "folder" is a Windows/graphical term.) Similarly, the "Documents and Settings" folder contains an "All Users" subfolder, which contains items that all users share (e.g., start menu, desktop, etc.) Each user (e.g., Mike Boldin) has his or her own personal folder/home directory, which contains files and subdirectories specific to that user. Pathnames --------- Each file or folder/directory has a name, called a filename or folder name/directory name. Each file or folder/directory also has a location in your Windows filesystem, which is made up of one or more drives/partitions. When you combine the location of a file with its name, you get what is called a "pathname". There are two types of pathnames: absolute (full) and relative. Absolute pathnames on Windows always begin with a drive letter, colon (:, a separator), and backslash (\, meaning the root directory of that drive). Then, any directories and subdirectories are listed, separated by backslash characters. For example, in the above example, the absolute pathnames for each file and folder shown are: C:\ C:\WINDOWS C:\WINDOWS\win.ini C:\WINDOWS\SYSTEM32 C:\WINDOWS\SYSTEM32\gdi32.dll C:\boot.ini "C:\Program Files" "C:\Documents and Settings" "C:\Documents and Settings\All Users" "C:\Documents and Settings\Mike Boldin" "C:\Documents and Settings\Mike Boldin\Desktop" "C:\Documents and Settings\Mike Boldin\Desktop\Command Prompt.lnk" "C:\Documents and Settings\Mike Boldin\Start Menu" NOTE: pathnames which contain at least one space in them must be enclosed in double quotes ("") Using the absolute pathname will *always* give you access to a file or folder, no matter what your current drive and/or c.w.d. is. Relative pathnames, on the other hand, depend on your current drive and c.w.d. A relative pathname may begin with a drive letter and a colon, but never with a drive letter colon and backslash (that's an absolute pathname). Example 1 If my current drive is C and my c.w.d. is my home directory, "C:\Documents and Settings\Mike Boldin", then the relative pathnames for all the files listed above are: ..\.. for C:\ ..\..\WINDOWS for C:\WINDOWS ..\..\WINDOWS\win.ini for C:\WINDOWS\win.ini ..\..\WINDOWS\SYSTEM32 for C:\WINDOWS\SYSTEM32 ..\..\WINDOWS\SYSTEM32\gdi32.dll for C:\WINDOWS\SYSTEM32\gdi32.dll ..\..\boot.ini for C:\boot.ini "..\..\Program Files" for "C:\Program Files" .. for "C:\Documents and Settings" "..\All Users" for "C:\Documents and Settings\All Users" . for for "C:\Documents and Settings\Mike Boldin" (the c.w.d.) Desktop or .\Desktop for "C:\Documents and Settings\Mike Boldin\Desktop" "Desktop\Command Prompt.lnk" or ".\Desktop\Command Prompt.lnk" for "C:\Documents and Settings\Mike Boldin\Desktop\Command Prompt.lnk" "Start Menu" or ".\Start Menu" for "C:\Documents and Settings\Mike Boldin\Start Menu" What you should learn from these examples: 1. . means c.w.d. 2. .. means "parent directory", i.e., go up one level in the hierarchy 3. To go down one level in the hierarchy, just specify a subfolder name. Example 1A - Absolute/Relative Pathnames on the Same Drive If we want to access files or folders on the same drive, we can leave out the drive letter and colon, and just start from the root directory -- a special kind of absolute/relative hybrid pathname. THE KEY IS: YOU WANT TO MINIMIZE TYPING (because excessive typing tends to cause nasty things like Carpal Tunnel Syndrome!) If the c.w.d. is the same as for Example 1, the cases where using such a pathname would make sense are: \ for C:\ \WINDOWS for C:\WINDOWS \WINDOWS\win.ini for C:\WINDOWS\win.ini \WINDOWS\SYSTEM32 for C:\WINDOWS\SYSTEM32 \WINDOWS\SYSTEM32\gdi32.dll for C:\WINDOWS\SYSTEM32\gdi32.dll \boot.ini for C:\boot.ini "\Program Files" for "C:\Program Files" Example 2 If your c.w.d is C:\WINDOWS list the pathname requiring the minimum amount of typing and its type to access the files shown in the hierarchy. \ for C:\ (absolute/relative) . for C:\WINDOWS (the c.w.d., relative) win.ini for C:\WINDOWS\win.ini (relative - simple filename) SYSTEM32 for C:\WINDOWS\SYSTEM32 (relative - simple subfoldername) SYSTEM32\gdi32.dll for C:\WINDOWS\SYSTEM32\gdi32.dll (relative) \boot.ini for C:\boot.ini (absolute/relative) All others are absolute/relative. If you want to access files or folders on another drive, you need to know the c.w.d for that drive. Then you can make a decision whether to use an absolute or relative pathname. Absolute pathnames for files on another drive always begin with the drive letter, colon and backslash. Relative pathnames for files on another drive always begin with the drive letter and colon. (There are no absolute/relative hybrid pathnames for accessing files on other drives.) If my current drive was D, my c.w.d. on D was \work, and the c.w.d. on C was \WINDOWS\SYSTEM32, then the pathnames that require the minimum typing for the files and folders on drive C are: C:\ (absolute) C:.. for C:\WINDOWS (relative) C:win.ini for C:\WINDOWS\win.ini (relative) C: or C:. for C:\WINDOWS\SYSTEM32 (relative) c:gdi32.lib for C:\WINDOWS\SYSTEM32\gdi32.dll (relative) C:\boot.ini (absolute) For all others, use the absolute pathnames. DOS Commands for Navigating the Filesystem ------------------------------------------ When typing commands and pathnames, RULE NUMBER ONE IS: "THE TAB KEY IS YOUR FRIEND!" Microsoft introduced tab key completion into Windows 2000, although it was not activated by default. Windows XP, 2003 and Vista do have it activated, and it is very useful. When pressing Tab, it scrolls through the list of available file and folder names. It is also has a search-like function, in that if you type the letter S first, then press Tab, it will scroll through all files beginning with S. Tab key completion can be used for both absolute and relative pathnames. For example, to type the absolute pathnames of the files above, the typical keystrokes are as follows. Keystrokes and key combinations are in square brackets; keystrokes may vary on your system, depending on what other files and folders exist. [C][Shift+:][\] for C:\ (no Tab key completion required here) [C][Shift+:][\][W][Tab] for C:\WINDOWS [C][Shift+:][\][W][Tab][\][W][I][N][Tab] for C:\WINDOWS\win.ini [C][Shift+:][\][W][Tab][\][S][Y][Tab][Tab][Tab] for C:\WINDOWS\SYSTEM32 [C][Shift+:][\][W][Tab][\][S][Y][Tab][Tab][Tab][\][G][D][Tab][Tab] for C:\WINDOWS\SYSTEM32\gdi32.dll [C][Shift+:][\][B][O][Tab] for C:\boot.ini [C][Shift+:][\][P][R][Tab] for "C:\Program Files" (notice that [Tab] automatically adds the quotes) [C][Shift+:][\][D][O][Tab] for "C:\Documents and Settings" [C][Shift+:][\][D][O][Tab][\][A][Tab] for "C:\Documents and Settings\All Users" etc. Both commands and pathnames are case-insensitive on Windows, meaning that you can type them all lowercase, all capitals, or a combination of the two. CD [Enter] will tell you the c.w.d. on the current drive drive-letter: [Enter] will change to another drive. "drive-letter" ranges from A to Z, and depends on how many drives/partitions/network shares are active on your system. CD drive-letter: will tell you the c.w.d. on another drive CD folder-pathname will change your c.w.d. on the current drive. "folder-pathname" can be an absolute, relative, or hybrid pathname of an existing folder. CD drive-letter:folder-pathname will change your c.w.d. on another drive, but does not change to that drive. DIR will list all non-hidden, non-system files and folders in the c.w.d. on the current drive. DIR /A will list all files and folder, including hidden and system ones, in the c.w.d. DIR /A:D will list only folders in the c.w.d. (including hidden and system ones) DIR /A:H will list hidden files and folders in the c.w.d. DIR /A:S will list system files and folders in the c.w.d. DIR /A:R will list read-only files and folders in the c.w.d. DIR pathname will list information about the given "pathname", which can be absolute, relative or hybrid. If "pathname" refers to a file, it will list that file only. If "pathname" refers to a folder, it will list files and subfolders in that folder. DIR drive-letter: will list files and folders in the c.w.d. on another drive. You can combine DIR with a drive-letter, pathname, and switches. Switches are options that make any command behave slightly differently, and typically begin with slash (/), but may begin with a dash (-). To find out all available switches for any command, type the command with the /? switch. For example, DIR /? Other useful switches for DIR are: /P pause after each screenful of information (useful if there are a lot of files and folders) /S list the contents of subfolders, including a summary/total at the end (useful for searching for files or for calculating how much disk space a folder and its contents require) /O:D sort files and folders by the date/time that they were last modified /B list file and folder names only, no extra info. Useful for generating a list of files and/or folders to copy or archive, for example. ===