May 232016

ADM

Windows basics commands and tools for developers

  • May 23 2016
  • ADM

 

 

Windows basics commands and tools for developers - windows

 

I think Windows doesn't need any other introduction as is one of the most used operating systems and there is a big chance that you are currently reading this from a Windows.

I will use for all tools and commands from this tutorial a Windows 7 installations. Some of the commands are available on all Windows versions but some are not.

Table Of Content

Command Prompt

sA command prompt is an entry point for typing computer commands in the Command Prompt window. You can perform tasks on your computer without using the Windows graphical interface.

There are two ways of open the Command Prompt Windows:

  • click the Start button -> click All Programs -> click Accessories and then click Command Prompt.
  • click the Start button -> in the Search box, type Command Prompt -> in the list of results, double-click Command Prompt.

Windows basics commands and tools for developers - WindowsCommandPrompt

Basic Commands

All commands need to be followed by pressing <ENTER> key. If you need help for a specific command you can type the command name followed by /?. Example:
c:\>cls /?
Clears the screen.

CLS

c:\>

Cls

Used to clear the Command Prompt Windows.

Cd

Displays the name of or changes the current directory. Very useful to navigate through the computer disc. Here are some examples:
  • c:\cd admfactory - will change the current folder to c:\admfactory
  • c:\admfactory\cd .. - will go back to c:\
  • c:\admfactory\projects\jdbc\tutorials\cd / - will go directly to the root: c:\ instead of using multiple times cd ..

Windows basics commands and tools for developers - WindowsCdCommand

Dir

Displays a list of files and subdirectories in a directory.

Echo

Displays messages, or turns command-echoing on or off. Useful from .bat files to display messages to the console.

Ping

If you need to know is a specific networked device (e.g. server) is up you can use ping command. The ping command is working with both hostname and IP address. The ping command will send a series of test packets to the specified address. If they arrive and are returned, you know the device is capable of communicating with your PC; if it fails, you know that there's something blocking communication between the device and your computer. Also note that is the test address is a web server it might have the ping response disable and in that case you will not get any response back.

Usage with hostname:

C:\>ping www.google.com

Pinging www.google.com [216.58.213.68] with 32 bytes of data:
Reply from 216.58.213.68: bytes=32 time=15ms TTL=128
Reply from 216.58.213.68: bytes=32 time=13ms TTL=128
Reply from 216.58.213.68: bytes=32 time=13ms TTL=128
Reply from 216.58.213.68: bytes=32 time=13ms TTL=128

Ping statistics for 216.58.213.68:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 13ms, Maximum = 15ms, Average = 13ms

C:\>

Usage with IP address:

C:\>ping 192.168.136.2

Pinging 192.168.136.2 with 32 bytes of data:
Reply from 192.168.136.2: bytes=32 time<1ms TTL=128
Reply from 192.168.136.2: bytes=32 time<1ms TTL=128
Reply from 192.168.136.2: bytes=32 time<1ms TTL=128
Reply from 192.168.136.2: bytes=32 time<1ms TTL=128

Ping statistics for 192.168.136.2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

C:\>

Telnet

Telnet is a simple, text-based program that allows you to connect to another computer by using the network. Telnet will allow you to enter commands used to access programs and services that are on the remote computer, as if you were sitting right in front of it. Also you can use it to check if the application is up and running. It require two parameters hostname (or IP address) and the port.

Usage

c:\>telnet www.google.com 80

If you got the message

c:\>'telnet' is not recognized as an internal or external command,
operable program or batch file.

telnet command is not installed. To install it follow these steps:

  • Click the Start button , click Control Panel, and then click Programs.
  • Under Programs and Features, click Turn Windows features on or off. If you're prompted for an administrator password or confirmation, type the password or provide confirmation.
  • In the Windows Features dialog box, select the Telnet Client check box.
  • Click OK. The installation might take several minutes.

Where

Sometimes you don't know where a program is installed. Here come in handy where command. The command will tells you where is installed the program you are searching for.

