Introduction to windows command line

Command Line Commands – CLI Tutorial

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.
ss5-1

powershell start cmd -v runAs – Run the Command Prompt as an Administrator

Entering this command opens another command prompt window as an administrator:
ss1-1

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.
ss2-1

chdir or cd – Changes the Current Working Directory to the Specified Directory

ss3-1

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.
ss4-1

set – Shows your PC’s Environment Variables

ss5-2

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:
ss6-1

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.
ss7

You can type clip /? and hit ENTER to see how to use it.

assoc – Lists Programs and the Extensions They are Associated With

ss8

title – Changes the Command Prompt Window Title Using the Format title window-title-name

ss9

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”.
ss10

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.
ss11

netstat -an – Shows Open Ports, their IP Addresses and States

ss12

ping – Shows a Website IP Address, Lets you Know How Long it Takes to Transmit Data and a Get Response

ss13

color – Changes the Text Color of the Command Prompt

Enter color attr to see the colors you can change to:
ss14

Entering color 2 changes the color of the terminal to green:
ss15

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

ss16

ipconfig – Shows Information about PC IP Addresses and Connections

ss17

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.
ss18

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.
ss19

For example, you can use powercfg /energy to generate a battery health report.
ss20

The powercfg /energy command will generate an HTML file containing the report. You can find the HTML file in C:\Windows\system32\energy-report.html.

dir – Lists Items in a Directory

ss21

del – Deletes a File

ss22

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.
ss23

start website-address – Logs on to a Website from the Command Line

ss24
ss25

tree – Shows the Tree of the Current Directory or Specified Drive

ss26

ver – Shows the Version of the OS

ss27

tasklist – Shows Open Programs

You can do the same thing you do with the task manager with this command:
ss28
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:
ss29

date – Shows and Changes the Current Date

ss30

time – Shows and Changes the Current Time

ss31

vol – Shows the Serial Number and Label Info of the Current Drive

ss32

dism – Runs the Deployment Image Service Management Tool

ss33

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
ss34

echo – Shows Custom Messages or Messages from a Script or File

ss35

You can also use the echo command to create a file with this syntax echo file-content > filename.extension.
ss36

mkdir – Creates a Folder

ss37

rmdir – Deletes a Folder

ss38

N.B.: The folder must be empty for this command to work.

more – Shows More Information or the Content of a File

ss39

move – Moves a File or Folder to a Specified Folder

ss40

ren – Renames a File with the Syntax ren filename.extension new-name.extension

ss41-1

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.
cls

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.
ss42

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

The Windows command line, also known as the Command Prompt or cmd, can seem intimidating at first glance. However, it’s a powerful tool that allows you to perform various tasks on your computer, such as running programs, managing files and folders, and troubleshooting issues. In this article, we will provide a beginner-friendly introduction to the Windows command line, including its history, basic commands, and some tips for using it efficiently.

An Introduction Windows Command Line for Beginners

An Introduction Windows Command Line for Beginners

The Windows command line has its roots in the DOS (Disk Operating System) command line of the 1980s. The first version of the Windows command line was introduced with Windows NT in 1993 and has undergone several changes and improvements. Today, the Windows command line is an integral part of the Windows operating system and is used by many users, including system administrators and developers. The Windows commands are helpful to find a Printer in the Network.

Accessing the Windows Command Line

Accessing the Windows command line is easy. All you need to do is open the Command Prompt or cmd.exe. You can find it by searching for it in the Start menu or by running it via the Run dialog box (Windows + R). Once the Command Prompt is open, you can type in commands and press Enter to execute them.

Basic Commands

One of the most basic commands in the Windows command line is the “dir” command, which stands for “directory”. This command allows you to view the contents of a specific folder or directory. For example, if you want to view the contents of the “C:” drive, you would type “dir C:” and press Enter. The command will then display a list of all the files and folders in the “C:” drive.

Another useful command is the “cd” command, which stands for “change directory”. This command allows you to navigate to different folders or directories on your computer. For example, if you want to navigate to the “C:\Windows” folder, you would type “cd C:\Windows” and press Enter.

Troubleshooting with Command Line

The Windows command line is also a useful tool for troubleshooting issues on your computer. One of the most commonly used commands for troubleshooting is the “netstat” command, which stands for “network statistics”. This command can be used to view information about active network connections and open ports. For example, if you want to view a list of all active connections, you would type “netstat -an” and press Enter.

Another command that is commonly used for troubleshooting is the “ping” command. This command allows you to test the connectivity between two devices on a network. For example, if you want to test the connectivity between your computer and the google.com server, you would type “ping google.com” and press Enter.

