An Experiment in Randomness

You can print a random number between 1-10 with the following command.

echo $((( RANDOM % 10 )+1))

Creating random numbers

If you change it so the output is between 0-9 you get decently even results.

cat /dev/null > random.txt && cat /dev/null > random2.txt && for ((i=0; i<=9999;i++)); do echo $((( RANDOM % 10 ))) >> random.txt ; done && for ((i=0; i<=9;i++)); do echo $(grep -c $i random.txt) $i; done  |  sort -n

Note that you can change the command to be between 1-10, but all the 1’s in 10 will get grepped and counted as 1’s.

The above command should return something similar to the following. Sorted by lowest occurrences first.

943 5
945 8
985 7
996 2
997 6
1005 3
1012 9
1016 4
1033 0
1068 1
admin@localhost:~$

We can plot them in LibreOffice Calc.

Plot with GnuPlot

Gnuplot is another utility that you can use to plot numbers. Example is below.

cat /dev/null > random.txt && cat /dev/null > random2.txt && for ((i=0; i<=9999;i++)); do echo $((( RANDOM % 10 ))) >> random.txt ; done && for ((i=0; i<=9;i++)); do echo $i $(grep -c $i random.txt) ; done  |  sort -n | gnuplot -p -e 'plot "/dev/stdin"'

Create LUKS Encrypted Thumb Drive

Find the thumb drive with lsblk, dmesg, or sudo fdisk -l. In the following examples we are using /dev/sdc1, replace as needed.

sudo cryptsetup --verbose --verify-passphrase luksFormat /dev/sdc1
sudo cryptsetup luksOpen /dev/sdc1 encrypted_usb
sudo mkfs.ext4 /dev/mapper/encrypted_usb

Now we can mount the drive. We are mounting it to /mnt change if needed.

sudo mount /dev/mapper/encrypted_usb /mnt

Or go ahead and close the channel and remove the drive

sudo cryptsetup luksClose /dev/mapper/encrypted_usb

Command Explanation

sudo cryptsetup --verbose --verify-passphrase luksFormat /dev/sdc1

Wipe /dev/sdc1 and set the password when prompted for it.

sudo cryptsetup luksOpen /dev/sdc1 encrypted_usb

Open up a secure channel to the drive, and decrypt it so we can access it

sudo mkfs.ext4 /dev/mapper/encrypted_usb

Using the channel we created in the previous command, we can now format the drive.

sudo cryptsetup luksClose /dev/mapper/encrypted_usb

We can now close the channel for the drive and remove it.

Bash array example

#!/bin/bash
array=(one two three)
echo "Printing first object in array."  #Replace 0 with the place number of the array item
echo ${array[0]}

echo ""

echo "Whole array"
echo ${array[*]} 

echo "" 

echo "Array indexes" 
echo ${!array[*]}

Output

Printing first object in array. 
one

Whole array
one two three

Array indexes
0 1 2

https://www.linuxjournal.com/content/bash-arrays

Failed to acquire the VirtualBox COM object.

It appears that the issue could be a corrupt VirtualBox.xml file. The one I had did not have anything in it. Removing or moving the file let it create a new one and let VirtualBox actually start.

mv ~/.config/VirtualBox/VirtualBox.xml{,old}

Only problem is that none of the VM’s showed up. Was able to go to the ~/VirtualBox folder in a file browser and launch the vbox file to start the VM

Where is the Trash in KDE?

Where are the trash files stored?

The file location for the trash is in the following directory

~/.local/share/Trash/

Inside there are two folders. info and files.
info – Keeps track of what was deleted and where it was
files – Contains the actual files

Delete the files in the Trash

  • First delete the file in the “info” directory
  • Then go delete the files in the “files” directory

To delete the files, select the files then press “Shift + Del”
or right click, hold Shift down and select Delete.

Bash random sleep timer

Change the 10 to however many seconds you need or want.

echo $(( ( RANDOM % 10 ) +1 ))

Example output

bob@localhost:~$ echo $(( ( RANDOM % 10 ) +1 ))
10
bob@localhost:~$ echo $(( ( RANDOM % 10 ) +1 ))
2
bob@localhost:~$ echo $(( ( RANDOM % 10 ) +1 ))
9
bob@localhost:~$ 

Sleep timer

sleep $(( ( RANDOM % 10 ) +1 ))

kubuntu-desktop : Depends: software-properties-kde but it is not going to be installed

Try installing software-properties-kde and get

The following packages have unmet dependencies:
  software-properties-kde : Depends: python3-software-properties (= 0.96.24.32.11) but 1.8.8 is to be installed
 E: Unable to correct problems, you have held broken packages.

Try to install python3 from the bionic from bionic-updates

sudo apt install -t bionic-updates python3-software-properties

Install software-properties-kde

sudo apt install software-properties-kde

If it fails try force installing it

sudo dpkg -i --force-overwrite /var/cache/apt/archives/software-properties-kde_0.96.24.32.11_all.deb

Install Kubuntu desktop

sudo apt install kubuntu-desktop

More info here
https://pravin517.wordpress.com/2019/07/14/kubuntu-desktop-depends-software-properties-kde-but-it-is-not-going-to-be-installed/