Useful CMD Commands for Daily Use in Windows OS
The Command Prompt (CMD) in Windows is a powerful tool that allows users to interact with the operating system at a low level. While many tasks can be performed through the graphical user interface (GUI), knowing some useful CMD commands can save time and provide more control over your system. In this blog, we will explore some of the most commonly used CMD commands for daily tasks.
Table of Contents#
- Directory Navigation
cddir
- File and Folder Management
copymovedelmkdirrmdir
- System Information and Diagnostics
systeminfoipconfigpingtasklisttaskkill
- Networking
netstatnslookup
- Process Management
startshutdown
1. Directory Navigation#
cd (Change Directory)#
The cd command is used to change the current working directory.
Syntax:
cd [directory path]
Example:
- To navigate to the
Documentsfolder in theUsersdirectory (assuming your user profile isJohn):
cd C:\Users\John\Documents
- To go up one level in the directory hierarchy:
cd..
dir (Directory)#
The dir command lists the files and directories in the current working directory.
Syntax:
dir [options]
Common Options:
/a: Displays hidden and system files./s: Recursively lists files and directories in subdirectories./w: Displays output in wide format.
Example:
dir /a /s
This will list all files (including hidden and system files) in the current directory and its subdirectories.
2. File and Folder Management#
copy#
The copy command is used to copy files or directories.
Syntax:
copy [source] [destination]
Example:
- To copy a file named
example.txtfrom theDocumentsfolder to theDownloadsfolder:
copy C:\Users\John\Documents\example.txt C:\Users\John\Downloads
- To copy an entire directory (including its contents):
xcopy C:\Users\John\MyFolder C:\Users\John\BackupFolder /e
The /e option copies subdirectories, including empty ones.
move#
The move command is used to move files or directories. It can also be used to rename files or directories.
Syntax:
move [source] [destination]
Example:
- To move a file named
oldfile.txtto a new location:
move C:\Users\John\oldfile.txt C:\Users\John\NewLocation
- To rename a file:
move C:\Users\John\oldname.txt C:\Users\John\newname.txt
del (Delete)#
The del command is used to delete files.
Syntax:
del [file(s)]
Example:
- To delete a file named
temp.txt:
del C:\Users\John\temp.txt
- To delete multiple files (using wildcards):
del C:\Users\John\*.log
This will delete all files with the .log extension in the John user's directory.
mkdir (Make Directory)#
The mkdir command is used to create a new directory.
Syntax:
mkdir [directory name]
Example:
mkdir C:\Users\John\NewFolder
rmdir (Remove Directory)#
The rmdir command is used to remove a directory. The directory must be empty.
Syntax:
rmdir [directory name]
Example:
rmdir C:\Users\John\EmptyFolder
3. System Information and Diagnostics#
systeminfo#
The systeminfo command displays detailed information about the system, including hardware configuration, operating system version, and more.
Syntax:
systeminfo
Example:
systeminfo > systeminfo.txt
This will redirect the output of systeminfo to a text file named systeminfo.txt.
ipconfig#
The ipconfig command displays the IP configuration of the computer.
Syntax:
ipconfig [options]
Common Options:
/all: Displays full IP configuration information./release: Releases the IP address./renew: Renews the IP address.
Example:
ipconfig /all
ping#
The ping command is used to test the connectivity to a remote host.
Syntax:
ping [host name or IP address]
Example:
ping google.com
This will send ICMP echo requests to google.com and display the response times.
tasklist#
The tasklist command displays a list of running processes.
Syntax:
tasklist [options]
Common Options:
/svc: Displays the services associated with each process./v: Displays verbose information.
Example:
tasklist /svc
taskkill#
The taskkill command is used to terminate a running process.
Syntax:
taskkill /f /im [process name]
The /f option forces the termination.
Example:
taskkill /f /im notepad.exe
This will forcefully terminate the notepad.exe process.
4. Networking#
netstat#
The netstat command displays network connections, routing tables, and network interface statistics.
Syntax:
netstat [options]
Common Options:
-a: Displays all connections and listening ports.-n: Displays numerical addresses instead of resolving hostnames.-o: Displays the owning process ID.
Example:
netstat -ano
nslookup#
The nslookup command is used to query DNS servers.
Syntax:
nslookup [host name or IP address] [DNS server]
Example:
nslookup google.com
This will query the default DNS server to resolve the IP address of google.com.
5. Process Management#
start#
The start command is used to start a new process or open a file.
Syntax:
start [program name or file path]
Example:
start notepad.exe
This will start the Notepad application.
shutdown#
The shutdown command is used to shut down, restart, or log off the computer.
Syntax:
shutdown [options]
Common Options:
/s: Shuts down the computer./r: Restarts the computer./l: Logs off the current user./t [seconds]: Specifies the time delay before shutdown.
Example:
shutdown /s /t 60
This will shut down the computer after a 60 - second delay.
Best Practices#
- Be careful with deletion commands: Commands like
delandrmdircan permanently delete files and directories. Always double - check the file or directory names before executing these commands. - Use wildcards with caution: When using wildcards (e.g.,
*), make sure you know which files or directories will be affected. - Redirect output for logging: Commands like
systeminfocan generate a large amount of output. Redirecting the output to a file (e.g.,systeminfo > systeminfo.txt) can make it easier to review later.