The Windows command line is one of the most powerful utilities on a Windows PC. With it, you can interact with the OS directly and do a lot of things not available in the graphical user interface (GUI).
In this article, I’ll show you 40 commands you can use on the Windows command line that can boost your confidence as a Windows user.
N.B.: You have to be careful while using the commands I’ll show you. This is because some commands can have a lasting negative or positive effect on your Windows PC until you reset it.
In addition, some of these commands require you to open the command prompt as an admin.
powershell start cmd -v runAs
– Run the Command Prompt as an Administrator
Entering this command opens another command prompt window as an administrator:
driverquery
– Lists All Installed Drivers
It is important to have access to all drivers because they often cause problems.
That’s what this command does – it shows you even the drivers you won’t find in the device manager.
chdir
or cd
– Changes the Current Working Directory to the Specified Directory
systeminfo
– Shows Your PC’s Details
If you want to see more detailed information about your system you won’t see in the GUI, this is the command for you.
set
– Shows your PC’s Environment Variables
prompt
– Changes the Default Text Shown before Entering Commands
By default, the command prompt shows the C drive path to your user account.
You can use the prompt
command to change that default text with the syntax prompt prompt_name $G
:
N.B: If you don’t append $G
to the command, you won’t get the greater than symbol in front of the text.
clip
– Copies an Item to the Clipboard
For example, dir | clip
copies all the content of the present working directory to the clipboard.
You can type clip /?
and hit ENTER
to see how to use it.
assoc
– Lists Programs and the Extensions They are Associated With
title
– Changes the Command Prompt Window Title Using the Format title window-title-name
fc
– Compares Two Similar Files
If you are a programmer or writer and you want to quickly see what differs between two files, you can enter this command and then the full path to the two files. For example fc “file-1-path” “file-2-path”
.
cipher
– Wipes Free Space and Encrypts Data
On a PC, deleted files remain accessible to you and other users. So, technically, they are not deleted under the hood.
You can use the cipher command to wipe the drive clean and encrypt such files.
netstat -an
– Shows Open Ports, their IP Addresses and States
ping
– Shows a Website IP Address, Lets you Know How Long it Takes to Transmit Data and a Get Response
color
– Changes the Text Color of the Command Prompt
Enter color attr
to see the colors you can change to:
Entering color 2
changes the color of the terminal to green:
for /f "skip=9 tokens=1,2 delims=:" %i in ('netsh wlan show profiles') do @echo %j | findstr -i -v echo | netsh wlan show profiles %j key=clear
– Shows All Wi-Fi Passwords
ipconfig
– Shows Information about PC IP Addresses and Connections
This command also has extensions such as ipconfig /release
, ipconfig /renew
, and ipconfig /flushdns
which you can use to troubleshoot issues with internet connections.
sfc
– System File Checker
This command scans your computer for corrupt files and repairs them. The extension of the command you can use to run a scan is /scannow
.
powercfg
– Controls Configurable Power Settings
You can use this command with its several extensions to show information about the power state of your PC.
You can enter powercfg help
to show those extensions.
For example, you can use powercfg /energy
to generate a battery health report.
The powercfg /energy
command will generate an HTML file containing the report. You can find the HTML file in C:Windowssystem32energy-report.html
.
dir
– Lists Items in a Directory
del
– Deletes a File
attrib +h +s +r folder_name
– Hides a Folder
You can hide a folder right from the command line by typing in attrib +h +s +r folder_name
and then pressing ENTER
.
To show the folder again, execute the command – attrib -h -s -r folder_name
.
start website-address
– Logs on to a Website from the Command Line
tree
– Shows the Tree of the Current Directory or Specified Drive
ver
– Shows the Version of the OS
tasklist
– Shows Open Programs
You can do the same thing you do with the task manager with this command:
The next command shows you how to close an open task.
taskkill
– Terminates a Running Task
To kill a task, run taskkill /IM "task.exe" /F
. For example, taskkill /IM "chrome.exe" /F
:
date
– Shows and Changes the Current Date
time
– Shows and Changes the Current Time
vol
– Shows the Serial Number and Label Info of the Current Drive
dism
– Runs the Deployment Image Service Management Tool
CTRL + C
– Stops the Execution of a Command
-help
– Provides a Guide to other Commands
For example, powercfg -help
shows how to use the powercfg
command
echo
– Shows Custom Messages or Messages from a Script or File
You can also use the echo
command to create a file with this syntax echo file-content > filename.extension
.
mkdir
– Creates a Folder
rmdir
– Deletes a Folder
N.B.: The folder must be empty for this command to work.
more
– Shows More Information or the Content of a File
move
– Moves a File or Folder to a Specified Folder
ren
– Renames a File with the Syntax ren filename.extension new-name.extension
cls
– Clears the Command Line
In case you enter several commands and the command line gets clogged up, you can use cls
to clear all entries and their outputs.
exit
– Closes the Command Line
shutdown
– Shuts down, Restarts, Hibernates, Sleeps the Computer
You can shut down, restart, hibernate, and sleep your PC from the command line.
Enter shutdown
in the command line so you can see the extensions you can use to perform the actions. For example, shutdown /r will restart your computer.
Conclusion
This article showed you several “unknown-to-many” commands you can use to get access to hidden functionalities on your Windows PC.
Again, you should be careful while working with these commands because they can have a lasting effect on your OS.
If you find the commands helpful, share the article with your friends and family.
In case you know another useful command I did not list, tell me about it on Twitter. I will add it and mention you as the source.
Learn to code for free. freeCodeCamp’s open source curriculum has helped more than 40,000 people get jobs as developers. Get started
Sometimes you can forget cmd commands in Windows and saving them on your computer or a peace of paper as a cheat sheet is a good practice. This list is not complete but it contains most commonly used commands. Feel free to add your most commonly used commands in the comments below and share the list.
Files and Folders Management
- COPY — Copies files to another location
- DIR – Displays files and folders in current directory
- DEL or ERASE — Deletes files
- EDIT — Starts file editor
- CD — Changes directory
- EXPAND — Decompresses compressed files
- FC — Compares files and shows the differences between them
- FIND — Finds a text string in the file
- MD or MAKEDIR — Creates a folder
- MOVE — Moves files from one folder to another
- PRINT — Prints out the text file contents
- RD or RMDIR — Deletes a folder
- REN or RENAME — Renames a file or folder
- REPLACE — Replaces files in one directory with files of the same name in another directory (overwrite)
- ROBOCOPY — Uses an advanced tool to copy files and directories
- TREE — Shows directory structure of a disk or folder
- TYPE — Displays the contents of text files
- OPENFILES – Manages opened local or network files
- XCOPY — Copies files and directory trees
Applications and Processes
- SCHTASKS — Executes a command or start a scheduled application (Task Scheduler)
- SHUTDOWN — Shutdowns or reboots your computer
- TASKLIST — Lists the tasks being performed
- TASKKILL — Stops or halts a task (to stop a task you use a PID which you can find out from TASKLIST)
- REG – Starts registry editor
- RUNAS — Launches the task as another user
Disks Management
- CHKDISK — Checks disk and shows statistics
- DEFRAG – Starts disk defragmentation
- CHKNTFS — Displays or changes execution of disk check at boot
- COMPACT — Displays and change the compression of files in NTFS partitions
- CONVERT — Converts FAT disk volume to NTFS
- DISKPART — Displays and adjusts disk partition properties
- FORMAT — Formats the disk
- FSUTIL — Displays and configures file system properties
- LABEL — Creates, changes, or deletes a disk volume label
- RECOVER — Recovers data from a bad or damaged disk
- VOL — Displays volume label and serial number for the disk
System Information
- DATE — Outputs or sets the current date
- TIME — Displays or sets the system time
- DRIVERQUERY — Displays the current state and properties of the device driver
- HOSTNAME — Displays name of the computer
- SYSTEMINFO — Shows configuration information about your computer
- VER — Allows you to view the Windows version
- GPRESULT – Displays current applied group policies (RSoP)
- GPUPDATE – Updates group policies
Network
- IPCONFIG — Shows information about network interfaces
- PING – Sends ICMP requests to the target host, checks host availability
- TRACERT — Finds the path for packets traveling over the network
- NSLOOKUP — Finds IP address by resource name
- ROUTE — Displays network route tables
- ARP— Shows a table with IP addresses converted into physical addresses
- NETSH – Starts is a network settings control program
- GETMAC — Shows the MAC address of the network adapter
- TFTP – Starts TFTP client in console
Command Line Setup
- CLS — Clears screen
- CMD — Displays another command prompt
- COLOR — Sets the text and background color
- PROMPT — Changes the command line prompt
- TITLE — Assigns a title for the current session
- HELP – Launches CMD help
- EXIT — Exits the command line
Аverage rating : 4.1
Rated by: 13
1101
CT Amsterdam
The Netherlands, Herikerbergweg 292
+31 20 262-33-82
700
300
ITGLOBAL.COM NL
1101
CT Amsterdam
The Netherlands, Herikerbergweg 292
+31 20 262-33-82
700
300
ITGLOBAL.COM NL
700
300
Contents
- 1 Windows Command Line
- 2 Navigating Windows Command Line
- 3 Windows Command Line Commands
- 4 Piping Commands
- 5 Output to a text file
- 6 Chaining Commands
- 7 Processes and Performance
- 8 Controlling Windows Services in Command Line
- 9 Windows Hard Disk Utils
- 10 User Control
- 11 Managing TCP/IP and Networking with WCL
- 12 More Resources:
Windows Command Line
A simple guide for any skill level.
Windows Command Line, known as a Command Line Interface, can be a very powerful tool for system administrators, power users, and technical support personnel. While most users will never see Windows Command Line, this guide is intended for Intermediate to Advanced users.
Most of Windows Command Line functions can be accessed through Windows GUI, other functions and programs can not. Knowing and understanding Windows Command Line will allow you to complete tasks faster, access features and programs not available in the Windows GUI, and look like you know what you’re doing.
Through this guide, we will walk through each section of commands that Windows XP Command line offers you the capability of. At the end, we discuss how scripting, and batch files can automate tasks, and save you time.
Terms:
CLI — Command Line Interface (non-GUI)
WCL — Windows Command Line
GUI — Graphical User Interface
Script — Chain of commands to be automatically run in order
Navigating Windows Command Line
To open Windows Command Line, click Start > Run and enter the word «cmd». This is a shortcut to opening a historic file called command.com, which is now called cmd.exe (the main program running WCL). The files for WCL can be found in «%systemroot%system32». Whenever you see a value starting and ending with %, you will know this is a variable. The %systemroot% variable will have a value of whatever your main windows folder is. For Windows XP, your system root is C:Windows, unless specified otherwise. For Windows 2000, your system root is C:Winnt.
Terms:
Variable — A value that can change based on user input
Syntax — The way a command is typed (word order)
Navigating the Command Line Interface: Commands and Examples
Each command in Windows Command Line has a different function. Each command also has a help document associated with it (for the most part). To access help for any command, try these two methods:
Windows Command Line Help
(command) /? — This /? at the end of the command will bring up a help document describing different «modifiers» you can add to command using the / symbol.
If you dont get a help document from the first command, check your syntax, and try the other help command.
HELP — Help document for WCL
Usage: help OR help <command>
Example: help
Example: help copy
Explanation: Help lists commands, help <command> shows command help document
Windows Command Line Commands
Listed below are some commonly used Windows Command Line Commands. They show the command name, its description, usage, and an explanation of what the example command would do.
CD — Change current working directory
Usage: cd <directory you want to open> OR cd
Example: cd
Explanation: Changes your working directory to root (c:)
Example: cd windows
Explanation: Takes you to the windows directory inside your current directory
COPY — copies files or folders to other locations that already exist
Usage: copy <file or folder from> <copy file or folder to>
Example: copy employees.txt c:workemployees
CLS — Clears the screen of all commands
Usage: cls
Example: cls
DEL — Deletes a file from current directory
Usage: del <folder or file name>
Example: del programs
Explanation: Deletes the folder or file named programs
DIR — Used to list all files in current directory
Usage: dir (modifiers can be listed with /?)
Example: dir
Explanation: This will list all files and folders at current location
EXIT — Exits CMD
Usage: exit
FIND — Finds a command given certain search parameters
Usage: Find <search term>
Example: Find «*.txt»
Explanation: Finds all text files in directory
Notes: * can be used as a ‘wildcard’ to mean any length or any combination of letters.
MD — Make directory at current location
Usage: md <directory name you want to make>
Example: md programs
Explanation: This will make a new folder at the current location
MOVE — Moves a file from one location to another (cut)
Usage: Move <full path of file you want to move> <already existing directory to move TO>
Example: Move c:gamesmygame.zip c:newgames
Explanation: This will move the file mygame.zip from one directory, to another existing directory
PAUSE — Pauses scripts or batch files and waits for user input
example: pause
Explanation: When in a script, this displays «Press any key to continue» and waits for user input
RD — Remove Directory
Usage — rd <folder name>
Example: rd windows
Explanation: This removes the directory Windows (bad idea)
Notes: to remove a directory and its contents, «rd /s windows»
REN — Rename a folder or file
Usage: ren <file or folder> <new name you want>
Example: ren windows window
Explanation: this changes your windows directory name to window
TIME — Check or modify system time
Usage: time
VER — Check your version of Windows
Usage: ver
Windows Command Line also interfaces with files on your computer to record data to. Piping and chaining commands is another option in most CLI situations. Chaining commands is simply feeding the output of one command (dir for example outputs a list of files and folders) to another command that you want to run only for the output of the first file.
Piping Commands
The chaining of commands can be used by typing | (shift + ). This is called the pipe, or piping commands. To pipe one command to another, type one full command, and WCL automatically outputs the data that you normally see to the next command.
For example, «dir c:windows | Find «*.txt»
The above example would list all files in c:windows then put all of the files and folders in c:windows get sent to the find command. The find command then looks for any files that end in .txt. You will now see a list of all txt files in c:windows
Output to a text file
Another useful function for script makers is the ability to output text from the command line (input and output) to a text document. Using the output to text file, or append options both come in handy at different times.
> — Create a new text file and have WCL output info to it
Usage: <command to output> > <location of text file to output to>
Example: dir > c:myfiles.txt
Explanation: This command would list all files and folders in current directory, and outputs to file c:myfiles.txt
>> — Append information from a command to a text document.
Usage: <command> >> <file to add to>
Example: dir > c:myfiles.txt
Explanation: This would list files and folders in current directory and ADD the list to myfiles.txt while keeping the previous data in tact.
Chaining Commands
When there are multiple commands you want to run at one time, Chaining commands in Windows Command Line comes in handy. To chain a command, we have two tools.
& — Complete one command then another directly after
Usage: command & command2
Example: dir & ver
Explanation: This will list all files in current directory and then the version of Windows Command Line
&& — Complete one command, then another if the first was successful
Usage: <command1> && <command2>
Example: copy c:importantdata.txt c:backup && ren backupdata.txt
Explanation: This will copy the file importantdata.txt to c:backup, THEN if successful, it will rename the file to backupdata.txt
Processes and Performance
Windows has its GUI version of system performance monitor that shows up every time you press CTRL-ALT-DELETE at the same time. There is also a command line version that can be configured to show much more information for power users.
Another thing to take into account is that when you open a CMD window, it will use a LOT less system resources than a GUI. This can be VERY helpful in ending processes that are lagging your computer a lot.
To access the process and performance monitoring tools, use the following commands:
Tasklist in Windows Command Line (DOS)
TASKLIST — Lists all running processes with detailed information
Usage: Tasklist
Note: the /svc addition to tasklist allows you to see what processes are using what services at the moment
Note2: /M addition shows each process, and associated DLL files
TASKKILL — Stops tasks with given parameters
Usage: Taskkill <which task>
Example: Taskkill /pid 140
Explanation: This will end the task with PID of 140 (the process identification number). You can find the PID for each task using tasklist
Controlling Windows Services in Command Line
Services are extra functions that Windows has the ability to start and stop depending on whether you allow the services to be started. A lot of windows services contribute to slow computing, security risks, and instability in the operating system. While some services are essential, others are never needed. Windows XP Services
To list, modify, start and stop services you will need a new commands to help you.
SC query — Shows list of configured services
Usage: SC query
Explanation: This will list info and data on services
SC qc — Queries a specific service
Usage: SC qc <service name>
Example: sc qc messenger
Explanation: This will show configuration data for the messenger service
SC start — Starts a specific service
Usage: SC start <service name>
Example: SC start messenger
Explanation: This starts the messenger service
SC stop — Stops a specific service
Usage: SC stop <service name>
Example: SC stop messenger
Explanation: This stops the messenger service
SC config — Configures service properties
Usage: SC config <service name> start= <start type>
Example: SC config messenger start = disabled
Explanation: This will tell the messenger service NOT to start with the computer.
Notes: Settings available for start= are Disabled, Auto, and Demand
Disabled never starts, Auto starts every startup, and demand starts as the service is needed
Windows Hard Disk Utils
Windows comes with extensive command line utilities to control, check and maintain your hard disk drives. Included in the utilities are Drive Partitioners, Defragmenters, Check Disk Utilities, and utilities to set a drive to be checked for errors on next startup.
Try some of these Windows Command Line Commands, as they can save your computer in case of disasters like virus’s or improper shutdowns.
CHKDSK — Checks a hard disk for errors
Usage: chkdsk <parameters> <drive to check>
Example: chkdsk /f C:
Explanation: This command will scan drive C for errors, and repair them if needed.
Notes: /f parameter auto-repairs errors when found
DEFRAG — Defragments a hard drive to optimize performance
Usage: Defrag <parameter> <drive letter>
Example: Defrag c:
Explanation: Desfragments the C: drive
Notes: defrag -a <drive letter> will analyze only, and not defragment
User Control
Embedded in Windows XP is the ability to add and remove users. This concept is called a «Multi-User Operating System». This type of system allows for more than one user account to be made, each account with specific permissions to access data or run programs. User Accounts can be changed from control panel, or Windows Command Line.
NET USER — View a list of local user accounts
Usage: Net User <name of user, or blank for all>
Example: Net User Chris
Explanation: Displays user account info for user Chris
Notes: Access to net user can be used across a single domain also
Parameters: net user <name> /delete
Explanation: This deletes a user account
NET USER — Adds users to local computer
Usage: net user <username to add> <password to add> /add
Example: net user chris library /add
Explanation: This will add a user to the local computer with the name as chris, and the password as library
Notes: Parameters that go BEFORE /add are
/fullname:»Chris Reed» (Full name of user)
/comment:»Chris is main systems admin» (users comments)
/passwordreq yes (requires password at logon)
Example 2: net user Chris library /fullname:»Chris Reed» /comment: «Chris is main systems admin» /passwordreq yes /add
Explanation: This adds user Chris with password library, and full user name of chris reed, with a user comment as «Chris is main systems admin» and requires a password at logon
Managing TCP/IP and Networking with WCL
TCP/IP is a transmission protocol for two computers communicating through a network. TCP/IP has error checking for the packets that are transferred, and is used in many internet and networking situations.
Windows Command Line allows you to view detailed information about your internet connection, DNS servers, DHCP servers, your internal IP address, and defualt gateway. The commands below will show you how to check your TCP/IP status, modify servers, and set static IP addresses.
Terms:
[code]DHCP — Automatically determined IP set for your computer
Static IP — A custom setup network configuration with unchanging IP
TCP/IP — Communication protocol for 2 computers over a network
Default Gateway — Your router or gateways IP address
Subnet Mask — Defines the section of a network you are on
DNS servers — Computer that resolves URL to IP (www.yoursite.com to IP)
IP address — Your individual computers network ID
Note: To check your TCP/IP connections, network adapter, and settings, you can type ping «127.0.0.1». This will send a ping out through your network adapter, and redirect it right back to your computer. Upon successful ping, you can tell that your computer is setup properly to use TCP/IP.
==
TCP/IP from Windows Command Line ==
IPCONFIG — Shows IP information for your computer
Usage: IPCONFIG or IPCONFIG /all
Example: ipconfig /all
Explanation: Shows all information about current TCP/IP connection
Notes: Other parameters /flushDNS (resets DNS cache) /release (releases your network adapter) /renew (renews your network adapter)
SET ADDRESS — sets tcp/ip settings via WCL
Usage: Set address name=»<connection name>» source=<static or dhcp> addr=<static IP> mask=<subnet mask> gateway=<gateway IP>
Static IP Network Configuration
Example: Set address name=»Local Area Connection» source=static addr=192.168.1.201 mask=255.255.255.0 gateway=192.168.1.1
Explanation: This will make the computer setup a new connection called Local Area Connection, with a STATIC IP of 192.168.1.201, a subnet mask of 255.255.255.0 and a gateway of 192.168.1.1
DHCP Network Configuration
Example: set address name=»Local Area Connection» source=»dhcp»
Explanation: This will setup a new connection name Local Area Connection that will try to automatically set your IP using DHCP protocol. (Your router or gateway will be the DHCP server usually)
DELETE ADDRESS — Removes a connection from your list
Usage: Delete Address name=<address name> addr=<IP address>
DNS Server Setup
DNS servers are computers connected to the internet with records of URLs (www.yoursite.com) and the matching IP address for the URLs server (68.48.0.12). Your computer connects to a DNS server every time you enter a web page in your address bar. Although you dont usually see the IP address information, it is hiding beneath your browser or internet program.
To setup custom DNS servers using WCL, you will need the following commands. For your DNS server, you can either contact your ISP, and use one of theirs, or you can try using your router.
ADD DNS — Sets custom DNS servers to use
Usage: ADD DNS name=<DNS server name> addr=<ip of DNS server>
Example: ADD dns name=»My Pinacolataburg DNS» addr=»68.48.0.12″
Explanation: Adds a DNS server named My Pinacolataburg DNS with an IP address of 68.48.0.12
DELETE DNS — removes a specific DNS entry from a connection
Usage: delete dns name=<name to delete> addr=<IP to delete>
Example: delete dns name=»My Pinacolataburg dns» addr=68.48.0.12
Explanation: This will remove the DNS server entry above
Windows Command Line has an array of tools for diagnosing network problems. You can view individual stats for network adapters and network connections. You can also view the path to a certain internet host, get ping information for the host, and find all open TCP/IP connections with information on what program is using the connection.
Tracert — Find ping, and number of hops to reach a given server
Usage: Tracert <internet host to trace the route to>
Example: tracert www.computershack.net
Explanation: This command would give tracert information from the originating computer, to the opposite end of the connection.
PING — Find how long it takes for a message to be send to a server, and back again.
Usage: Ping < internet host IP or URL >
Example: ping www.computershack.net
Explanation: Ping shows the time, in milliseconds it takes to contact the given IP or URL, plus the time it takes to get back to your computer.
NETSTAT — Shows information about network connections
Usage: Netstat <parameters>
Example: Netstat -b
Explanation: With the parameter -b, netstat shows a list of all open connections, the port, and program that is managing the connection.
Notes: Another parameter is -a to view all open connections/ports
NETSH — Network Shell is a collection of tools to diagnose network components.
Usage: NETSH <parameter>
Example: NETSH diag ping adapter
Explanation: This will ping each item in your TCP/IP configuration. Included is DNS, DHCP, WINS, and Default Gateway
Conclusion: Using the information in this document, it is possible to control, maintain, diagnose, and fix problems in almost all categories. With this information, try using Windows Command Line more often. It will help you become a better technician, and be able to fix more problems faster.
More Resources:
- Official Microsoft Command Line Reference
The Windows command line is a powerful tool that can be used for a variety of tasks. From basic tasks like managing files and directories to more advanced tasks like scripting and automation, the command line can help you do just about anything. This article will guide you on opening the Windows command prompt and provide you with the Windows command line cheat sheet.
What is Windows command line?
The windows command line is a text-based interface that allows you to execute commands on your computer. Often referred to as the «command prompt» or simply «prompt,» the command line provides a text-based interface for issuing commands and controlling your computer. You can perform all sorts of tasks using the command line, from launching programs to accessing system settings. While the command line may seem daunting at first, it’s actually quite easy to use. With a bit of practice, you can quickly learn how to use the windows command prompt to manage your computer more efficiently.
How do I open a command line in Windows?
Opening the command line in Windows is a simple process. First, open the Start menu by clicking the Start button or pressing the Windows key. Then, type «cmd» into the search box and press Enter. This will open the Windows Command Prompt. From here, you can type any commands you wish to execute.
Alternatively, you can also press the «Windows key + R» on your keyboard. This will open the «Run» dialog box. Type «cmd» into the box and press Enter.
Now that you know how to open command prompt in Windows, you can use it to run various commands to perform tasks on your computer.
Windows Command Line Cheat Sheet
If you’re new to the Windows command line, you may be feeling a bit overwhelmed. There are so many different commands and options, and it can be difficult to know where to start. But don’t worry- we’ve got you covered. Our windows command line cheat sheet pdf provides a handy reference guide to all the most commonly used commands. Simply print it out or keep it open on your desktop, and you’ll always have the information you need right at your fingertips. Or you can view the online sheet below, and start making the most of the command line!
Command | What does it do? |
Files & Folders Comands |
|
assoc | Fix file associations. |
attrib | Change file attributes. |
cd (or chdir) | Change current working directory. |
comp | Perform a comparison of multiple files. |
compact | Copy files from one location to another. |
del (or erase) | Delete files. |
dir | List files and subfolders. |
expand | Expand compressed files. |
fc | File compare. |
find | Filter a string in files. |
findstr | Search for patterns of text in files. |
md (or mkdir) | Create a directory or subdirectory. |
move | Move files from one directory to another. |
openfiles | Display the current open files list or disconnect opened files/folders. |
Send a text file to a printer. | |
rd (or rmdir) | Delete a directory. |
ren (or rename) | Rename a file or directory. |
replace | Replace existing or add new files to a directory. |
robocopy | Copy file data from one location to another. |
tree | Display tree structure of a directory. |
type | Display the contents of a text file. |
xcopy | Copy files and directories. |
Disk & Partition Commands |
|
active | Mark the partition with focus as active. |
chkdsk | Check disk. |
chkntfs | Display or modify automatic disk checking when the computer is started. |
clean | Remove all partitions or volume formatting from the disk with focus. |
convert | Convert a disk from one disk type to another. |
create | Create partition or volume. |
defrag | Locates and consolidates fragmented files on local volumes. |
delete | Delete a partition or a volume. |
detail | Display information about the selected disk. |
diskcomp | Compare the contents of two floppy disks. |
diskcopy | Copy content of the disk. |
diskpart | Manage computer disks and drives. |
diskperf | Start or stop disk performance counters for Performance Monitor. |
extend | Extend a partition or a volume. |
format | Format a disk to accept Windows files. |
freedisk | Check to see if the specified amount of disk space is available before continuing with an installation process. |
fsutil | Perform tasks that related to FAT and NTFS file systems. |
gpt | Assign gpt attribute(s) to a partition. |
label | Create, change, or delete the volume label of a disk. |
list | Display a list of disks. |
recover | Recover readable information from a bad or defective disk. |
vol | Display the disk volume label and serial number. |
Network Commands |
|
arp | Display and modify entries in the ARP cache. |
bitsadmin | Create, download or upload jobs and monitor their progress. |
dnscmd | Manage DNS servers. |
ftp | Connect to and use FTP. |
getmac | Return the MAC address. |
ipconfig | IP configuration. |
ipxroute | Display and modify information about the routing tables used by the IPX protocol. |
irftp | Sends files over an infrared link. |
jetpack | Compact a WINS or DHCP database. |
netsh | Network Shell utility. |
netstat | Display network statistics. |
net use | Connect/disconnect a computer to/from a shared resource |
ping | View the computer name and the IP address of an endpoint computer. |
tracert | Determine the route to a destination by sending ICMP packets to the destination. |
System Information & Configuration Commands |
|
date | Display or set the system date. |
driverquery | Display device driver status and properties. |
hostname | Display the computer hostname. |
powercfg | Power configuration. |
shutdown | Turn off computer. |
systeminfo | Display computer system information. |
time | Display or set the system time. |
ver | Display Windows system version number. |
Command Line Setup Commands |
|
cls | Clear the command prompt window. |
cmd | Start a new instance of the command interpreter. |
color | Change the foreground and background colors in the Command Prompt window for the current session. |
exit | Quit and close the command prompt. |
help | Display a list of the available commands. |
prompt | Change the Cmd.exe command prompt. |
title | Set the Cmd.exe window title. |
Conclusion
Windows command line can be extremely useful for any Windows user. If you want to learn more about using the commands, the windows command line cheat sheet would be a great resource. Whether you’re a beginner or an experienced user, the sheet can help you get the most out of your windows experience.
Updated: 12/31/2020 by
This page covers the basics of navigating and using the Microsoft Windows command line. On this page, you learn how to move around in the command line, find files, manipulate files, and other important commands. Realize that there are over 100 different commands used in MS-DOS and the Windows command line. If you are interested in learning about the command line in more detail, see our DOS and command prompt overview, which gives a description and example for every command.
Get into the Windows command line
Open a Windows command line window by following the steps below. If you need additional information or alternative methods for all versions of Windows, see: How to get to an MS-DOS prompt or Windows command line.
- Click Start.
- In the Search or Run line, type cmd (short for command), and press Enter.
Understanding the prompt
After following the steps above, the Windows command line should be shown (similar to the example below). Windows often starts you at your user directory. In the example below, the user is Mrhope. So, C:UsersMrhope> is our prompt. This prompt shows that we’re in the C: drive (default hard drive letter) and currently in the Mrhope directory, a subdirectory of the Users directory.
Key tips
- MS-DOS and the Windows command line are not case-sensitive.
- The files and directories shown in Windows are also found in the command line.
- When working with a file or directory with a space, surround it in quotes. For example, the directory My Documents would be «My Documents» when typed.
- File names can have a long file name of 255 characters and a three character file extension.
- When a file or directory is deleted in the command line, it is not moved into the Recycle Bin.
- If you need help with any of command, type /? after the command. For example, dir /? would give the options available for the dir command.
Listing the files
Let’s learn your first command. Type dir at the prompt to list files in the current directory. You should get an output similar to the example image below. Without using any dir options, this is how dir output appears. As shown, you are given information including the creation date and time, directories (<DIR>), and the name of the directory or file. In the example below, there are 0 files listed and 14 directories, indicated by the status message at the bottom of the output.
Every command in the command line has options, which are additional switches and commands that can be added after the command. For example, with the dir command, you can type dir /p to list the files and directories in the current directory one page at a time. This switch is useful to see all the files and directories in a directory with dozens or hundreds of files. Each of the command options and switches is listed in our DOS command overview. We offer guides for individual commands, as well. For example, if you want to see all the options for the dir command, refer to our dir command overview for a complete option listing.
The dir command can also be used to search for specific files and directories using wildcards. For example, to list files or directories that begin with the letter «A» you could type dir a* to list only the AppData directory, in this above example. See the wildcard definition for other examples and help with using wildcards.
- How to list files in a directory or folder on the computer.
Moving into a directory
Now that we’ve seen a list of directories (shown below) in the current directory, move into one of those directories. To move into a directory, we use the cd command, so to move into the Desktop type cd desktop and press Enter. Once you’ve moved into a new directory, the prompt changes. So, in our example, the prompt is now C:UsersMrhopeDesktop>. You can see what files are found in this directory by typing the dir command again.
- How to change a directory or open a folder.
Understand the files
In the Desktop directory, as shown in the above example, there are 23 files and 7 directories, representing different file types. In Windows, you are familiar with files having icons that help represent the file type. In the command line, the same thing is accomplished by the file extensions. For example, «forum posts.txt» is a text file because it has a .txt file extension. Time.mp3 is an MP3 music file and minecraft.exe is an executable file.
- Listing of file extensions and additional help with file extensions.
Most users are only concerned with executable files, which as mentioned above, are files ending with .exe, .com, and .bat. When the file name is typed in the command line, the program runs, which is the same as double-clicking a file in Windows. For example, if we wanted to run minecraft.exe, typing minecraft at the prompt runs that program.
Note
Realize that if the executable file you are trying to run is not in the current directory, you get an error. Unless you have set a path for the directory with the executable file, which is how the command line finds external commands.
If you want to view the contents of a file, most versions of the command line use the edit command. For example, if we wanted to look at the log file hijackthis.log, we would type edit hijackthis.log at the prompt. For 64-bit versions of Windows that do not support this command, you can use the start command (e.g., type start notepad hijackthis.log) to open the file in Notepad. Additional information about opening and editing a file from the command line is available on the page linked below.
- How to open, view, and edit the contents of a file on a computer.
Moving back a directory
You learned earlier the cd command can move into a directory. This command also lets you go back a directory by typing cd.. at the prompt. When this command is typed, you’ll be moved out of the Desktop directory and back into the user directory. To move back to the root directory type cd to get to the C:> prompt. If you know the name of the directory you want to move into, you can also type cd and the directory name. For example, to move into C:Windows>, type cdwindows at the prompt.
- How to change a directory or open a folder.
Creating a directory
Now with your basic understanding of navigating the command line, let’s start creating new directories. To create a directory in the current directory, use the mkdir command. For example, create a directory called «test» by typing mkdir test at the prompt. If created successfully, you are returned to the prompt with no error message. After the directory is created, move into that directory with the cd command.
- How to create a directory or folder.
Switching drives
In some circumstances, you may want to copy or list files on another drive. To switch drives in the Windows command line, type the drive letter of the drive followed by a colon. For example, if your CD-ROM drive is the D drive, you would type d: and press Enter. If the drive exists, the prompt changes to that drive letter. If the drive does not exist or is not accessible (e.g., no disc in CD-ROM drive), you get an error.
- How to copy files from one drive to another drive.
- How to change drives in MS-DOS and Windows command line.
Creating a new file
You can create a new file from the command line using the edit command, copy con command, or using the start command to open a file.
- How to create a file in MS-DOS and the Windows command line.
Creating a new batch file
In the new test directory, let’s create your first file. In most circumstances, you never need to create any file at the command line, but it is still good to understand how files are created. In this example, we are creating a batch file. A batch file is a file that ends with .bat and helps automate frequently used commands in the command line. We are calling this batch file example, so type edit example.bat at the prompt. As mentioned in the document on creating a file, if the edit command does not work, use the start command to open the batch file in Notepad. To perform this action, you type start notepad example.bat into the prompt.
Both of the commands above open a new blank example.bat window. In the file, type the three lines below, which clear the screen with the cls command and run the dir command.
@echo off cls dir
After these three lines are typed into the file, save, and exit the file. If you are in the edit command, click File (or press Alt+F) and then Save. After the file is saved and you are back at the command prompt, typing dir displays the «example.bat» file in the test directory.
Now, run the batch file to get a better understanding of what a batch file does. To run the batch file, type example at the prompt, which executes the batch file, clears the screen, and runs the dir command.
- Full information and additional examples on batch files.
Moving and copying a file
Now that we’ve created a file, let’s move it into an alternate directory. To help make things easier, create another directory for the files. So, type mkdir dir2 to create a new directory in the test directory called dir2. After the new directory is created, use the move command to move the example.bat file into that directory. To do this, type move example.bat dir2 at the prompt. If done successfully, you get a message indicating the file was moved. You could also substitute the move command for the copy command to copy the file instead of moving it.
- How to move files and folders on the computer.
- How to copy files.
Rename a file
After the file is moved into the dir2 directory, move into that directory with the cd command to rename the file. In the dir2 directory, use the rename command to rename the example file into an alternate name. Type rename example.bat first.bat at the prompt to rename the file to «first.bat.» Now, when using the dir command, you see «first.bat» as the only file.
Tip
When renaming any file, make sure the file has the same file extension. If you were to rename the .bat file to a .txt file, it is no longer an executable file only a text file. Also, realize that renaming the file to a different file extension does not convert the file. For example, if you renamed the file as an .MP3, it may look like an MP3 in Windows, but it’s not going to play music.
- How to change or rename a file, folder, or directory.
Deleting a file
Now that we’ve had our fun with our new file, delete the file with the del command. Type del first.bat to delete the first.bat file. If successful, you are returned to the prompt with no errors, and the dir command shows no files in the current directory.
Tip
When deleting files, you can also use wildcards to delete multiple files at once. For example, if the directory contained several .GIF image files you could type del *.gif to delete all files ending with the .gif file extension.
- How to delete a file, directory, or folder.
Renaming a directory
Go back one directory to get back to the test directory using the cd.. command mentioned earlier. Now, rename our dir2 directory to something else using the same rename command we used earlier. At the prompt, type rename dir2 hope to rename the directory to «hope.» After this command is completed, type dir and you see one directory called «hope.»
- How to change or rename a file, folder, or directory.
Removing a directory
While still in the test directory, remove the hope directory using the rmdir command. At the prompt, type rmdir hope to remove the hope directory.
Tip
If the directory you are trying to remove contains any files or directories, you’ll receive an error. To prevent this error, use the /s option. For example, if the hope directory still had the first.bat file, you would need to type rmdir /s hope at the prompt.
- How to delete a file, directory, or folder.
Running a program
Any executable file can run from the command line by typing the name of the file. For example, if you listed files using the dir command and see a file named «myfile.exe,» typing «myfile» at the command line runs that program.
- How to run a file from MS-DOS.
How to list available commands
After getting a good understanding of using the command line from the steps shown above, you can move on to other available commands by typing help at the command line. Typing «help» displays a list of available commands with a brief description of each command.
Closing or exiting the command line window
After you are done with the Windows command line, you can type exit to close the window.
In conclusion
Now you have a good understanding of how to navigate the command line, create directories and files, rename directories and files, and delete. As mentioned earlier, there are hundreds of other commands you can use at the command line. If you want to expand your knowledge further, we recommend looking at the options available for each command above and reviewing our commands overview page. You can also use our search to find any command by the name of the command or by the action it performs.
Command Prompt (or CMD) is Microsoft’s command-line interpreter for its Windows operating systems. It enables you to use commands for performing various operations on your computer — everything from creating new files and moving files between folders to more advanced actions like task automation.
Not just that, you can also use the Command Prompt to carry out administrative operations or fix certain kinds of system issues on Windows. In short, pretty much any action you can think of doing with Windows’ GUI can probably be done more efficiently with its CLI (Command Line Interface) counterpart, thanks to the Command Prompt.
However, to perform any of these actions, you need to be familiar with the Command Prompt commands. In this guide, we’ve put together a list of all such essential commands that you need to know to use the Command Prompt effectively on your Windows PC.
Before you dive into the commands, first, launch the Command Prompt. You can do this in a few different ways. However, the easiest way to go about this is to hit Windows + R key to open Run, enter “cmd”, and press Enter.
Also, while you’re at it, you should pin Command Prompt to the taskbar so you can easily access it next time. For this, with CMD running, right-click on its icon in the taskbar and select More > Pin to taskbar.
With that done, all you have to do now to run a command is to type in the command and hit the Enter key.
1. Find
Find is one of the most useful Windows CMD commands. It lets you search for a string in a file or multiple files and returns the lines that contain the text you specified in your query.
So if you’d like to search for a string in a specific file, you’ll need to run:
find /i "query_string" pathtofile
…where /i is a switch to avoid case-sensitive searching.
Eg:
find /i "command prompt commands" C:UsersDellDocumentsCommands.txt
To search for text in multiple documents:
find /i "query_string" pathtofile1 pathtofile2
In case you still can’t file your document, you can narrow down your search to a specific set of files:
find /i "query_string" *.file_type
Eg:
find /i "command prompt commands" *.txt
2. Copy con
If you haven’t used the command prompt much before, you’re probably using Windows’ GUI to create new files. Although this is perfectly acceptable, there is another (read efficient) way to accomplish this: it involves running the copy con command in the CMD window to speed up the entire process.
To use it, follow the below syntax:
copy con file_name_with_extension
Eg:
copy con MyFile.txt
…and start populating the file with text. Once done, hit Ctrl + Z to save the file.
Alternatively, if you want to create a single-line text file, you can also use the echo command:
echo your_text_here > file_name_with_extension
3. Rename
The rename command enables you to rename files and folders on your computer right from the command line. Run your command in the following syntax to rename a file:
rename current_file_name new_file_name
Eg:
rename File1.txt MyFile.txt
If you want to rename the files in other folders, prepend their path before the filename.
Eg:
rename C:UsersDellDocumentsFile1.txt File2.txt
4. Copy
As its name suggests, the copy command allows copying file(s) from one location on your system to another. It comes with a few different switches to help you extend its scope of use and put it to use for your different requirements. And, you can even use it to combine multiple files.
To copy a file from an existing directory, use the following syntax:
copy file_name destination_file
Eg:
copy MyFile.txt D:Files
When you want to copy a file from a different folder:
copy source_file destination_file
For copying multiple files of the same type in a folder to another location:
copy *.txt D:Documents
Similarly, if there’s a need to combine two files into a new file, enter:
copy file_name_1 + file_name_2 file_name_3
5. Move
Using the copy command, you can create a copy of a file on some other location on your computer. Occasionally, however, when you want to relocate a file or directory to a different location and don’t want an extra copy, you need the move command.
With move, you can move your files/folders by running:
move file_name destination_address
or
move folder_name destination_address
Eg:
move MyFile D:Documents
or
move MyFolder D:
Do note that you need administrative access on your system to move files/folders around, so make sure you’re running CMD as an administrator before carrying out such operations. You can do this by searching “cmd” in Run and pressing the Ctrl+Shift+Enter keys or by right-clicking on its app icon and selecting Run as administrator.
6. Del
Short for delete, the del command helps you delete files from your computer. You can use it in conjunction with switches to get around deletion restrictions on the system.
To delete a file from your current directory, run:
del file_name
For deleting a file inside a folder:
del pathtofile
Eg:
del D:Documentsmyfile
When you want to delete all files in a folder:
del pathtofolder
Eg:
del D:Documents
7. Mkdir
Similar to the copy con and echo command, which let you create files, Windows also has a similar utility to create folders: it’s called mkdir. Using it, you can create a folder or a subfolder within a folder right from the CMD window.
To create a folder in the current working folder, use the following syntax:
mkdir folder_name
When you want to create a folder in other :
mkdir pathtofolder
Eg:
mkdir D:Documents
8. Rmdir
The Rmdir command assists you with deleting a folder or its subfolders on your computer. It also provides a couple of switches to help you in the deleting process.
For removing a folder in the current folder, simply run:
rmdir folder_name
To do it for a folder in another drive:
rmdir pathtofolder
Eg:
rmdir D:Documents
When there are multiple subfolders and you want to delete all of them at once:
rmdir /s pathtofolder
Eg:
rmdir /s D:Documents
Since the above command prompts for confirmation, you can bypass it by adding the /q switch:
rmdir /s /q folder_name
9. Cls
Cls is the most elementary yet significant Command Prompt command. It lets you clear your CMD window that might get crowded with outputs from all the previous commands you’ve run to have a clean slate to work on it again.
To clear your Command Prompt window with it, run:
cls
10. Dir
When working on the Command Prompt, navigating between different folders is one of the basic tasks you’ll need to do.
To this end, Windows has the dir command, which outputs a list of all the folders and their subfolders on your system, so you get an idea about a folder’s content. Not just that, it also returns the total number of files and subfolders along with the free space available on the disk.
You can view the files and subfolders inside a folder by running:
dir
To view a list of all the files of a particular kind:
dir *.extension
Eg:
dir *.txt
When you want to view all folders:
dir /a
Just a list of hidden folders:
dir /a:d
A list of all the hidden files:
dir /a:h
11. Cd
Viewing a list of files and folders on your system is one half of the navigation process; the other requires you to change the folder (or directory). The cd command helps you with just that and features a few different switches to make navigating around a little more convenient.
In addition to changing directories, cd also displays the name of your current working directory, so you can run it to know where you are in your file system.
For this, simply run:
cd
Now, if you wish to go to the root directory of the system, you’d enter:
cd
To change the directory:
cd D:
For accessing a particular folder:
cd C:pathtofolder
Eg:
cd C:Extras
When you want to go to the parent folder of your current folder:
cd ..
12. Sfc
Sfc, short for System File Checker, is a built-in utility on Windows operating systems that enables you to scan and restore the corrupted system files on your PC.
If your system keeps crashing, shows DLL file errors, or displays the BSoD (Blue Screen of Death), it’s likely suffering from file corruption. And, this is where you can use the sfc command to fix such issues.
For scanning your system to identify system file errors, run:
sfc /scannow
[Since it’s an administrative task, you need to be running CMD as an administrator.]
Once the scanning finishes, you’ll get a message showing your system status and whether there’s a need for any fix.
You can also use sfc to scan a specific file by running:
sfc /scanfile=pathtofile
If you just want to scan the integrity without performing repairs:
sfc /verifynow
Similarly, when you only need to verify the integrity of a particular file:
sfc /verifyfile=pathtofile
13. Chkdsk
Similar to sfc, Microsoft also offers another utility called chkdsk (Check Disk), which examines the disk space of your logical or physical drivers to identify its integrity and attempt a fix if there are any errors. It supports various switches that help with scanning and identifying potential parameters for disk failure.
To run a simple chkdsk scan on a drive, make sure you’re running CMD with elevated privileges and use the syntax below:
chkdsk drive_name /f
Eg:
chkdsk D: /f
If you suspect the drive to have bad sectors:
chkdsk drive_name /r
…where /r implies /f but also includes checks for bad sectors.
14. Systeminfo
Systeminfo (or System Information) gives you detailed system configuration information about a PC. You can use it to find out details such as the system model, operating system build, BIOS version, RAM, and installed NIC, among others.
For this, all you have to do is run the following command:
systeminfo
To get system information about a remote computer:
systeminfo /s hostname_or_IP_address
15. Where
The command’s name is pretty much a giveaway here: it allows you to find the installation directory/path for an app on your PC. So you can find out the installation paths for different programs on your computer and use them whenever required. For instance, when there’s a need to change their default launch programs.
Use the following syntax to find out the path for a program:
where program_name
Eg:
where notepad
16. Assoc
Assoc is a powerful CMD command that enables you to change the default associations for the various file extensions on your system. Using it, you can change the default app for opening the different kinds of file types.
For instance, if you want to open all the .txt files in Notepad, you can do so right from the Command Prompt.
To do this, first, identify the existing association for that file extension by running:
assoc .file_extension
Eg:
assoc .txt
Next, make sure you are running CMD as an administrator and find the path for the app that you want to assign. You can do this using the where command.
Copy the returned path and use it with the following syntax:
assoc .file_extension=pathtoapp
Eg:
assoc .txt=C:WindowsSystem32notepad.exe
17. Driverquery
Windows PCs often run into driver issues, be it when you get a new hardware accessory or when an existing one starts malfunctioning out of the blue. In such situations, getting to know the installed drivers on your system can help you identify the problem and find its fix.
The driverquery command helps you with just that: it presents you with a list of all installed drivers on your system.
To use it, simply run:
driverquery
18. Fc
Fc or File Compare gives you the ability to you compare two files and view the differences between them side by side, right from the Command Prompt. So, if you’re in a situation where you’ve got multiple files with similar text in them, you can run them through fc to identify the differences, if any.
Use the syntax below to compare two files:
fc /a file_name_1 file_name_2
…where /a signifies ASCII comparison.
When you want to compare other kinds of files, like .exe, .sys, .obj, .bin, etc., you’d need to add the /b switch:
fc /b file_name_1 file_name_2
19. Ping
Ping is a built-in network management tool on Windows that helps you determine your PC’s connectivity with other devices (computers/servers). So, if you’re facing issues connecting to the internet or another device, you can check your connectivity status by running the ping command in the following syntax:
ping hostname
Eg:
ping google.com
or
ping IP_address
Eg:
ping 142.250.192.46
When you want to ping an IP address and resolve to its hostname:
ping /a IP_address
20. Tracert
Tracert is a slightly more nuanced network troubleshooting utility than ping: it helps you identify the path between the source and the destination point, so you know the path (involving hops) traversed by the network packets.
To trace the path to a hostname, run:
tracert IP_address
or
tracert domain_name
If you want to speed up the process, you can use the /d switch, with the following syntax, to prevent tracert from resolving the IP addresses of hops:
tracert /d IP_address_or_domain_name
21. Netstat
Netstat (or Network Statistics) takes network troubleshooting up a level over both ping and tracert. It presents you a list of many network connection statistics, such as open ports, active connections (incoming and outgoing), and even the routing table to give you a comprehensive overview of your entire network.
It also provides various switches, which you can include in your commands, to get more network statistics.
At its most basic level, you can run netstat to get a list of all the connections to/from your PC.
But to filter out, say, just the active connections and ports, you’d need to run:
netstat -a
For viewing ethernet statistics:
netstat -e
When you want to get the process ID (PID) for each connection:
netstat -o
To view the routing table:
netstat -r
22. Ipconfig
Ipconfig (or IP Configuration) is an important network configuration command that shows you different information about a network, such as its IP address, subnet mask, default gateway, MAC address, DNS server, and DHCP status, to name a few.
Additionally, it also allows you to perform certain network-related operations on your computer, which come in handy during troubleshooting and make the process a lot more convenient.
To get just the basic information about your network, simply run:
ipconfig
For a more detailed look into the network:
ipconfig /all
When you want to release an IP address used by an adapter:
ipconfig /release
To request a new IP address:
ipconfig /renew
For clearing the DNS resolver cache:
ipconfig /flushdns
23. Tasklist
When you experience slowdowns on your computer, one of the likely explanations is the excessive consumption of resources by the processes running in the background. The tasklist command helps you in determining such processes right from the command window by listing down all the currently running processes on your system.
For obtaining a list of all the processes on your system, run the following command:
tasklist
To display verbose task information:
tasklist /v
24. Taskkill
Just as its name suggests, the taskkill command allows you to end running tasks (or processes) on your system. It’s kind of an extension of the tasklist command — responsible for listing all the currently running processes — that helps you end the processes running heavy on your system resources.
So when there’s a need to kill a process, you simply need to run:
taskkill /pid process_ID
Eg:
taskkill /pid 7018
To end a process along with its child processes:
taskkill /pid process_ID /t
For forcefully killing a process:
taskkill /pid process_ID /f
25. Attrib
Attrib is an essential administrative utility that allows you to set or remove attributes assigned to the different files and folders on your computer to deny or grant access to them to other users on your PC. If you’ve got multiple users sharing the same PC, this can prove to be of great use in helping you manage what these users can access on the system.
Before you add or remove attributes for a file/folder, first identify its attributes by running:
attrib file_name
Then, to add a new attribute, use the following syntax:
attrib +r file_name_or_folder_name
Eg:
attrib +r MyFile
…where +r sets the read-only attribute to the file/folder.
Below are some other attributes you can use:
- +h – to set the hidden file attribute
- +s – to set the system file attribute
- +a – to set the archive file attribute
- +v – to set the integrity file attribute
- +x – to set the scrub file attribute to limit background data usage
Use the attribute with the minus sign (–) to remove the attribute. You can also club multiple attributes together in a command to add or remove them from a file/folder.
Efficiently Performing Windows Operations With Command Prompt
Using the CMD commands above, you can perform most of the system operations on your Windows PC quickly and efficiently while saving yourself the extra steps you’d otherwise have to take if you followed the GUI approach.
Of course, these are just some of the Command Prompt commands, and there’s a bunch of other complex commands, like installing programs using Winget, that you can use to carry out advanced operations. We feel the commands on this list will set the groundwork to get you familiar with the Command Prompt and its working to help you become proficient with it.
Was this article helpful?
YesNo