Finally a decent terminal for Windows

Tip! Check out my new post about making the terminal great again here

For years and years Windows users have had to work with disabled tools when trying to work in the command line interface. The old cmd had a bad interface, and even powershell until very recent, has also been a pain. One of the most annoying things has been the missing ability to adjust the window size to your needs, furthermore tab completion has either been missing or bad implemented. All in all, flexibility has not been a keyword for any of the old terminals, but this is all in the past, because now we have Windows terminal!

Easy to install from the Windows store or with command line package manager like chocolatey, and has a great deal of the features you know from various Linux terminals.

Windows terminal supports multiple terminals in tabs, split panes horizontal and vertical, custom background and a lot more. Check it out here: https://github.com/microsoft/terminal

If you are a Linux user and sometimes have to work from Windows, Windows terminal also work perfect with WSL (Windows Subsystem for Linux). Install the terminal, install your favorite Linux, and you are good to go. Here are some small tips to make the experience even better:

  1. Make Linux the default shell by editing the json settings file. You find it by clicking the small “down-arrow” and select settings. Add the guid number of the Linux you want to start to the defaultprofile setting.
  2. Make the Linux shell start in the Linux home folder by adding this setting to the bottom of the paragraph of your Linux profile:
    “commandline”: “wsl.exe ~”

If you are interested in command line stuff, and working on Windows, this is a nice resource to follow: https://devblogs.microsoft.com/commandline/

Looking for clear text authentication with tcpdump

Login services not using encryption, is unfortunately still often seen in the wild. I started out in the IT business around 2000, and even back then, clear text authentication was bad, but still we see it today.

Examples of services using clear text authentication is: HTTP, FTP and telnet. Don’t ever authenticate using any of these protocols, unless you know exactly what you are doing.

Sometimes you may want to verify, if the password is actually sent in clear text, and one of the tools to use is tcpdump. Tcpdump is the default network analyse tool on most Linux distributions, and it’s very easy to get started with. Maybe you just want to know if your network changes is routing traffic to your server, you can use tcpdump to verify.

When sniffing for clear text passwords, we need to give the parameters -s 0 and -A and then we can give the destination port the service is listening on with dst port. So the full command would look like this:

tcpdump -s 0 -A dst port xxx

You can also specify the interface to listen on, by using the -i option. If your interface is enp0s31f6, then it would look like.

tcpdump -i enp0s31f6 -s 0 -A dst port xxx

Another option is the “and” and the “not” keyword. Imagine you are logged in with SSH, and looking for ssh traffic, but you don’t want to see your own traffic. The you can use and not host ${your own IP address}, like this

tcpdump -i enp0s31f6 dst port 22 and not host xx.xx.xx.xx

In the last example i have removed the -s 0 and the -A option, since i don’t need it just to see if traffic is getting to my server.

Nvidia MX150 mobile GPU on Ubuntu with secure boot

I just got a replacement laptop, as my previous Thinkpad T580 started to freeze after > 10 minutes of usage. Luckily my company just replaced the thing, so I didn’t have to think about anything else than reinstalling (since i don’t use coorporate Windows image) and copy in my backup.

The T580 has a Nvidia MX150 GPU alongside with the Intel. I had some issues getting this to work on my old laptop, when I initially installed it with Ubuntu 18.04. Working with the Nvidia driver, pre-summer 2019’ish on Linux, reminded me of trying to get the xserver to work some decades ago. If you don’t know what I’m talking about, pleaae watch Bisqwit trying with SlackWare 3.0 in this video: https://www.youtube.com/watch?v=EanGvOBhr9s

Well, lets forget about the past and watch ahead. Since Ubuntu 19.10 was released, all this Nvidia stuff should be much easier, as Nvidia drivers are now build into Linux and Ubuntu is working to make everything easier.

During installation I selected install third party drivers, and that should more or less be it – it should work. But of course it did not, otherwise I would not have been writing this. Somehow it seemed like Ubuntu was not recognizing the GPU. The prime profile application gave me an option to choose what GPU to use, but it kept using the Intel even though I told it to use Nvidia. After some time of debugging, I learned, that in order to use the Nvidia GPU you have to disable secure boot. I rebooted to BIOS, disabled secure boot, and everything is now working as expected.

LGSM CS:GO not starting

I’m running a small CS:GO server for the local E-Gaming club. It’s based on https://linuxgsm.com/, which makes managing game servers easy.

Today I got a call from the trainer, telling that the server was not running. I have some tasks running every night to check for updates, and my first thought was that something had gone wrong during the update.

when trying to start the server with: “./csgoserver st” it tried to start but immediately stopped again. I inspected the console log file and found hundreds of files, with very few lines in them:

#AppFramework : Unable to load module bin/engine.so!
#Unable to load interface VCvarQuery001 from bin/engine.so, requested from EXE.
Wed Dec 11 16:55:14 CET 2019: Server Quit

Searching google for this did not give me anything related to my issue. Trying to communicate with someone in the LGSM discord channel did not give me any success as well. I tried installing the server again with “./csgoserver i” and I tried the variuos options for updating the server – no luck.

Finally i tried the validate command “./csgoserver v” and even though it seemed to be running forever without anything happening, it finally showed progress, and after 5-7 minutes it finished.

I was now able to start the servers (I have more than one instance, running of the same source) and everything seems to be running just fine.

My assumption is that some kind of download got aborted during an update, and therefore missed or corrupted some files.

Portable headless Linux box

I have a Raspberry Pi that I’m using in different environments. The easiest way to use the Pi is by just connecting power and network and use SSH, but when theres no screen, it’s not always easy to know the IP address of my Pi.

To make life easier for myself i have put the following lines in a start.sh script and added it to my crontab with the @reboot option. This will make crontab run this script every time the Pi has been rebooted (or shut down)