The “ipconfig” command is also useful for troubleshooting network issues. This command can be used to view information about a computer’s IP address, subnet mask, and default gateway. For example, if you want to view your computer’s IP address, you would type “ipconfig” and press Enter.

Tips and Tricks

One of the most important tips for using the Windows command line efficiently is to learn the basic commands and their parameters. Additionally, it is helpful to keep a list of commonly used commands and their parameters for quick reference. Also, when troubleshooting issues, it is often helpful to use the “/?” parameter with a command to view the help information for that command.

Another helpful tip is to use tab completion. This allows you to type the first few letters of a command or file name and then press the Tab key to automatically complete the rest of the name.

The Windows command line has its roots in the DOS (Disk Operating System) command line of the 1980s. The first version of the Windows command line was introduced with Windows NT in 1993 and has undergone several changes and improvements. Today, the Windows command line is an integral part of the Windows operating system and is used by many users, including system administrators and developers.

The Windows command line can be accessed by opening the Command Prompt or cmd.exe. It can be found by searching for it in the Start menu or by running it via the Run dialog box (Windows + R). Once the Command Prompt is open, users can type in commands and press Enter to execute them.

One of the most basic commands in the Windows command line is the “dir” command, which stands for “directory”. This command allows users to view the contents of a specific folder or directory. For example, if you want to view the contents of the “C:” drive, you would type “dir C:” and press Enter. The command will then display a list of all the files and folders in the “C:” drive.

Another useful command is the “cd” command, which stands for “change directory”. This command allows users to navigate to different folders or directories on their computers. For example, if you want to navigate to the “C:\Windows” folder, you would type “cd C:\Windows” and press Enter.

Another important command in the Windows command line is the “netstat” command, which stands for “network statistics”. This command can be used to view information about active network connections and open ports. For example, if you want to view a list of all active connections, you would type “netstat -an” and press Enter.

The “ping” command is also commonly used for troubleshooting network issues. This command allows users to test the connectivity between two devices on a network. For example, if you want to test the connectivity between your computer and the google.com server, you would type “ping google.com” and press Enter.

The “ipconfig” command is another valuable command for troubleshooting network issues. This command can be used to view information about a computer’s IP address, subnet mask, and default gateway. For example, if you want to view your computer’s IP address, you would type “ipconfig” and press Enter.

The “tasklist” command is useful for managing and troubleshooting processes running on the computer. This command can be used to view a list of all running processes and their associated process ID (PID). For example, if you want to view a list of all running processes, you would

Introduction

Side Note — I’ve searched online to find info on many things related to technology. A typical search will yield a lot of blogs and tutorials, and way down the list there is documentation from the company/team that created the product. All this is OK, but i’ve found if you really want to learn something, the best way is a good old-fashioned book (pdf or print). The ideas are whole and complete, and the quality is much higher than a typical blog post (..yea, I know, this is a blog, and no it is not as good as a book).
And now for the big surprise. Most of my content is from books. I did not invent this stuff. And I think it is important to give credit where credit is due. For more information, check out an A+ certification book (I got mine from goodwill for 3 bucks, isnb-9780071745154).

Ok, on to the post. This tutorial only applies to the windows command line, not powershell. To start out, I am not a huge Windows fan. It is expensive, and I am often disappointed in the stability. But, most of us use it at work and home, so we should be using to the best of our ability. So this should help extend your skills at doing basic stuff. There are a few things that I will show you that I prefer to use a mouse and keyboard with, but there are a few things I would rather use the command line with (eg, moving files, mouse, finding the ip address of the computer, keyboard). Also, I am using Windows 7.

Lets get started. To get to a command prompt, we can hold shift and right-click and select open command window here. This is nice because we do not have to change the directory to the our directory we want to work from. You can also just type cmd in the start menu.

If you ever run a command and it is taking forever to finish, we can terminate the command with ctrl+c while in the command prompt.

if you need general help on any command, use

Now, lets get our keyboard hands «dirty».

File Information

The first command is dir. This shows the content of the directory (dir) you are in.

> dir

 Volume in drive C has no label.
 Volume Serial Number is 5033-5C23

 Directory of C:\Users\ngordon\Desktop\test

08/28/2015  07:44 AM    <DIR>          .
08/28/2015  07:44 AM    <DIR>          ..
08/28/2015  07:44 AM    <DIR>          another-test
08/28/2015  07:44 AM                 0 file1.txt
08/28/2015  07:44 AM             8,746 file2.xlsx
08/28/2015  07:44 AM                72 tmp.txt
               3 File(s)          8,818 bytes
               3 Dir(s)  38,038,937,600 bytes free

