Which process is using this port?

Sometimes, I get errors like “address is already in use” but struggle to find out what’s using that port. This happens especially with loads of stuff running in background like docker, vagrant vms, local server instances, ssh tunnels etc.

Here’s an easy way to figure out whats running on a certain port:

The second last column refers to the process using that port.

For example, running that on my mac:

Indicates that process ID 5500 is using port 8080. Doing a process check on that tells me:

Hope this helps!

Generating random passwords from linux command line

Managing production passwords isn’t a trivial task. I was trying to deploy a containerized app the other day that had a database deployed with it. During the deployment, I was trying to find an easy way to set a secure password. I didn’t want anyone to know the password because I wanted only the application to know it and no one else. Also, the container was setup in a way that the database cannot be accessed from the outside world.

So instead of hard-coding the password, after doing some research, I used the following command: Continue reading

Some quick tomcat shell functions

Here are some bash profile functions to help you use tomcat as a pro. The following needs to be done in either your .profile file or .bash_profile, depending on what shell you have and whichever method you prefer. First off, make sure you have exported CATALINA_HOME variable pointing to the base of your tomcat installation.

Once you’ve got that done, you can define the following shell functions. Continue reading

Streaming folders from a server over SSH using tar and gzip

This is how you can stream a folder or multiple folders from a server over SSH protocol.

To stream folders in uncompressed, raw format, run:

Since the tar file is being streamed raw, this could potentially take longer as more data is being passed between server and client. In my test for 700 megabytes of data, this command took 1:56 seconds.

There’s another method. Continue reading