Usage

C:\>where telnet
C:\Windows\System32\telnet.exe
C:\>

The example displays the path to the telnet command.

Note: will work only for applications that are added to the Path.

Ipconfig

If you want to see the IP configuration you can use ipconfig command. The command will display all network adaptors installed in your computer.

C:\>ipconfig

Windows IP Configuration


Ethernet adapter Bluetooth Network Connection:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . : localdomain
   Link-local IPv6 Address . . . . . : fe80::c9a4:7f4b:1799:7c20%11
   IPv4 Address. . . . . . . . . . . : 192.168.136.129
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.136.2

Tunnel adapter isatap.{235CC12E-1A08-4683-8E60-0B57438D430E}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Tunnel adapter Local Area Connection* 13:

   Connection-specific DNS Suffix  . :
   IPv6 Address. . . . . . . . . . . : 2001:0:5cf2:840f:1817:1724:3f57:777e
   Link-local IPv6 Address . . . . . : fe80::1817:1724:3f57:777e%13
   Default Gateway . . . . . . . . . : ::

Tunnel adapter isatap.localdomain:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : localdomain

C:\>

"ipconfig /release" followed by "ipconfig /renew" can force your Windows PC into asking for a new IP address, which is useful if your have an IP conflict. You can also use "ipconfig /flushdns" to refresh your DNS address.

Hostname

Hostname command is used to get the computer name.

C:\>hostname
admfactory

C:\>

Netstat

This command is used to get the list of all ports and IPs associated. You'll also be told what state the port is in - listening, established or closed. This is a great command if you're trying to troubleshoot the devices (or servers) your PC is connected to.

C:\>netstat -an

Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3306           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:5357           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:27017          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49152          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49153          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49154          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49155          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49156          0.0.0.0:0              LISTENING
  TCP    127.0.0.1:3333         0.0.0.0:0              LISTENING
  TCP    127.0.0.1:3333         127.0.0.1:49185        ESTABLISHED
  TCP    127.0.0.1:3334         0.0.0.0:0              LISTENING
  TCP    127.0.0.1:49172        0.0.0.0:0              LISTENING
  TCP    127.0.0.1:49185        127.0.0.1:3333         ESTABLISHED
  TCP    192.168.136.129:139    0.0.0.0:0              LISTENING
  TCP    [::]:135               [::]:0                 LISTENING
  TCP    [::]:445               [::]:0                 LISTENING
  TCP    [::]:3306              [::]:0                 LISTENING
  TCP    [::]:5357              [::]:0                 LISTENING
  TCP    [::]:49152             [::]:0                 LISTENING
  TCP    [::]:49153             [::]:0                 LISTENING
  TCP    [::]:49154             [::]:0                 LISTENING
  TCP    [::]:49155             [::]:0                 LISTENING
  TCP    [::]:49156             [::]:0                 LISTENING
  UDP    0.0.0.0:3702           *:*
  UDP    0.0.0.0:3702           *:*
  UDP    0.0.0.0:3702           *:*
  UDP    0.0.0.0:3702           *:*
  UDP    0.0.0.0:5355           *:*
  UDP    0.0.0.0:49166          *:*
  UDP    0.0.0.0:52904          *:*
  UDP    0.0.0.0:59851          *:*
  UDP    127.0.0.1:1900         *:*
  UDP    127.0.0.1:49736        *:*
  UDP    192.168.136.129:137    *:*
  UDP    192.168.136.129:138    *:*
  UDP    192.168.136.129:1900   *:*
  UDP    192.168.136.129:49735  *:*
  UDP    [::]:3702              *:*
  UDP    [::]:3702              *:*
  UDP    [::]:3702              *:*
  UDP    [::]:3702              *:*
  UDP    [::]:5355              *:*
  UDP    [::]:49167             *:*
  UDP    [::]:52905             *:*
  UDP    [::]:59852             *:*
  UDP    [::1]:1900             *:*
  UDP    [::1]:49734            *:*
  UDP    [fe80::c9a4:7f4b:1799:7c20%11]:546  *:*
  UDP    [fe80::c9a4:7f4b:1799:7c20%11]:1900  *:*
  UDP    [fe80::c9a4:7f4b:1799:7c20%11]:49733  *:*