This is an easy way to see all the files and folders in our current directory. If you want to preserve this information, we can redirect the output to a file tmp.txt with

To get help on the command dir, use

If you just want to see the filenames in 5 columns, we can use a switch with the syntax /W, which looks like this

> dir /W
 Volume in drive  C has no label.
 Volume Serial Number is 5033-5C23

 Directory of C:\Users\ngordon\Desktop\test

[.]            [..]           [another-test] file1.txt      file2.xlsx      tmp            tmp.txt        
               4 File(s)          9,187 bytes
               3 Dir(s)  38,019,055,616 bytes free

Wildcards

If there are alot of files, using wildcards can reduce the clutter. Also note the :: are commets.

:: finds all files
dir *.*

:: finds all files with the extension xlsx
dir *.xlsx

:: finds all files that start with a
dir a*.*

:: finds an exact file
dir file1.txt

Tree

Another cool visual is with the tree command. Just using the tree command only shows the folders in the current directory, which shows up fine in the command window, but is not ascii text.

> tree
Folder PATH listing
Volume serial number is 5033-5C23
C:.
\---another-test

If you want to see ALL the files on your current disk, use the backslash. This may take a while to run on your system drive (C), so remember ctrl+c to cancel

I prefer being able to copy and paste those results into documents. Lets try and figure out how to change the command to give me ascii characters.

> tree /?
C: /?
Graphically displays the folder structure of a drive or path.

TREE [drive:][path] [/F] [/A]

   /F   Display the names of the files in each folder.
   /A   Use ASCII instead of extended characters.

Ah ha. We need to add switches to do that. If you want to see the folders and files in the current directory, try

> tree /F

Folder PATH listing
Volume serial number is 5033-5C23
C:.
│   file1.txt
│   file2.xlsx
│   tmp.txt
│
└───another-test
        file3.txt

Lastly, to create an ascii format list of all files and folders and dump it to a text file, try

attrib

We can also use attrib to get file information in the current directory. The A stands for archive.

> attrib

A            C:\Users\ngordon\Desktop\test\file1.txt
A            C:\Users\ngordon\Desktop\test\file2.xlsx
A            C:\Users\ngordon\Desktop\test\tmp
A            C:\Users\ngordon\Desktop\test\tmp.txt

Navigating

If you want to navigate your system, the cd command is the ticket, to go towards the root of the drive, use cd

cd ..

:: or to go directly to the root

cd \

:: or for multiple traverses

cd ..\..

and to go into another folder use

cd test

:: or for multiple folders

cd Desktop\test\another-test

This can become tedious, so I’d recommend using tab when typing out names. It not only reduces the amount of typing you have to do but also reduced typos.

Lets say you want to search your usb drive. To switch to a different drive other than the default C:, just type

Another modern and handy way to navigate is typing cd and dragging and dropping a folder into the command prompt and hitting enter. This can save some time on those deep folder structures.

Managing Folders and Files

OK, lets make some stuff. To create and destroy a new directory, use md and rd

:: create directory
md newfolder


:: destory an empty directory
rd newfolder

:: BE CAREFUL - recursively destroy directory, and all files and subfolders
rd newfolder /S

To copy a single file or groups of files, use copy

copy file1.txt file10.txt

:: or to copy to a different folder

copy file1.txt another-test\file1.txt

:: or copy all txt files to the subdirectory another-test

copy *.txt another-test

To copy an entire directory, we can use xcopy

:: copy directory another-test and skips empty subdirectories to another-test2
xcopy another-test another-test2

:: to include empty subdirectories, use switch
xcopy another-test another-test3 /E

We can rename files or folders with ren

ren file1.txt text1.txt

:: or more complicated names with spaces
ren text1.txt "text 1.txt"

::change directory name
ren another-test another-test5

To delete a file or files, use del

del tmp.txt

:: deletes all text files in the current directory
del *.txt

Creating New files

It appears that Microsoft deprecated edit, the command line editor. For those of you familiar with vim or nano, this are available on windows, so check them out. But for now, we can use the echo command, to create text files and append them

We can use echo to print text to the command window

Or we can redirect the text to a file

echo this is my first command line text file > file8.txt
echo this is the second line >> file8.txt
echo this is the third line >> file8.txt

for more complicated stuff, we can always open the file with the default text editor notepad.

Automating commands with a batch file

A batch file (*.bat) is a simple windows script that can automate simple tasks.

