Tag Archives: Server

What’s running on port 80 in Windows?

Trying to set up Apache on a server, something is hogging port 80, but very “helpfully” the Resource Monitor just reports “System” with PID 4…

However, some commands found in a StackOverflow answer and its comments were helpful:

netsh http show urlacl
netsh http show servicestate
net stop http

Note: Do not just run these commands blindly and turn off services (in particular you should probably answer N when the last one asks…), but use them to identify what service(s) might be to blame. Then do an intelligent decision on whether the service is needed or not, before you potentially stop it and disable it…

Ubuntu server upgrade

# Get list of available upgrades
sudo apt-get update

# Upgrade packages
sudo apt-get upgrade

# Upgrade distro
sudo apt-get dist-upgrade

Remove old kernels

# Reboot into newest first, of course
sudo shutdown -r now

# Remove all old kernels
sudo apt-get remove --purge $(dpkg -l 'linux-image-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')

Notes on Minecraft hosting

Just notes to self that I keep having to find in various documents and random Minecraft forums of varying quality of which there are a lot…

Screen stuff

I have an unused laptop which I installed Ubuntu Server on, and this is what I use to run the Minecraft server so it’s easy to manage and won’t die when I disconnect.

# Run detached in screen using dir name as screen name
screen -dmS ${PWD##*/} java -Xmx3G -XX:MaxPermSize=256M -jar server.jar nogui

# List screens
screen -ls

# Reattach to specific
screen -r name

# Reattatch to whatever (handy if just one running)
screen -raAd

# Detach (important, since Ctrl+c would shut down the server)
Ctrl+a, Ctrl+d

Minecraft server stuff

A bit cheaty, especially the last one, but sometimes you just want to play without worrying about losing what you spent way too many hours working on. I prefer a gravestone mod over the last one though, cause then dying is still an annoyance, but at least you have a chance of getting back that crazy expensive armor and the fifteen stacks of diamonds you just spent forever digging up.

# Prevent creepers and such from destroying stuff
gamerule mobGriefing false

# Don't lose stuff when dying
gamerule keepInventory true

Java: Simple check to see if a server is listening on a port

Here is a simple method to check if a server is listening on a certain port. I used it to ignore certain non-critical SFTP related integration tests in a project when I hadn’t bothered starting the SFTP server.

public static boolean serverListening(String host, int port)
{
    Socket s = null;
    try
    {
        s = new Socket(host, port);
        return true;
    }
    catch (Exception e)
    {
        return false;
    }
    finally
    {
        if(s != null)
            try {s.close();}
            catch(Exception e){}
    }
}

To ignore a test (assuming JUnit) you can then do the following:

@Test
public void some_test()
{
    assumeTrue(serverListening("localhost", 22));

    // Rest of test...
}

Ultra simple SFTP server for Windows

Core FTP mini-sftp-server interface
Was going to test some code the other day which needed to talk to an SFTP server. Stumbled over a small gem which was super simple to use. It’s called Core FTP mini-sftp-server. No installation, no tricky stuff. Just download and run. Great stuff 🙂

Note: They also have a not-mini-sftp-server, which is the first dowload, so make sure to get the right download link.