1. Lesson objectives
Teach students to understand basic commands when interacting with the operating system through Command Prompt.
Students can manipulate commands on files/directories.
2. Introduction to the Command Prompt
Today, the operating systems on most personal computers support a Graphic User Interface (GUI) program. Thereby, operations on the computer can be performed simply.
In addition, we can perform most of the tasks on the computer with Command Line Interface or CLI. The command line interface in Windows OS is called Command Prompt.
3. Tutorial to use Command Prompt
To use CMD, press Windows + R key combination -> Run dialog box appears -> enter cmd -> click OK.
The Command Prompt window displays.
Some basic commands in CMD:
|1||DRIVE:||Change current drive|
|2||DIR [drive:][path][filename] /P /W /S /A||Displays a list of files and subdirectories in a directory. /P: Pauses after each screenful of information. /W: Uses wide list format. /S: Displays files in specified directory and all subdirectories. /A: Displays files with specified attributes. (/AH: Hidden files; /AR: Read-only files; /AS: System files; /AA: Files ready for archiving)|
|3||CD [/D] [drive:][path] CD [..]||Displays the name of or changes the current directory. CD.. Specifies that you want to change to the parent directory. CD\ switch back to the root directory|
|4||MKDIR [drive:]path MD [drive:]path||Creates a directory.|
|5||RENAME [drive:][path]filename1 filename2. REN [drive:][path]filename1 filename2.||Renames a file or files.|
|6||TREE [drive:][path] [/F] [/A]||Graphically displays the folder structure of a drive or path. /F Display the names of the files in each folder. /A Use ASCII instead of extended characters.|
|7||RD [/S] [/Q] [drive:]path||Removes (deletes) a directory. /S: Removes all directories and files in the specified directory in addition to the directory itself. Used to remove a directory tree. /Q: Quiet mode, do not ask if ok to remove a directory tree with /S|
|8||COPY CON [path]\filename||Create a new file F6 or Ctrl + Z: save new file Ctrl + C: cancel file creation|
|9||TYPE [drive:][path]filename||Displays the contents of a text file or files.|
|10||REN [drive:][path]filename1 filename2||Renames a file or files.|
[filename_01] + [filename_02] [new_filename]
|Merge contents of files|
|12||COPY [source_path] [destination_path]||Copy files|
|13||MOVE [drive:][path]filename1[,…] destination||Moves files and renames files and directories.|
|14||DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names||Deletes one or more files.|
|15||ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] [+O | -O] [+I | -I] [+X | -X] [+P | -P] [+U | -U] [drive:][path][filename] [/S [/D]] [/L]||Displays or changes file attributes. Xem/thay đổi thuộc tính tập tin/thư mục +: Sets an attribute. -: Clears an attribute. A: Archive file attribute, read-only file attribute. H: Hidden file attribute, S: System file attribute.|
|16||DATE [/T | date]||Displays or sets the date.|
|17||TIME [/T | time]||Displays or sets the system time.|
|18||CLS||Clear the screen.|
|19||FORMAT [DRIVE:]||Formats a disk for use with Windows.|
|20||LABEL [DRIVE:] [LABEL]||Creates, changes, or deletes the volume label of a disk.|
|21||VOL [DRIVE:]||Displays the disk volume label and serial number, if they exist.|
|22||SHUTDOWN -s -t [a] (a is second)||Turn off the computer|
4. How to user PowerShell on Windows
PowerShell is a command line interface program that is gradually replacing Command Prompt on Windows. PowerShell will work on the .NET environment and the .NET Framework includes commands and programming languages.
In parallel with PowerShell, Windows also developed Windows Power Shell ISE. ISE (Integrated Scripting Environment) includes a graphical user interface for programming and integrates various tools that support manipulation with Power Shell.
Windows PowerShell has been developed by Microsoft for quite some time. However, an updated version with many improved features has been introduced since Windows 8.1 and Windows Server 2012.
To start PowerShell on Windows, press the Windows + R key combination, enter “powershell” to open the Windows PowerShell interface.
Windows PowerShell program interface.
Commands on PowerShell, students can refer here.
5. Requirement of practice
Let’s create a directory tree in the image below:
Note: Do not use the “\” in Command Prompt, knowing that when entering Command Prompt, we see:
a. Use the command to create 2 files GiaoTrinh.txt and BaiTap.txt with the following content in the directory C:\QLHVIEN\TINHOC. The contents of the GiaoTrinh.txt file are as follows: “Textbook of TH-PCMT for IT students“. The content of the BaiTap.txt file is as follows: “Manipulating command line commands on Windows“.
b. Merge GiaoTrinh.txt and BaiTap.txt to NoiDung.txt.
c. Move all newly created files to C:\QLHVIEN\TINHOC\CANBAN.
d. Rename the file NoiDung.txt to Content.doc.
e. Create folder VP1, VP2 in folder VANPHONG.
f. Delete the VP1 folder.
g. Delete the VANPHONG folder.