Categories
Uncategorized

Gnome GUI “Authentication Required” Administrator password

When getting a popup message to Authenticate as “administrator” in gnome it most likely means the user you are using does not have the correct groups associated to them.

Some of the messages you see were “Authentication required to refresh system repositories”

When rebooting or relogging in, it will now show your username to authenticate instead of “administrator”

Add the user to the adm and sudo group.

sudo usermod -a -G adm <username>

sudo usermod -a -G sudo <username>

Not exactly related – but similar issue:

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/352

Categories
Uncategorized

Compacting Linux VHDX with Hyper-V

I wasn’t able to reduce the file size of my Linux disks on Hyper-V through the build in compact function of Hyper-V

In order to compact your disk run the following command on the Linux install

sudo fstrim -v

Shutdown your Linux install

Compact your disk

Credit: https://helgeklein.com/blog/2016/11/faster-trimming-compacting-hyper-v-ubuntu-vms/

Categories
Uncategorized

Default page to serve Apache2 and Debian9

sudo nano /etc/apache2/mods-enabled/dir.conf

Add file name that it can access only with directory’s name, or change the order

DirectoryIndex index.html index.htm
Categories
Uncategorized

Install Ubuntu 18.4, Apache2, PHP 7.3 and Percona 5.7

Update system repositories

sudo apt update

Install Apache 2

Install Apache 2 with the apt command

sudo apt install apache2

Allow Apache on UFW and verify its status

sudo ufw allow 'Apache'

Install PHP 7.3

Update system repositories

sudo apt update
sudo apt upgrade

Add PPA for PHP 7.3

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

Install PHP 7.3 for Apache

sudo apt install php7.3

Install PHP 7.3 Extensions

Install extensions through:

sudo apt install php7.3-extension_name

sudo apt install php7.3-common php7.3-mysql php7.3-xml php7.3-xmlrpc php7.3-curl php7.3-gd php7.3-imagick php7.3-cli php7.3-dev php7.3-imap php7.3-mbstring php7.3-opcache php7.3-soap php7.3-zip php7.3-intl

Adjust php.ini file

sudo nano /etc/php/7.3/apache2/php.ini

upload_max_filesize = 100M
post_max_size = 48M
memory_limit = 512M
max_execution_time = 600
max_input_vars = 3000
max_input_time = 1000

Restart Apache2 and PHP services

sudo systemctl restart apache2.service

Test PHP7.3 and Apache2 install

sudo nano /var/www/html/phpinfo.php

Add the following line and save

<?php phpinfo( ); ?>

Load web browser with localhost/phpinfo.php

The following is ONLY for dev environment

Add current user to group that owns /var/www/html folder

sudo usermod -a -G GROUPNAME USERNAME

Reboot system

Change group permissions to rwx

sudo chmod -R g+rwx /var/ww/html

Install Persona 5.7

Source: https://www.percona.com/doc/percona-server/5.7/installation/apt_repo.html

Update max_allowed_packet in mysqld.cnf to 32M to prevent Mysql went away message when doing large imports like: “ERROR 2006 (HY000) at line XXXX: MySQL server has gone away”

sudo nano /etc/mysql/percona-server.conf.d/mysqld.cnf

[mysqld]
max_allowed_packet=32M

sudo service mysql restart

Install PHPMyAdmin

sudo apt update && sudo apt install phpmyadmin

For WordPress installation /

Enable mod_rewrite

sudo a2enmod rewrite

sudo systemctl restart apache2

By default, Apache prohibits using an .htacess file to apply rewrite rules.

sudo nano /etc/apache2/sites-available/000-default.conf

Add the following code between <VirtualHost *:80>

<Directory /var/www/html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>

sudo systemctl restart apache2

Create a .htaccess file in the web root folder

sudo nano /var/www/html/.htaccess

Add default WordPress .htaccess file contents:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Source: https://vitux.com/how-to-install-and-configure-apache-web-server-on-ubuntu/

Source: https://www.cloudbooklet.com/how-to-install-php-7-3-on-ubuntu-18-04/

Source: https://websiteforstudents.com/install-php-7-3-php-7-3-fpm-with-apache2-nginx-on-ubuntu-16-04-18-04-18-10/

Categories
Uncategorized

Setup Remote Desktop XRDP on Debian 9

Install XRDP

sudo apt install xrdp

Configuring the firewall

sudo ufw allow 3389

Modify the Xwrapper.config file when you get a blank screen when removing in.

sudo nano /etc/X11/Xwrapper.config

Change:

allowed_users = console

to

allowed_users = anybody

Restart XRDP.

