You are on page 1of 23

Windows CLI

(Command Line Interface)


Dr Bhanu
CLI vs GUI
• GUI (Graphical User Interface)
• Menu-driven interface - Extremely user-friendly and hence easy to learn
• Just click mouse buttons - Can even be used by toddlers and illiterates
• Provides a pleasant visual environment – desirable feature for most users
• Easy multitasking – Open multiple windows(applications) and switch from one
to another with a simple click of the mouse
• No need to remember any complex commands
• Useful for Office applications, games, surfing the web, ATM, Household
devices (TV, Microwave, Mobile Phone) etc.
CLI vs GUI
• GUI Disadvantages
• Graphical information, by nature, tends to be both larger and more complex
than text-based information
• Uses more system resources
• Requires a larger size OS, Memory, Faster and efficient Graphics card
CLI vs GUI
• CLI (Command Line Interface)

• If you can type fast, the command line will always be faster than a keyboard and
mouse – typing speed is the only limiting factor
• For most tasks it can be a lot faster using a command line than it can be using a GUI.
• Certain tasks can be done 10 to 100 times faster (some are impossible from a GUI )
• Very flexible with the use of “switches” (options)
• Good for “expert” users - can quickly access commands
• Uses the fewest system resources
• Need to memorize the commands – learning curve is steep
• Possibility of command chaining – use pipe and other operators
• Md ccis && dir
CLI vs GUI
• CLI (Command Line Interface) - Advantages

• Ability to go back and look at the history and replicate it on other machine
• Repeatability of commands
• Create scripts that can be used to automate processes
• DOS scripts are used on Windows machines
• Apple scripts are used in Mac machines etc.
• Used always by experts or specialists
• Command Line Interface Applications
• System administration
• Engineering applications
• Scientific applications
How to go to CLI?
• Start  Click on search
Type “cmd” in the search window

Right
click and
select
“Pin to
taskbar”
Command Prompt Window

• Called “Command prompt”


• Change to D drive – Type D: and press enter
• Type md dummy and press enter. Your cursor is at D:\dummy
• Command format : “command” space arguments options
DOS Commands - Basic
• View the contents of a directory
• Dir
• The dir command allows you to see the available files and directories
 in the current directory. The dir command also shows the last
modification date and time, as well as the file size.
• Switches - /p (page), /w (wide format), /s (subdirectory list), /a (all
files including system and hidden files) ………..remember forward slash
• Multiple switches can be used on the same command…..
DOS Commands - Basic
• Version of MSDOS
• Ver
• Time and date commands
• Time, Date – allows you to change. Don’t do!
• Vol – shows serial number including the owner
• Help - help on commands
• Commands are NOT case sensitive
DOS Commands - Basic
• Create a directory
• Md or mkdir
• Md ccis
• Md D:\ccis\ceng\d1
• Changing directories
• CD (Change Directory) is a command used to switch directories in MS-
DOS and the Windows command line.
• Cd
• Cd ccis
• Cd D:\ccis\ceng
DOS Commands - Basic
• Cd – More options
• Cd\- goes to the root drive
• Cd.. - goes back by one level
DOS Commands - Basic
• Echo
• Echo is used to repeat the text typed back to the screen and can be
used to send to a peripheral on the computer, such as a COM port.
• Echo I am fine - whatever is typed after “echo” appears on the console
• Used in general with redirection operators….to create files
• Send messages to peripherals
Redirection operators
1. command > filename
• Redirect command output to a file
2. command >> filename
• APPEND into a file
3. commandA | commandB
• Pipe the output from commandA into commandB
4. commandA & commandB
• Run commandA and then run commandB
5. commandA && commandB
• Run commandA, if it succeeds then run commandB
6. commandA || commandB
• Run commandA, if it fails then run commandB
7. commandA && commandB || commandC
• If commandA succeeds run commandB, if it fails commandC
Echo
• Echo this is my first file > resume.txt
• File resume.txt is created
• Echo I am Person >> resume.txt
• Contents are appended……contents?
• How to see the contents?
• Notepad resume.txt
• Type resume.txt
• More resume.txt
• Would display the contents of a file one page at a time. Pressing space would go to the next
page and pressing enter would go down one line at a time.
• A.txt > con - prn, lpt1 etc.
Deleting a file
• del
• Del a.txt dangerous command…..be careful…..may not recover once deleted
• Del *.txt
• Del ab*.bat
• Del ab?.txt
• Del *.* extremely dangerous……..delete all!!
• Can you delete a directory?
Deleting a directory
• Rd
• Removes an empty directory in MS-DOS. To delete directories with files or
directories within them the user must use the deltree command
• Rd ccis - if empty ….deleted….if not?
• Deltree……if available
Copying files
• COPY is usually used to copy one or more files from one location to
another. However, COPY can also be used to create new files. By
copying from the keyboard console (COPY CON:) to the screen, files
can be created and then saved to disk. 

The first filename you enter is referred to as the source file. The
second filename you enter is referred to as the target file. If errors are
encountered during the copying process, the COPY program will
display error messages using these names.
Copying files
• Copy abc.doc myfile.doc - abc.txt and myfile.doc are same
• Copy a.txt + b.txt c.txt -Concatenate or Append
• Copy *.rtf d:\ccis\it -use wild cards
• Copy c:\windows\*.exe d:\Bhanu\impfiles - drive to drive
• Switches - /v (verify), /b (binary files), /d(decrypt), /y(overwrite?)
Renaming files/directories
• Ren or rename
• Used to rename files and directories from the original name to a new name.
• Ren old_name new_name
• Ren a.txt aa.txt
• Ren *.doc *.rtf
• Ren d:\Bhanu\ccis\it\aa.txt a2.txt
• Ren ccis ccit - Directories
Moving files
• move
• Allows you to move files or directories from one folder to another, or
from one drive to another.
• Moves one or more files to the location you specify. Can also be used
to rename directories.
• Move d:\ccis\a.txt d:\ccis\it\a.txt -just move
• Move d:\ccis\a.txt d:\ccis\it\file1.txt -move & rename
Tree command
• Allows the user to view a listing of files and folders in an easy to read
listing.
• Tree
• Tree /f - show files also
• Tree /a - graphic characters linked connecting lines
Attrib command
• Sets or displays the read-only, archive, system, and hidden attributes
of a file or directory.
• Attrib
• Attrib +r +s a.doc -makes the file read-only and system file
• If you use this command to specify a file as read-only, the file can be
accessed, but not altered or deleted. 
• If a file has an attribute of -R, it can be both read from or written to (it
is referred to as read/write). If a file has an attribute of +R, it can be
read from, but not written to

You might also like