Common window commands

Time:2021-5-8

Open DOS window

  • Open the run dialog box (Win + R)
  • Enter CMD to open the console command window
  • You can also run the command directly through the CMD / C command and the CMD / K command

Note / C means to close the CMD window after executing the command/ K means to keep the CMD window after executing the command

Some skills in console command window

  • Copy content: right click to pop up the shortcut menu, select “mark (k)”, then select the content to be copied, and then right click
  • Paste content: right click to pop up the shortcut menu and select “paste (P)”
  • Hold down shift in the blank space of the folder, and then right-click to pop up the shortcut menu. You can see “open command line window here”
  • Use the up and down arrow keys to view the used commands
  • Tab complement function
  • Command parameter path: use backslash ”, do not use forward slash ‘/’, such as: del D: test2filemy.txt
  • Command parameter path: if there are spaces, double quotation marks should be used to cause the path, such as: del “D: program file file my. TXT”
  • File and directory names cannot contain any of the following characters: /: *? “< >|

get help

command /?  //  View the command help
cd /?
  • Interrupt command execution Ctrl + Z

CD switch directory

CD // displays the current directory

CD.. // enter the parent directory

CD / D D \ \ Src // enter the D \ \ SRC directory

CD D: Src / main / Java // enter the Src / main / Java folder in the current directory

CD D: // displays the directory of last disk D

MD create folder

MD D:: workspace // create a workspace folder on disk D

Delete empty folder

Rd Java // delete the empty movie folder in the current directory
Rd / S / Q D: \ \ workspace // // delete D: \ \ test in quiet mode (in addition to the directory itself, all subdirectories and files under the specified directory will be deleted)

Copy file

Copy key.txt C: // Doc // copy the key.txt in the current directory to C: // doc
Copy / Y key.txt C: // Doc // copy the key.txt in the current directory to C: // doc (write directly without asking)
Copy / Y key1.txt + key2.txt key.txt // merge the contents of key1.txt and key2.txt in the current directory and write them to key.txt (do not ask, directly write them)

Move files

Move *. PNG test // move the PNG pictures in the current directory to the test folder in the current directory (if there are PNG pictures with the same name in the test, you will be asked whether to cover them)

Del delete file

Del test // delete all non read only files in the test folder in the current directory (files in subdirectories are not deleted; Confirm before deleting; Equivalent to del test \ *)
Del / F test // delete all files (including read-only files) in the test folder in the current directory; Files in subdirectories are not deleted; Confirm before deleting; Equivalent to del / F test \ *)

Del / F / S / Q test D: // test2 \ *. Doc // delete all files in the test folder in the current directory and all doc files (including read-only files) in D: // test2; Recursive subdirectory files; Do not confirm before deleting)


++++++++++++++++++++++

/AR, / ah, / as, and / AA indicate to delete read-only, hidden, system, and archive files respectively
/A-R, / A-H, / A-S, and / A-A are used to delete files except read-only, hidden, system, and archive files

++++++++++++++++++++++

Example: del / AR *. * // delete all read-only files in the current directory

Example: del / A-S *. * // delete all files except system files in the current directory

Type displays the contents of the text file

