20 most common Windows command lines

Source: Internet
Author: User
Tags net command

1. Interrupt command execution
Ctrl + Z

2. Files/Directories
CD Switch Directory
Example: CD//Show current directory
Example: CD. Go to Parent Directory

3. Create a Directory
MD D:\mp3//Establish MP3 folder in C #
MD d:\mp4//create MP4 folder in D:\
CD/D d:\mp4//Change the current directory to D:\mp4

4. Displaying content in a directory
Example: Dir//Show subfolders and files in the current directory
Example: dir/s//recursive display of content in the current directory

5. Deleting a directory
Example: Rd movie//delete movie empty folder in current directory
Example: rd/s/q d:\test//Use Quiet mode to remove d:\test (in addition to the directory itself, all subdirectories and files under the specified directory will also be deleted)

6. Copy file
Example: Copy key.txt c:\doc//Copy the Key.txt under the current directory to C:\doc (if there is also a key.txt file in doc, ask whether to overwrite)
Example: Copy jobs C:\doc// Copy the files in the Jobs folder under the current directory (no recursive subdirectories) to C:\doc (if the corresponding file exists in doc, ask whether to overwrite)
Example: Copy key.txt c:\doc\key_bak.txt// Copy the Key.txt under the current directory to C:\doc and rename it to Key_bak.txt (if there is also a key_bak.txt file in doc, ask whether to overwrite)
Example: copy/y key.txt c:\doc// Copies the key.txt under the current directory to C:\doc (without asking, overwriting writes directly)

6. Delete Files Note: Directories and subdirectories are not deleted
Example: Del Test//delete all non-read-only files in the test folder under the current directory (files in subdirectories are not deleted; confirmation before deletion; equivalent to Del test\*)
Example: del/f Test//Delete all files in the test folder under the current directory (including read-only files; files in subdirectories are not deleted; del/f test\*)
Example: del/f/s/q Test d:\test2\*.doc//delete current directory All the files in the test folder and all the doc files in the D:\test2 (including read-only files; files in a recursive subdirectory; not confirmed before deletion)
Replace replace file "Even if the file is in use, you can still replace the success"
Example: Replace D:\ Love.mp3 D:\mp3//Use the Love.mp3 in the D drive to force the replacement of the Love.mp3 file in the D drive mp3 directory
Mklink create Symbolic links (win7 introduced); A shortcut-like arrow appears on the Created symbolic link file
The Mklink command under Win7 can create different forms of file or directory links by specifying parameters, broken down into hard links, symbolic links (symbolic link), and directory joins (Junction) of three. The
(1) Symbolic link (symbolic Link)
establishes a soft link equivalent to creating a file (or directory), which is used to point to other files (or directories), and the shortcut to win is somewhat similar.
Deleting this link has no effect on the original file (or directory), and when you delete the original file (or directory), opening the link will prompt "location not available."
(2) directory join (Junction)
functions essentially like symbolic links. The difference is that the directory join automatically references the absolute path of the original directory when it is established, and the symbolic link allows a reference to the relative path.
(3) Hard link
Mklink [[/d] | [H] | [/j]] Link Target
/d Creates a directory symbolic link. Mo considers file symbolic links.
/h creates a hard link instead of a symbolic link. The
/j creates a directory join. The
link specifies the new symbolic link name. The
Target Specifies the path (relative or absolute) referenced by the new link.

7. View or modify the properties of a file or directory "A: Archive R: Read-only S: System H: Hidden"
Example: attrib 1.txt//View the properties of 1.txt in the current directory
Example: Attrib-r 1.txt//Remove read-only property of 1.txt
Example: attrib +h movie//Hidden Movie folder

8. Set the ' file type ' associated with ' file extension '
Example: Assoc//Show all ' file name extension ' associations
Example: Assoc. txt//Displays the ' file type ' represented by. txt, and the results are displayed. Txt=txtfile
Example: Assoc. doc//Displays the ' file type ' represented by the. doc, and the results are displayed. Doc=word.document.8
Example: Assoc. exe//Displays the ' file type ' represented by the. exe, and the results are displayed. Exe=exefile
Example: Assoc. txt=txtfile//Restore correct association of. txt

9. Set the ' Execute program and parameters ' associated with ' file type '
Example: Ftype//Show all ' file type ' associations
Example: Ftype exefile//Displays the command line associated with the Exefile type, resulting in exefile= "%1"%*
Example: Ftype txtfile=c:\windows\notepad.exe%1//SET command behavior associated with txtfile type: C:\Windows\notepad.exe%1

