Author Archives: peter

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.

Apache – prevent SQLite DB from download

If you are using SQLite for your website as backend database then it is important to prevent others from downloading the entire database, since SQLite is a file then it can be solved by denying access to the file from the web by this .htaccess rule

RewriteEngine On
RewriteCond %{REQUEST_URI} (.*).db [NC]
RewriteRule ^(.*)$ 404.html [R=404,L]

The rule will prevent access to all files with .db in the name, that will prevent download of files like blog.db mydatabase.db etc.

In my example it will redirect to a 404.html page

Your php script is running inside the server and will still have access to your database files as long as it has the correct unix fileaccess

How to change 15pin to 14pin VGA

If you have an old IBM PC with VGA and it’s only 1 pin where the normal is 15pin then don’t panic, it’s possible to change that by removing one pin and then it can connect to 15 pin monitor, you just need to remove it in one end and you have a 14pin to 15pin adapter cable 😉

Here is my modified 15 pin cable, just changed it in one end and it worked wih my 15 pin LCD monitor

Seems like one of the purposes for the one pin is that newer vga monitor can report it’s resolution back to the computer so you need to set that manually.

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/