#!/bin/sh
sleep 30
echo “My IP is: $(ip addr | grep global | awk -F ‘ ‘ ‘{print $2}’)” | mail -s “Raspi reporting in…” someone@somewhere.org

The script will put in a 30 seconds delay to allow the Pi to pickup an address and then mail it for my mail address. Remember to make sure that your Pi is able to send mails, otherwise this will not work.

This will most likely ensure that i will get a mail with the IP address of my Pi, and I  am ready to login with SSH.

 

Playing with LXD containers

Lately I have been playing around with LXD containers, and its actually pretty cool.

Lets create a new container:

lxc-create -t download -n TestCont

This will download the default Ubuntu image from the official repository and create a container named TestCont.

Fire it up with “lxc-start -n TestCont”, connect to it with “lxc-attach -n TestCont”. Now you are in the shell of your new container.

Install dnsmasq, configure it for DHCP and DNS and assign IP’s to your containers based on Name or MAC address. The entry in the dnsmasq conf file should look something like this:

dhcp-host=TestCont,10.0.0.205

Lets create 10 new containers, have them set to autostart, fire them up, and watch the process go along:

for i in `seq 1 10`; do lxc-copy -n TestCont -N TestCont$i;echo “lxc.start.auto = 1” | tee -a .local/share/lxc/TestCont$i/config;lxc-start -n TestCont$i; done; watch -n 5 lxc-ls -f

Maybe we can also configure the dnsmasq at the same time:

for i in `seq 1 10`; do echo “dhcp-host=Cont$i,10.0.0.$i” | tee -a /etc/dnsmasq.d/static-hosts.conf;lxc-copy -n TestCont -N TestCont$i;echo “lxc.start.auto = 1” | tee -a .local/share/lxc/TestCont$i/config;lxc-start -n TestCont$i; done; watch -n 5 lxc-ls -f

As you can see my dnsmasq conf file is called static-hosts.conf. Now i got 10 new containers with fixed IP addresses in 5 minutes – thats cool 🙂

Before copying the original container I have some tips on what to install in it:

sshd
vim
bash-completion

You could do it like this:

lxc-execute -n TextCont apt install ssh vim bash-completion -y

Now you got a nice base image with ssh for remote access, vim for file editing and bash completion. This image will have a ~420 MB footprint.
Another option is to put your public SSH key in the base image, now where getting somewhere 🙂

 

 

Kill unresponsive VM from ESXi cli

Sometimes a VM can go in an unresponsive mode and you cannot shut it down or reboot it from the vSphere client. When this happens we need to be more persuasive in telling the VM to shut down. Log in to the ESXi server with SSH, find the World ID for the unresponsive VM and kill the process, this is done like this:

esxcli vm process list

This will list all the running VMs on the server, use grep -A2 to filter the VM name and the world ID, like this:

esxcli vm process list |  grep -A2 “VM Name”

Kill the process with this command:

esxcli vm process kill -t=soft -w=”WORLD_ID”

This will kill the process in a “soft” way, use -t=hard to be even more persuasive and as a last resort attempt you can use -t=force. If none of the three shuts down the VM, a reboot of the host is required.
To automate things a bit i assembled this one-liner for easy use:

esxcli vm process kill -t=soft -w=`esxcli vm process list | grep -A2 “VM Name” | grep World | awk ‘{print $3}’`

This will softly shut down the VM with “VM Name”

Re-Volt, Wine, Multiplayer

My kids are beginning to play on their computers, and when one of them where invited to a socalled LAN-Party it woke up memories in my mind. I remembered how I used to play at LAN parties my self, and I remembered how simple it was to set up a game and play against each others. Todays gaming is all about joining public servers, creating accounts, and answering questions about this and that.

That made me think back on one of my favourite games from around 2000, Re-Volt. I searched the web and found that Re-Volt isn’t dead at all, fan communities are still alive, and theres even a small patch for the latest version that will support modern wide screens, easier multiplayer, etc. Check it out here: http://www.revoltrace.net/ where you will also be able to download the latest version and patch.

The kids are running Windows 7 and Windows 10 and we had no issues installing it, the installer will ask for the directplay module and download it when needed. In order to play multiplayer we had to allow some firewall ports to be used even though the firewall is disabled on the local network. When hosting a game I noticed that it’s using my public IP and not my private, thats probably why I had to allow additional ports to be used – 🙁

Now, lets get back to the actual point for my post. I am running Ubuntu Linux 14.04 on my laptop, and I thought I would be able to play Re-Volt using Wine. No problem at all, it installed just fine and worked like a charm, until I wanted to play multiplayer over the LAN. I got different erros depending if I wanted to host or join a game, but quickly I found out that on Linux I also needed the so-called directplay module, which is easily installed with winetricks that comes with the Wine installation on my system. After some googling I found out that all I needed to do was:

winetricks directplay

This command will install the directplay module and now the game is running smoothly with or without multiplayer. Wine documentation states to run “sh winetricks directplay” which will not work for the package-manager installed version.

Using Vim as editor in PowerShell

If you are used to using Vim or Vi as your editor, you might miss it when using powershell. Good news is, theres a way to get it. Download and install Vim for windows, create a profile.ps1 file in this path: (for me at least) c:\users\%username%\documents\WindowsPowerShell\ and type in the following:

$VIMPATH    = “C:\Program Files (x86)\Vim\vim74\vim.exe”

Set-Alias vi   $VIMPATH
Set-Alias vim  $VIMPATH

# for editing your PowerShell profile
Function Edit-Profile
{
vim $profile
}

# for editing your Vim settings
Function Edit-Vimrc
{
vim $home\_vimrc
}

Remember to change the $VIMPATH to your installation.

Now you have a fully functional vim from powershell.

/Kasper