Sometimes you may get the error "port already in use" or "port already open" when you install a application or when you start any server . That means the mentioned port is used by an application. For Example you may get the following error when you start the test server in WSAD .
This is due to, we may have terminated the WSAD by using Task Center when it is not responding. When you again load WSAD , starting the test server will the above error. This can be solved either by restarting the system or Stopping / Killing the process which uses the port . The same error may also occur when you install new application or when you run a java program (Socket Programming), in this situation you can use new port or if you want to use the same port means , you have to kill the process which uses the port.
Steps to end / stop / kill the process which uses the port
First find out the process id of process / application which is using port . To find out the process id of a process using the port no
netstat -aon | findstr "<port number>"
For example to find the process id of the application which is using the port 9080 , use the following command
C:\>netstat -aon | findstr "9080"
When you run the above command ,if the port 9080 is already used , then the following output is displayed
TCP 0.0.0.0:9080 0.0.0.0:0 LISTENING 3800
The number in the last column is the process id (PID) of the process holding the socket. That is 3800
Once PID is known, one can kill the application which corresponds to the PID using "Windows Task Manager" . (Note : to display the PID value in Task Manager, go to Processes tab, open View menu, then Select Columns)
or Using Command prompt to kill the process using process id , you can use the following command
taskkill /PID processid
Command to kill the processid 3800 , use the following command
c:\> taskkill /PID 3800
Solution for Port already in use / Port already open. How to close a port in windows whis is in already in use or open ?
How to find Which Port is in use in Windows?
- displays all ports which are in use.
- displays which applicatiosn use which ports
The following is the output of the command . test-pc is the name of the PC.
TCP test-pc:9090 test-pc:0 LISTENING 5628
[javaw.exe]
in the above output , 9090 is the port which is used by javaw.exe.
Some more outputs of the command.
TCP test-pc:523 test-pc:0 LISTENING 396
[db2dasrrm.exe]
TCP test-pc:912 test-pc:0 LISTENING 4044
D:\WINDOWS\system32\WS2_32.dll
E:\Program Files\VMware\VMware Workstation\vmware-authd.exe
D:\WINDOWS\system32\kernel32.dll
[vmware-authd.exe]
TCP test-pc:1998 test-pc:0 LISTENING 6904
[javaw.exe]
TCP test-pc:2000 test-pc:0 LISTENING 5628
[javaw.exe]
TCP test-pc:5900 test-pc:0 LISTENING 3524
[tvnserver.exe]
TCP test-pc:6789 test-pc:0 LISTENING 3180
[db2jds.exe]
TCP test-pc:9090 test-pc:0 LISTENING 5628
[javaw.exe]
TCP test-pc:9094 test-pc:0 LISTENING 5628
[javaw.exe]
TCP test-pc:9095 test-pc:0 LISTENING 5628
[javaw.exe]
TCP test-pc:9096 test-pc:0 LISTENING 5628
[javaw.exe]
TCP test-pc:12345 test-pc:0 LISTENING 2808
[tmlisten.exe]
TCP test-pc:db2c_DB2 test-pc:0 LISTENING 4904
[db2syscs.exe]
How to use Path Command in DOS / Windows , Setting path for Java package
When you execute a command , Operating System will search the command in the current directory , if the command is not available in the current directory , then OS will search the folders specified using PATH command.
Path Displays or sets a search path for executable files. This is an Internal Command which is available in the following operating systems.
MS-DOS
Windows 95
Windows 98
Windows ME
Windows NT
Windows 2000
Windows XP
Windows Vista
Windows 7
Syntax : PATH [[drive:]path[;...][;%PATH%]
PATH ;
Uses :
Path - to Display the current paths
Path; - to clear all search path which is currently available and the os will search only in the current directory.
path=d:\Sun\SDK\jdk\bin;
Now the path is set to d:\Sun\SDK\jdk\bin; which you can execute javac , java executable files from the current directory.
path=%path%;d:\Sun\SDK\jdk\bin; Search path includes already available search path + d:\Sun\SDK\jdk\bin;
Example : How to set path for java package from the current folder ?
--------
d:\Javacode> - folder where your java files are located.
d:\Sun\SDK\jdk\bin; - folder where javac, java (java compiler, interpreter) are located.
Now you set the path from the current folder as follows
d:\Javacode> path=%path%;d:\Sun\SDK\jdk\bin;
- Now you can compile , run the java files from the javacode folder.
How to Access Linux Desktop from Windows?
By using Virtual Network Computing (VNC) , you can display or access the Linux desktop from any Network or Internet. Linux Desktop can be accessed by another Linux
System or Windows System which is on a network or internet. Here letus focus on
Steps to be followed for accessing Linux Desktop from Windows System
We have to establish a VNC connection to a desktop environment (such as KDE or GNOME) on the Linux system
Step 1. Ensure VNC server is installed and running on the Linux system whose desktop you want to access. ( from windows system)
Step 2. Ensure VNC viewer client installed on the system on which you want to display your Linux desktop. (TightVNC)
Step 3. Secure shell (ssh) connection may be established between the Linus & Windows system.
How to Get VNC Server and Client ?
Recent releases of Linux such as Redhat Linux and Fedora Core come with vncserver which is installed automatically. You can also use TightVNC which can be downloaded for free from http://www.tightvnc.com/download.html
Detail of Step 1 :
------------------
How to Start & Stop the the VNC Server in Linux system.
To start the VNC Server , run the command vncserver
when you run the command first time , it will ask password. give password. then You will get the following message if you are a root user:
New 'vkj:3 (root)' desktop is vkj:3
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/vkj:3.log
where vkj is the hostname of the linux machine.
To change the password use the command vncpasswd
The above statement indicates that vncserver has started up an X server as display :3 on system "vkj" and that it has created a sub-directory called .vnc in the /root
directory that started the server containing a startup script xstartup. In addition it creates a log file that can be used to diagnose any problems when the server failed to start.
To stop the VNC server , run the following command:
vncserver -kill :3
where the :3 matches the display that was indicated when vncsever started up. This will display something along the lines of:
Killing Xvnc process ID 9523
Configuring the Desktop Environment to be Launched by VNC. When we start the vncserver it runs the script xstartup which is located in the folder .vnc under /root or /home/username/.vnc for other than root user.
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
To launch the GNOME desktop environment change the twm line in xstartup to:
gnome-session &
Similarly to launch the KDE desptop environment change the line to:
startkde &
Detail of Step 2 :
------------------
Installing the VNC Viewer Client
---------------------------------
Next step is to install the client side VNC viewer on Windows machine. (vncviewer incase of linux) . TightVNC can be used which can be downloaded from
http://www.tightvnc.com/download.html
Detail of Step 3 :
-----------------
Establishing a SSH between the two systems :
Due to security reasons, it is recommended that the VNC communication take place through an encrypted secure tunnel connection. SSH can be used On Linux for secure remote connection. On Windows we can use PuTTY which is freely downloaded from http://www.putty.nl/download.html
By default the VNC server will use the port 59xx for communication where xx represents the display number. If vncserver is running as display :1 then the port being used is 5901. If it running as display :3 then port 5903 is used. Suppose if the VNC is using the port 5903 on a system called "vkj" then can establish an ssh connection as follows:
Windows using PuTTY:
--------------------
1. Start PuTTY, enter the hostname or IP address of the system running VNC server. In our example this is "192.168.79.128" ip address of vkj
2. Set the "SSH" toggle.
3. Select the SSH --> Tunnels option from the tree and enter the following information:
Source port: 5903
Destination: 192.168.79.128:5903 , The click on add button.
4. Save the profile you have entered by selecting "Session" from the Tree, entering name (in our example kk) in the "Saved Sessions" text field and press "Save"
5. Press the "Open" button to establish the secure connection.
You will be prompted for a password for the user under which you are logging in.
( Note : incase of Linux system use the command : ssh -L 5903:localhost:5903 vkj)
Launching the VNC Viewer Client
On Window using TightVNC simply launch the TightVNC viewer and enter localhost:3 into the Connection details dialog and press "OK".
( in case of Linux or UNIX , ou have to give the command : vncviewer localhost:3)
Now You will be prompted for a password. This is the password of vncserver.
Making secure connections between Linux to Linux is very easy by using the inbulit command (SSH) . eg. $ssh root@192.168.79.128 where 192.168.79.128 is the IP address of the destination linux system.
For making Secure Shell(SSH) connections between Windows to Linux , we can use the free utility Putty which is freely availabe from http://www.putty.nl/download.html . Now let us see how to use putty. Run the putty.exe , a window will open as follows.
The following steps should be followed.
1) Give Hostname or IP Address of the Linux Machine in the Hostname textbox .
2) Select the option SSH which will display the port 22 ( SSH will use the port 22)
3) You can save this session for future access by giving the name in the text box of the saved sessions.
4) Click on the Open button which will ask the username and password.
Now the connection between windows & linux is secured.
Start / Stop Services in Windows & Linux
1) Windows Services can be started by net start
Windows Services can be stoped by net stop
Full list of the services can be found in the registry under the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services . Registry can be opened by running Run->regedit
eg. net start DB2-0 ---> starting db2 service.
2) You can also start/stop by using Run->services.msc which will open the following window. You can select any services and start & stop by manualy.
Linux
1) service service name stop or start or restart or status
to stop/start/restart the service of httpd use the following commands.
service httpd stop
service httpd start
service httpd restart
service httpd status
2) All scripts for start/stop/restart of all services are are located in /etc/init.d directory . List of scripts of services can be seen by $ls /etc/init.d
so you can just go there and type the script name and either stop or start or restart
or /etc/init.d/
eg. /etc/init.d/httpd status ->to check httpd status.
/etc/init.d/httpd stop -> to stop httpd service.
/etc/init.d/httpd restart -> to restart httpd service.
To stop httpd service at startup you can use the chkconfig command:
chkconfig --levels 3 httpd off