Type conf.ini // displays the text content of conf.ini in the current directory
Type C: (11. TXT | more // the text content of 11. TXT in Disk C is displayed in pages

Process operation

Tasklist // displays the current running process information (you can view PID)

Taskkill ends the specified process

Example: taskkill / im notepad.exe // ends a process named notepad.exe

Network operation

Ping // used to detect whether the network is unobstructed and the network delay (works on ICMP Protocol)
Ping baidu.com // test the connection with Baidu server
Ping - L 65500 - N 10 qq.com // send a 65500 byte Ping to qq.com 10 times
Ping - t baidu.com // continuously test the connection of Baidu server [Ctrl + pause break: View Ping statistics; CTRL + C: terminate the current task]

Ipconfig / all // view the local IP address and other details
Ipconfig / displaydns // displays the contents of the local DNS cache
Ipconfig / flushdns // clear the local DNS cache
nslookup  www.cnblogs.com   //Get www.cnblogs.com Domain name resolution of
Netstat - A // view which ports are open
Netstat - N // view the network connection of the port
Netstat - V // view work in progress
Netstat - P TCP // view the usage of TCP protocol
Tracert 182.140.167.44 // view the local route to 182.140.167.44
Route print // displays the IP route
Telnet 182.140.167.44 8000 // detect whether 182.140.167.44 uses TCP protocol to monitor port 8000 (Note: telnet command does not support UDP port detection)
ARP // displays and modifies the IP to MAC address translation table used by ARP
ARP - A // display ARP cache table

text processing

Search string in find // file
Find / N / I "PID" 1.txt // ignore the case in the 1.txt file to find the PID string, and display the result with the line number
Find / C "exe" 1.txt // only the number of times to find an EXE string in the 1.txt file is displayed
Find / V "exe" 1.txt // displays lines that do not contain the 1.txt file and do not contain the EXE string

Search string in findstr file
Findstr "Hello world" 1.txt // search for Hello or world in the 1.txt file
Findstr / C: "Hello world" 1.txt nul // search for Hello world in the 1.txt file and print out 1.txt before each line of results. Note: findstr will print out the file name of each file only when searching for strings in two or more files. Nul means an empty file
Findstr / S / I "hello" * * // case insensitive, in all files in the current directory and all subdirectories

DOS command to view the process of port occupancy and closing

1. View port occupancy
Execute in Windows command line window

netstat -aon|findstr "8080" 

The results are as follows:

TCP     127.0.0.1:8080         0.0.0.0:0               LISTENING       2448

2. Close the process

  • Close process by process number
taskkill /pid 2448 /pid 2449
  • Close process by process name
taskkill /im notepad.exe /im iexplorer.exe

If you want to close all chrome processes, use the wildcard *, that is:

taskkill /im chrome*.exe
  • Forcibly terminate the process
taskkill /f /im notepad.exe
taskkill /f /pid 2152
  • port status
  1. Listening status

After the service is started, it is first in listening state.

2 established status
Established means to establish a connection. Indicates that two machines are communicating.

3 CLOSE_WAIT
If the other party closes the connection actively or the connection is interrupted due to network abnormality, our status will change to close_ Wait at this time, we call close() to make the connection close correctly

4 TIME_WAIT
We actively call close() to disconnect, and the status changes to time after receiving the confirmation from the other party_ WAIT。 TCP protocol specifies time_ The wait state will continue for 2msl (that is, twice the maximum lifetime of the segment) to ensure that the old connection state will not affect the new connection. In time_ The resources occupied by the wait state connection will not be released by the kernel, so as a server, try not to disconnect actively when possible to reduce time_ Waste of resources caused by wait state.

There is a way to avoid time_ The way to waste wait resources is to turn off the ringer option of socket. But this method is not recommended by TCP protocol. In some cases, this operation may bring errors.

5 SYN_ Sent status
SYN_ The sent status indicates connection request. When you want to access the services of other computers, you should first send a synchronization signal to the port. At this time, the status is syn_ Sent. If the connection is successful, it becomes established. At this time, syn_ The sent state is very short. But if SYN is found_ There are a lot of sent to different machines, so your machine may be infected with viruses such as shockwave or shockwave. In order to infect other computers, this kind of virus has to scan other computers. In the process of scanning, it has to send out synchronization request to each computer to be scanned, which is also the occurrence of many syn_ The reason for sent

reference material

Windows common command line (DOS) command
DOS command to view the process of port occupancy and closing

Recommended Today

Looking for frustration 1.0

I believe you have a basic understanding of trust in yesterday’s article. Today we will give a complete introduction to trust. Why choose rust It’s a language that gives everyone the ability to build reliable and efficient software. You can’t write unsafe code here (unsafe block is not in the scope of discussion). Most of […]