sudo systemctl restart xrdp

Actually, reboot the entire server

When logging in and you receive the message: Authentication Required – Authentication is required to create a color managed device click cancel and it’s all working.

In case you get a blue screen after login I found the following code works to fix this when you use Gnome as your desktop

$echo gnome-session > ~/.xsession
$chmod +x ~/.xsession
Categories
Uncategorized

PowerShell – Running scripts is disabled on this system.

There are four different execution policies in PowerShell

  • Restricted – No scripts can be run.
  • AllSigned – Only scripts signed by a trusted publisher can be run.
  • RemoteSigned – Downloaded scripts must be signed by a trusted publisher.
  • Unrestricted – All Windows PowerShell scripts can be run.

You can change the PowerShell execution policies with Set-ExecutionPolicy like

Set-ExecutionPolicy Unrestricted

You can get the current policy in PowerShell

get-executionpolicy

Categories
Uncategorized

Windows PowerShell Remove previous Hyper-V backup folders older than….

This is based on code from Mike Galvin. When you copy the dirs to a network drive or so, this allows you to delete older backups.

Create a file called “Remove-old-Backups.ps1” and enter the following code:

##Remove previous backup folders older than the configured number of days.
$Backup = "\\NETWORKDRIVE\FOLDER\"
$History = 4
## Location of the VM names file
$VmList = "c:\scripts\vms.txt"
##If a VM list file is configured, get the content of the file.
If ($VmList)
{
$Vms = Get-Content $VmList
echo $Vms
}
ForEach ($Vm in $Vms)
{
Get-ChildItem -Path $Backup -Filter "$Vm
-*-*-*-*-*-*" -Directory | Where-Object CreationTime –lt (Get-Date).AddDays(-$History) | Remove-Item -Recurse -Force
echo $Backup
}

Source: https://gal.vin/2017/09/18/vm-backup-for-hyper-v/

Categories
Uncategorized

Windows PowerShell copy local directory to network drive where items created TODAY

The following script will copy a local directory with items created TODAY to a network share.

Copy and paste below code to a file ending with .ps1 and run from Powershell as Admin

$path = "C:\LOCALPATHTOFOLDER\"
$Destination = "\\NETWORKSHARE\FOLDER"
Get-ChildItem -Path $path | Where-Object {$_.CreationTime.Date -eq (Get-Date).Date} | Copy-Item -Destination $Destination -Recurse -Force
Write-Host "I've just copied the file to $Destination"

Categories
Uncategorized

Importing Hyper-V backup

From the right pane in Hyper-V Manager Console, select the ‘Import Virtual Machine’ option.

Browse to the folder of your backed up VM and ‘Select Folder’

Choose the type of import to perform.

Complete the import

I’ve been noticing that in some cases when you added a new virtual switch manager other than the default ones in Hyper-V, the VM would fail to start with “Hyper-V Manager: failed to change state.”.

My workaround was doing another import but during the connection selection, selecting a connection for each VM.

Categories
Uncategorized

Creating Hyper-V backups in Windows 10

Download and run the script from Mike Galvin.

Create folder c:\scripts

Create folder c:\scripts\logs

Create folder c:\scripts\vms

Save code from: https://github.com/Digressive/HyperV-Backup-Utility/blob/master/Hyper-V-Backup.ps1 to file Hyper-V-Backup.ps1 in the folder c:\scripts

Create a text file called c:\scripts\vms.txt and on a separate line list each Hyper-V VM name you would like to backup.

Right click on powershell and run as administrator

Run: C:\scripts\Hyper-V-Backup.ps1 -BackupTo C:\scripts\vms C:\scripts\vms.txt -Keep 4 -L C:\scripts\logs

More options available such as compress and email.

Source: https://gal.vin/2017/09/18/vm-backup-for-hyper-v/

Schedule the task with Task scheduler

Open task scheduler by typing in taskschd.msc

Action > Create Task

Enter in a name like “Backup VMs”

Select “Run whether user is logged on or not”

Configure for: “Windows 10”

Tab Triggers

Daily, select start date / time

Stop task if it runs longer than: 4 hours (or whatever works for you)

Tab Actions

Enter “powershell” in program / script

Enter for “Add arguments (optional):” C:\scripts\Hyper-V-Backup.ps1 -BackupTo C:\scripts\vms C:\scripts\vms.txt -Keep 4 -L C:\scripts\logs

Tab Settings

Check the following:

“Allow task to be run on demand”
“Run task as soon as possible after a scheduled start is missed”
“Stop the task if it runs longer than: 4 hours (or whatever works for you)
“If the running task does not end when requested, force it to stop”