10. display text File contents
Example: Type c:\11.txt//display text content of 11.txt in C drive
Example: Type Conf.ini//Display the text content of Conf.ini in the current directory
Example: Type C:\11.txt | More//pagination shows the text content of 11.txt in C disk
More screen-per-display text file content
Example: more Conf.ini//display the text content of Conf.ini in the current directory "space: Next screen Q: Exit"

11. Registry Commands
Reg registry Related actions
Parameter description:
KeyName [\machine]fullkey
Machine Name of the remote machine-ignores default to the current machine.
only HKLM and HKU on remote machines.
FullKey Rootkey+subkey
Rootkey [HKLM | HKCU | HKCR | HKU | HKCC]
Subkey The full name of the registry key under the selected ROOTKEY
/v The value name to be added under the option
/ve add a blank value name < No name to the registry key;
/t RegKey data type
[REG_SZ | REG_MULTI_SZ | Reg_dword_big_endian |
REG_DWORD | REG_BINARY | Reg_dword_little_endian |
Reg_none | REG_EXPAND_SZ]
If omitted, use REG_SZ
/s To specify a character that is
used as a delimiter in the REG_MULTI_SZ data string, and if omitted, use as delimiter
/d Data to be assigned to the added registry ValueName
/F is not prompted to forcibly overwrite the existing registry key

12. @#@
& Sequential execution of multiple commands, regardless of whether the command executed successfully
Example: cd/d d:\src&work.exe/o c:\result.txt//Switch the current working directory to D:\SRC first, then execute the work.exe/o c:\result.txt command
&& sequential execution of multiple commands that do not execute subsequent commands when a command is executed that fails
Example: Find "OK" c:\test.txt && echo Success//If the word "OK" is found, it shows "success", not found will not show
|| Executes multiple commands sequentially and does not execute subsequent commands when the correct command is run
Example: Find "OK" C:\test.txt | | Echo Unsuccessful//If the word "OK" is not found, it will show "unsuccessful" and will not show when found
| Pipeline command
Example: Dir * */s/a | find/c ". exe"//Executes the dir command first and then executes the Find command on the output (stdout) (outputs the number of. exe files in the current folder and all subfolders)
Example: Dir * */s/a 2>&1 | find/c ". exe"//Executes the dir command first, then executes the Find command on the output (stdout) and error messages (STDERR) (the number of. exe files in the current folder and all subfolders)

CLS Clear Screen

14.start running a program or command
Example: Start/max notepad.exe//Maximizing the way to start Notepad
Example: Start/min calc.exe//Minimizing the way to start the calculator
Example: Start tasklist//Start a CMD instance window and run tasklist

14.exit exiting the current CMD window instance

Shutdown shutdown, restart, logoff, hibernate computer

regsvr32 registering or anti-registering COM components
Example: regsvr32/s clock.ocx//Register Clock.ocx components in a silent way
Example: regsvr32/u myCommon.dll//unload MyCommon.dll components

. Format formatted Disk
Example: Format J:/fs:ntfs//formatted with NTFS type J disk "type: FAT, FAT32, ExFAT, NTFS, or UDF"
Example: Format J:/fs:fat32/q//Fast formatting J-disk with FAT32 type

The. NET command
net start//view services that have been started
net start "task Scheduler"//Start Task Scheduler service
net stop task Scheduler//Shut down scheduled services

18. Process Operations
Tasklist//Display the currently running process information (see PID)
Taskkill end the specified process

19. Network operation
Ping//To detect network patency and network latency (working on ICMP protocol)
Example: Ping baidu.com//test connection with Baidu Server
Windows Telnet Server (default port: 23) The environment configuration process is as follows:
A. Installing the Telnet server
B. Start the Telnet service
C. Turn off Windows Firewall Note: If you do not want to turn off the firewall, you need to configure the Telnet server access rules in the Windows Firewall-Advanced settings
FTP 46.19.34.198 21//Connect 46.19.34.198 FTP server (21 is port number), then ask for username and password; After successful connection, how to use can type? To view Help description
ARP Display and modify Address Resolution Protocol (ARP) using the "IP-to-Mac" address translation table
Example: ARP-A//display ARP cache table
At Scheduled tasks (you must ensure that the "task Scheduler" service starts net start "task Scheduler")

20. Text Processing
Edit Config.ini//editing Config.ini file (will enter edit character editor; press ALT to select the corresponding menu) Win7 x64 without the command
Search string in the Find file
Example: find/n/i "pid" 1.txt//Ignoring case-finding PID string in 1.txt file with line number showing results after lookup
Search string in findstr file
Example: findstr "Hello World" 1.txt//search for Hello or world in 1.txt files

20 most common Windows command lines

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.