Category Archives: Linux

How To shrink Journal Log files

Sometimes Journal Log files can take up a lot of diskspace. Here is how to make a fast cleanup

Delete logfiles and shrink until 500 MB in total size

journalctl --vacuum-size=500M

You will get an result that look like this

This freed up a lot of diskspace, but it may not have giving you as much free space as you think, if your value that you wan’t to shrink to is to low then the command will adjust to the lowest possible value

Get the size of the Journal Logs

Now here is how to see the current Journal disk usage

journalctl --disk-usage

SSH config files – Windows DOS or Powershell prompt

A local configuration files for ssh where you have all the “shortcuts” you need to contact another computer with openssh server installed. In my example it’s Linux and Windows Servers that I need to manage.

A shortcut could be

ssh node1

to manage node1.pvangsgaard.com

Here is How To setup SSH and config file

You can use powershell prompt or DOS promt, but i will recommend using Hyper Terminal, you can download and install it from https://hyper.is/

if you haven’t used SSH before then generate a key-pair with

ssh-keygen

It will look like this

ssh-keygen on windows (Hyper Terminal)

Now the ssh-keygen have made a directory containing a ssh-keypair

The directory is in your path and in my case C:\Users\peter\.ssh\

ssh key and config directory in windows path

go to the .ssh directory and list content with

cd .ssh
dir
ssh directory content

now start notepad or any editor and write a config for a server, in this example it’s node1.pvangsgaard.com

Host node1
     HostName node1.pvangsgaard.com
     User root
     Port 22
     IdentityFile c:\users\peter\.ssh\id_rsa
ssh config file

If you have another RSA key that is provided by your company then just alter id_rsa filename to the one that you need also remember to change path and servername 😉

Now save the config file in your ssh dir like C:\Users\peter\.ssh\

save config file

It’s very important that the file is named config and NOT config.txt 😉

Now tryout the new config by connecting

ssh node1

Note that is is only working in DOS or Powershell, if you need it in a Linux container in Windows then you have to alter the path and then it will work.

If you use Hyper there is a little bug when exiting the terminal, you need to close all connections and type exit in the last one to close the app.

How to copy .img files to floppy with DD

If you are into retro computing and need to copy one of the old floppy .img disks to a diskette then it can be done with dd for unix/linux or by using the windows port of dd

My son learning to code Power Basic for DOS and switching floppies 😉

In my case i had 2 computeres with a floppy drive, one was a Windows XP machine and the other was a much older DOS computer without USB or network and i need to test FreeDOS and MS DOS 6.2 but i only had files like disk1.img downloaded from the internet and blank 1.44 floppy disks.

In my first attempt i tried to use a Windows program called winimage but it was not able to run on the old Windows XP, maybe it needed a servicepack or somthing else, so the fastest way was to find a simpler and faster solution and dd came in to my rescue.

here is How to copy a disk.img to floppy with dd

Unix/Linux

dd if=disk1.img of=/dev/fd0

Windows (DOS or CMD Console)

dd if=disk1.img of=\\?\Device\Floppy0

It can be downloaded at http://www.chrysocome.net/download

OR from my server https://www.pvangsgaard.com/download/dd-windows/

How to get an SSL A+ rating with Apache

If you need a high rating with tests like https://www.ssllabs.com then i have an example on a working configuration that will get you the A+ score.

I’m using letsencrypt for my SSL site but you can use any certificate to get the result.

<VirtualHost *:80>
ServerName www.pvangsgaard.com
ServerAlias pvangsgaard.com
Redirect / https://www.pvangsgaard.com/
ErrorLog /var/log/apache2/pvangsgaard.com.error.log
CustomLog /var/log/apache2/pvangsgaard.com.access.log combined
</VirtualHost>
<VirtualHost *:443>
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"
ServerName www.pvangsgaard.com
ServerAlias pvangsgaard.com
DocumentRoot /home/pva/public_html/pvangsgaard.com
ErrorLog /var/log/apache2/pvangsgaard.com.error.log
SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLEngine on
SSLCipherSuite EECDH+AES:EDH+AES:-SHA1:EECDH+RC4:EDH+RC4:RC4-SHA:EECDH+AES256:EDH+AES256:AES256-SHA:!aNULL:!eNULL:!EXP:!LOW:!MD5
SSLHonorCipherOrder on
SSLCertificateFile    /etc/letsencrypt/live/pvangsgaard.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/pvangsgaard.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/pvangsgaard.com/fullchain.pem
</VirtualHost>

Remember to enable headers with:

a2enmod headers
systemctl restart apache

I have also made an example for NGINX at this url https://www.pvangsgaard.com/2018/02/22/how-to-get-an-a-rating-with-100-score-on-the-ssllabs-test-with-nginx/