speed up journalctl

Sometime back I noticed that whenever I run my favourite command, viz.

journalctl -xn -f -l

it was taking more time than usual. So, I thought to dig more into it and finally found that the following command:

sudo journalctl --disk-usage

showed that journalctl was using some huge space in tune of about 4GB. So, the solution was simple, vaccum the journal entries and the command to do so is :

sudo journalctl --vacuum-size 90M

Checking journalctl size after that confirms the size is reduced and after that indeed the above journal command takes no time 🙂

Most simple and fast lightweight container with Fedora systemd

If you need to have a quick bash shell in sandbox with not network as well, then the most simple command I could find so far is:

sudo virt-sandbox -c lxc:/// /bin/bash

For this you will need to have libvirt-sandbox installed which you can do with the following command:

sudo yum install libvirt-sandbox

ssh – remove offending key.

Whenever a system/server is re-installed or the host key changed for any reason, you would have seen the “host key verification failed”. And as usual you would have to go to known_hosts file and delete the offending key. I will show you 2 simple ways to do this here.

The output that you get in such scenario is:

Offending ECDSA key in ~/.ssh/known_hosts:4

First, you can use sed to directly delete the offending key with a command like this :

sed -i 4d ~/.ssh/known_hosts

So, if you see, we are using “-i” to do the changes inline and using “4d” command to delete the 4th line.

But being on Linux has the advantage that everything can be automated. So, lets do this in simpler way.

We will be using command called xclip for this, so get that intalled.

sudo dnf install xclip

Once that is done, add a alias in your bashrc file like this:

alias ssh-remove-key='a=( $(xclip -o|sed "s,:, ,") ) ; sed -i -e "${a[1]}d" ${a[0]}'

After this is done, whenever you get that error, copy the “<file>:line” portion and execute “ssh-remove-key” and the key is gone from file 🙂