echo echo hi there > hello.bat

Now we can run the batch file by simply typing the name and executing it

To pause to execution of a bat file, add pause to the end. This is nice if you have an error in the file and want to see what the error is, otherwise it will just close the window

:: waits for keyboard input from user
pause

Advanced command line

To see all the settings Windows loads by default, use

> set
ALLUSERSPROFILE=C:\ProgramData
CommonProgramFiles=C:\Program Files\Common  Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
HOME=C:\Users\ngordon
HOMEDRIVE=C:
HOMEPATH=\
Path=C:\Program Files\Common Files\Microsoft Shared\Windows Live

A common task is adding a program, exe or other, to the default list windows looks for when running. If we want to be able to run a program without executing the command from that directory, we have to add it to the path variable

Lets switch to the root of our c drive and create a folder called batch, and create a batch file that says hi there, and add it to the path so we can be greeted anywhere we are

:: go to the root of the c drive
cd \

:: make a new directory
md batch

:: go into the directory
cd batch

:: create a new batch file that says hi there
echo echo hi there > hello.bat

:: add this new folder to the system path
path=%PATH%;c:\batch

:: move out of the directory and check and make sure the system path works. This moves us to our home directory
cd %HOME%

Now lets test and make sure the system knows where to look for my custom batch scripts.

Excellent. We have covered the basics.

Networking Information

I have found myself using the command line alot when learning about networking. Here are some commands to help you get started with networking info.

:: robust command for networking options, such as seeing things on the network
net view

:: test the communication of  another ip address
ping www.ifcuriousthenlearn.com

:: show network settings
ipconfig

:: tool to find networking information
nslookup www.ifcuriousthenlearn.com

:: traces the path a packet takes to get to the destination
tracert www.ifcuriousthenlearn.com

Summary

We have covered the basics to operate a windows command line. For a lot of work, it is faster than clicking a mouse around, but it takes some practice. There are also some great fundamental tools available found at the command line nearest you. Understanding what is going on in a computer is much easier when you can operate the command lines, as it is an integral part of any operating system. I hope you found this useful, and please comment with any suggestions.

Stay Curious!

A lot of Windows users have never touched the Command Prompt. With today’s streamlined operating systems, it’s easy to use a computer without ever worrying about entering old-school text commands in the command line.

However, it’s a good idea to become familiar with command line basics in Windows. It helps you appreciate the OS more and can come in handy for some tasks. Here’s a beginner’s guide to the Windows Command Prompt for those who aren’t yet familiar.

What Is the Command Prompt?

The Command Prompt, officially called the Windows Command Processor and often abbreviated to CMD, is the command line interface for Windows operating systems. A command line interface is a way of interacting with a computer directly using text commands.

These hearken back to the early days of computers, when you had to type commands into a terminal to execute processes on the machine. Early PC operating systems, like MS-DOS, operated exclusively through command-line interfaces. There were no mouse cursor, window management, or similar graphical user interface (GUI) elements we take for granted today.

Another term you should know is the word «shell,» which is used to describe a program that allows the user to give commands to the computer. So a command line interface, as well as a GUI, are both shells.

Early versions of Windows, like Windows 3.1, effectively ran as a visual interface on top of DOS. Later versions, including Windows 95 through Windows ME, also included MS-DOS integration. These allowed you to run commands through the MS-DOS Prompt, as the Command Prompt was called at the time.

Starting with Windows XP, Windows broke away from MS-DOS. However, in modern versions of Windows, you can still use the Command Prompt to interface with your computer directly instead of clicking through various menus. The Command Prompt can also run batch files; these make automating tasks easy.

Power users prefer the Command Prompt for some tasks, as you can take actions with a few simple keystrokes that would require dozens of clicks in the GUI.

How to Open the Command Prompt in Windows 10 and Windows 11

There are a few ways to open the Command Prompt in Windows. Below are the most convenient:

  1. Type «command prompt» into the Start menu to search for it. You can also type «cmd» (the short name of the executable that runs the Command Prompt) if you prefer.
  2. Press Win + R to open the Run box, then type «cmd» and hit Enter to open it.
  3. Press Win + X (or right-click the Start button) and choose Command Prompt from the menu.
    1. Depending on your Windows settings, this may show Windows PowerShell or Windows Terminal instead. The new Windows Terminal and PowerShell are both more powerful than the Command Prompt, but are backward-compatible with all CMD commands.
Windows Open CMD Prompt

Any of these will open the Command Prompt with regular permissions. A lot of useful commands require you to have administrator permissions, which will fail with a regular CMD window.