C:\>

You can notice the MySQL's port - 3306 or MongoDB's port - 27017.

Task Manager

Task Manager is a very useful tool in monitoring. It provides informations about your resources, running applications, services network and users. Also you can use it to stop/start an application or service.

To start Task Manager you have several options:

  • right click on Taskbar -> select Start Task Manager;
  • press Ctrl+Alt+Del -> select Start Task Manager;
  • press Start button -> type Task Manager -> from search result list select View running processes with Task Manager;

The Task Manager window will look like this:

Windows basics commands and tools for developers - WindowsTaskManager

On Services tab if you select a service and right-click on it you have the start and stop options.

On Processes tab if you select a process and right-click on it you have in the menu End process option.

Services

A Windows service is a computer program that operates in the background. E.g. MySQL or MongoDB. Within Windows Services window you can start/stop/pause a service.

To open Services application you have two options:

  • press the Start button -> click on Control Panel -> click System and Security -> click Administrative Tools -> double-clicking Services.
  • press Start button -> type Services -> from search result list select Services.

If you're prompted for an administrator password or confirmation, type the password or provide confirmation.

Windows basics commands and tools for developers - WindowsServices

Registry

The Windows Registry is a hierarchical database that stores low-level settings for the Microsoft Windows operating system and for applications that opt to use the Registry. You must use it with extra attention as you make broke the functionality of the application that you are modifying registry for.

To open Windows Registry application you have two options:

  • press Start button -> type regedit -> from search result list select regedit.exe

If you're prompted for an administrator password or confirmation, type the password or provide confirmation.

Windows basics commands and tools for developers - WindowsRegistry

Environment variables

Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer. In other words there are global variables that can be access by any running program on your PC.

To open Environment variables application you have two options:

  • press the Start button -> click on Control Panel -> click System and Security -> click System -> click Advanced system settings on the left menu -> click Advanced tab -> click Environment Variables ...
  • press Start button -> type Environment Variables -> from search result list select Edit the system environment variables.

If you're prompted for an administrator password or confirmation, type the password or provide confirmation.

Windows basics commands and tools for developers - mavenWindowsVariables

These are two groups first for current user and second for the entire system. If you want that the settings to be accessible only for you use the user dedicated section otherwise use the the system section.

To add/modify/delete use the buttons bellow each table.

If you want to see if the variable is accessible for you you can check it from command prompt using echo command follow by the variable name between %% characters.

C:\>echo %JAVA_HOME%
D:\apps\\jdk1.8.0_51
C:\>

PATH variable

PATH is an environment variable that holds all the executable shell commands. When you type something in the command prompt, it will go through all the path and search for the match of the command line utility name you have just entered. PATH is one of the most important variable. If you want to edit or add some new paths to the PATH variable follow the steps described in the previous section.

Event Viewer

Event Viewer, a component of Microsoft's Windows NT line of operating systems, lets administrators and users view the event logs on a local or remote machine. Applications and operating-system components can use this centralized log service to report events that have taken place, such as a failure to start a component or to complete an action.

If you have an application that is failing this is good point to start for clues.

To open Event Viewer application you have two options:

  • click the Start button -> click on Control Panel -> click System and Security -> click Administrative Tools -> double-clicking Event Viewer.‌
  • press Start button -> type Event Viewer -> from search result list select Event Viewer

If you're prompted for an administrator password or confirmation, type the password or provide confirmation.

Windows basics commands and tools for developers - WindowsEventViewer

Conclusion

This article doesn't cover every Windows command available or every tools. There are hundreds of them. In this tutorial I covered the most used by me in a daily bases routine.

If you have any comments or suggestions for other commands/tools please drop a line in the Comments section or use the contact us page.

References