Technology Insights

How to Reset a Serial Port in Linux, ttyS0, ttyAM0, etc.

When connecting to a Linux device using a serial port there may be times where that connection becomes stuck open and thus will not provide sane output to the TTY port. This issue can be resolved by killing the PID (Process ID) and letting the serial port process restart.

The serial port connection should be configured in inittab which will allow you to specify various configuration options as well as respawning the process. So when you specify respawn the process will automatically restart if it is no longer running as will be the case if you kill the process off. The inittab entry will look similar to one of the two below examples.

Technology Insights

Windows XP: Figure Out What Service is Running on a Specific Port

Finding out what application is running on a specific port in Windows XP is easy by using two command line utilities. By using netstat with the proper switches you can list out all of the ports that are being used and then use Tasklist to list all of the applications that are running. The combination of the two utilities will allow you to figure out which application us using which port. As an example you can use the below directions to figure out what application is using port 80 for instance.

  1. Open Command Prompt: Click Start in the lower left hand corner of your PC and then select Run from the pop up. Type command in the Run window and click Enter to open up the command prompt.

Technology Insights

The Linux Kill Command Explained in Detail

The Linux kill command is used to kill PID’s or process ID’s. This command is beneficial for numerous reasons typically for run away processes, processes caught in some sort of loop, to kick users from a system, or any other number of reasons.

Typically kill is used in the below format with 12345 being the PID in this example.

bash

  1. [root@server ~]# kill 12345

If the process will not die from using the above command the -9 switch can be added to force it to stop as shown below.

Technology Errors

Postgres ERROR: database “dev” is being accessed by other users

If you are having issues dropping a postgres database the issue is more than likely that a user is accessing the database you are attempting to drop. There isn’t technically a way to force drop the postgres database however there are steps you can take to prevent others from accessing the database and if needed kick the users whom are accessing the database.

If you receive an error similar to the below the issue with your attempt to drop the database is the fact that either a user is accessing the database or an application of some sort has an open connection to the database. In the second scenario PostgreSQL considers the application the same as a user. In the code below the name of the example database is dev.

Please note that dropping the database will destroy all data located within the database. I strongly suggest always backing up your data before dropping the database. You can backup the data with pg_dump and regardless of if you think you will need the data or not it is best to keep a copy just in case.