To run the Command Prompt as an admin, hold Ctrl + Shift when you launch either of the first two options above. If you use the third option, pick Command Prompt (Admin) (or the corresponding option that appears for you) instead. This will require you to accept a UAC prompt, so you’ll need to be logged into an admin account or provide an admin password.

How to Use the Windows Command Prompt: Basics

When you open a Command Prompt window, you’ll see some basic info about your current Windows version. Below this, you’ll see a line like the below:

C:\Users\[Username]>

This is your current location. Any commands you run that rely on location (such as deleting files) will take place in this folder. Other CMD commands are more general and don’t rely on you being in a specific location.

It’s important to know that when working in the Command Prompt, you must type commands exactly as the system expects. Since you’re issuing commands directly to your computer, it won’t understand if you type something wrong.

If you type a command that your computer doesn’t recognize, you’ll see a message that says ‘[Command]’ is not recognized… and Windows won’t do anything.

Command Prompt Command Not Recognized

This isn’t a problem; what’s more of a risk is accidentally typing the wrong command, or using a command in a way you didn’t intend. For example, when trying to delete one file, you might accidentally tell it to delete an entire folder instead.

The command line will run whatever you tell it, as long as it’s a valid option. So you should always double-check what you’re about to do before you fire it off, and don’t use an admin Command Prompt for general purposes.

Basic Command Prompt Commands for Beginners

There are lots of Command Prompt commands, and most of them aren’t intuitive for newcomers. Learning them takes some time, so it’s best to pick up a few at a time and slowly build your knowledge.

Let’s look at a handful of CMD commands that illustrate its use for a beginner. These are just a very small sampling of what the Command Prompt can do, however. When you’re ready to move on, have a look at more CMD commands you should know, as well as our cheat sheet of handy Windows commands.

Getting Help

CMD Help Example Commands

Typing help will list many common commands that you can use. These will get you started, so you don’t have to go looking for command names on your own.

If you’d like more specific information about how to use a certain command, type it followed by /?. This will give you more help, plus additional options for modifying how it works.

Listing and Changing Directories

Windows Directory Command Example

The dir command, which is short for directory, will list the contents of the folder that you’re currently in. As mentioned earlier, you can check this by looking at the folder that appears to the left of your current command.

To change your current location, use cd (short for change directory) followed by the folder you want to visit. Available folders are marked with <DIR> when you run the dir command.

So for example, to move to your Desktop folder from your default user folder, you would type cd Desktop. You can move up one folder by using the cd.. shortcut.

Creating and Deleting Files and Folders

Use mkdir [new folder name] (make directory) to create a new folder. For instance, mkdir Awesome Pics will make a folder called Awesome Pics.

Similarly, rmdir [folder name] (remove directory) will delete a folder, but only if it’s empty. To delete a file, use del [file name].

CMD Management

If there’s too much clutter on the Command Prompt’s screen, type cls to clear the contents and start fresh. And if there’s a command running that you want to cancel (maybe it’s taking too long), hit Ctrl + C to end it.

Networking Commands

Some of the most useful Command Prompt commands deal with networking. Commands like ping let you see if your computer can reach a remote destination and how long it takes. Meanwhile, ipconfig lets you see the network overview for your current connection.

Ping CMD Example

Learning about CMD commands for managing networks is thus a great use of the tool.

Commands for Troubleshooting

A common use for firing up the Command Prompt is to run one of several troubleshooting commands. CHKDSK lets you scan your storage drives for errors, while SFC allows Windows to detect and fix corrupt system files. For more, see our comparison of CHKDSK, SFC, and DISM.

Taking the Command Prompt to the Next Level

Now you’re familiar with the basics of the Command Prompt, even if you’ve never used it before. Some tasks, like managing files and folders, will probably feel clunky in the command line if you’re used to doing these with the GUI. But for other tasks, like checking your IP address, running a quick CMD command is much more convenient than clicking through a bunch of menus.

While most CMD commands are specific to the Windows environment, Windows 10 and later also allow you to run the Bash shell used by Linux, macOS, and many other OSes. This is worth learning about if you use multiple platforms.

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.jpg

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

Windows-command-line-run.jpg
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.

windows xp cli

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:\work\employees\

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:\games\mygame.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

Windows-command-net-user.jpg

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)

Windows-command-ipconfig.jpg

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

Windows-command-netstat.jpg

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

  • Introducing windows 11 скачать саундтрек
  • Ip адрес time windows com
  • Intra vpn скачать для windows
  • Ip адрес в реестре windows 10
  • Internet explorer нужен ли в windows 10