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/

Setup DHCP server on Linux

Install dhcp server software

sudo apt install isc-dhcp-server

Edit the following config file and set the networking interface it should use. In this case enp60s0

sudo vi /etc/default/isc-dhcp-server

Example line to change

INTERFACESv4="enp60s0"

Now edit the dhcpd.con file

sudo vi /etc/dhcp/dhcpd.conf 

Add the following in. Change the addresses and settings as needed.

subnet 192.168.47.0 netmask 255.255.255.0 {
   range 192.168.47.26 192.168.47.30;
   option domain-name-servers ns1.internal.example.org;
   option domain-name "internal.example.org";
   option subnet-mask 255.255.255.0;
   option routers 192.168.47.1;
   option broadcast-address 192.168.47.255;
   default-lease-time 600;
   max-lease-time 7200;
 }

Set a static ip on the computer that’ll be acting as the dhcp server. You can set it as the gateway if it is the gateway.

Allow dhcp through the firewall

sudo ufw allow  67/udp
sudo ufw reload
Restart the service and connect a client.

sudo systemctl restart isc-dhcp-server

More info.

You can look at dhcp leases with the following command

tail -f /var/lib/dhcp/dhcpd.leases

Run iperf speed test on Linux

Install iperf

sudo yum install iperf3

Launch server with

iperf3 -s 

If you want you can have it bind on a certain interface which can be useful in some causes if you have multiple IP addresses on the system. The IP address is the local address of the machine.

iperf3 -s -B 192.168.1.1

Note you may need to disable the firewall to allow access from the client

sudo systemctl stop firewalls

From the client computer install iperf and run it.

iperf3 -c 192.168.1.1

Clonezilla – Clone Windows 10 from single SSD to New Raid 0 SSD Volume

Boot up and create your raid array

Boot into Clonezilla and get to command line :cry: unfortunately you can’t clone from disk to raid in clonezilla interface, however we can do it from the command Line!

Basic steps are as follows. Replace raidarray with the name of your raid array.

  • Initialize raid array with dmraid -ay or kpartx -a /dev/mapper/raidarray
  • use gdisk to backup structure of source drive
  • Write gdisk backup to raid array
  • use ntfsclone to clone to raid array
  • ntfsclon –overwrite /dev/mapper/raidarray /dev/sdSOURCEDRIVE

Install NextCloud on Ubuntu 19.04

Install with snap

sudo snap install nextcloud 

Set user and password for NextCloud

sudo nextcloud.manual-install nextcloudadmin password

Allow https access for firewall

sudo ufw allow 80,443/tcp

For the following steps to work, you’ll need an A record setup on your domain name server to point a domain to your Next Cloud servers public ip address. Change www.example.com in the following steps to the domain name you’ve setup.

View trusted domains

sudo nextcloud.occ config:system:get trusted_domains

Setup new trusted domain. Change www.example.com with your domain.

sudo nextcloud.occ config:system:set trusted_domains 1 --value=www.example.com

Run through Lets Encrypt to setup a SSL certificate.

sudo nextcloud.enable-https lets-encrypt

Should be able to access NextCloud from a web browser www.example.com

Extra info
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-nextcloud-on-ubuntu-18-04

How To Reset root Password on CentOS VM – XenServer

Basic steps are as follows.

  1. Shutdown VM
  2. From XenCenter, insert the CentOS iso into the VM’s Virtual DVD drive.
  3. Boot the CentOS VM in recovery mode.  If you need help with that check this post out.
  4. On the grub menu, select recover OS Installation.
  5. Run through the recovery and mount the VM’s disk where CentOS is installed
  6. You should now be able to drop to a prompt and chroot /sysimage
  7. Change the root password with passwd
  8. Shutdown the VM
  9. Eject the CentOS iso
  10. Boot up the VM and login with the new password

Set static ip address in Ubuntu 19.04

The network configuration settings for the server edition of Ubuntu are now stored in the following location. Create the file if it does not exist.

sudo vi /etc/netplan/01-network-manager-all.yaml

Add or edit the config file to the following. Change eno1 to your interface name and the address and gateway to the appropriate IP’s

For more information, see netplan(5).
 network:
   version: 2
   renderer: networkd
   ethernets:
     eno1:
      dhcp4: no
      addresses: [192.168.200.24/24]
      gateway: 192.168.200.1
      nameservers:
        addresses: [8.8.8.8,8.8.4.4]

Now apply the changes with the following command.

sudo netplan apply