Friday, August 05, 2022

changes after upgrading to Moodle 4

Copy-pasting edited extracts from an email exchange after upgrading a test server to Moodle 4 - 


... the orange band appears with company logo. Need to check how to remove orange band or replace the logo with SSSVV.

 
Also the footer information is not displayed like in the present case.

The easy way to remove it is to add the following to the Advanced tab in Moove settings,  Raw SCSS - 
footer#page-footer .copyright  {display:none;}
which I have done now. 
 
a) In the footer when you click on the mailbox it goes to MS edge account and not to the given mail id.

The footer link for contact us is a mailto: link. This will work properly if your browser is configured properly to handle mailto: links.
If you find that clicking that link takes you to your microsoft account, you might be using microsoft edge browser? In that case,
 
b) Phone when clicked goes to a number which has this number added before the number given "662453:"

Just like the contact us email link is a mailto: link, the telephone link is a tel: link, which again needs to be configured correctly in your browser for it to work.
The incorrect behaviour is also because the tel: link is not configured properly. Only the number should be entered, and not text like "Mobile:".
 
c) Although I have a Web whatsapp installed on my laptop it says the link is wrong. On mobile it works.

One workaround would be to enter the whatsapp phone number as
00919876543210 - without spaces and without the + symbol, using 0091 instead of +91 - then I think it works.
 
d) When one clicks on Google Play icon for mobile app. the user cannot return to the front page but goes to the site home page. To return to the front page he has to login and logout.

I think this is related to what we have discussed earlier, Moodle shows a different page when one is logged in as compared to when logged out. Also, user is automatically logged in to guest login if any of the internal links which have guest access are clicked.
 
e) Is it possible to remove the App. Store link or the version 4 of moodle supports mobile app. on IOS devices.

Yes, we can remove if necessary using custom CSS. We probably need to link to the India site, like

(the US site https://apps.apple.com/us/app/moodle/id633359593 does not seem to load for users in India)


7) I have added sample videos in some blocks to check. However if you open a video for viewing one cannot return to the front page but lands on the site home page. (Front page means non logged in page). One has to log in and log out to land again on the front page.

Please see how the marketing block looks like on the production site. I don't think there is any change in functionality 
 Whenever I log into the site I get a mail saying new sign in. May be a version 4.0 addition. Can it be disabled or it will remain as default.

You can probably change this behaviour from
 
 


Thursday, August 04, 2022

Linux ls - listing files sorted by date

Since some email notifications had not arrived, I did not have a ready reference to know which were the latest auto-encoded files. PB suggested looking in the server directory - and I could sort by date and go pagewise to get what I needed, 
ls -lt | more

Wednesday, August 03, 2022

problems with mysql server on Windows Server 2016 and workaround

The latest MySQL community editions - 8.0.22, 8.030 etc - which use installer version 1.6 - don't install properly on Windows Server 2016. They install fine on Windows 11. 

The error seen in the Log tab of the installer is,
Option --authentication-policy was set to an invalid value
(and I suspect when that is corrected, another error comes up.)

By trial and error, found a workaround, which was to install a version which was working fine on Windows Server 2016 - this post uses 8.0.19, so that was working. After the installation, after verifying that the server is running, we can allow the installer to update, and then after the installer updates itself, we can update the server to 8.0.30 without issues. The upgrade does some config file changes, I think. 
 
Some notes:
  1. When reinstalling, we must delete both C:\Program Files\Mysql directory as well as C:\ProgramData\Mysql  before reinstalling if we want a fresh install with a fresh root password.


  2. Found
    c:\programdata\mysql\mysql server 8.0\my.ini
    which had
    authentication_policy=0.0
    According to https://dev.mysql.com/doc/refman/8.0/en/multifactor-authentication.html the valid default should be
    '*,,'
    but in our installation, it is set to 0.0

  3. Tried commenting it out, then tried running from command line as mentioned in the ini file, (but correcting the path),
    mysqld --defaults-file="c:\programdata\mysql\mysql server 8.0\my.ini"
    That  seemed to start, then immediately stop the server. So, no improvement. Probably there were other things wrong for Win Server 2016... 

Saturday, July 30, 2022

Windows password - never expire

Windows passwords expire by default in 6 months. To prevent this, https://www.itechtics.com/set-windows-local-user-account-passwords-to-never-expire/

lusrmgr.msc --> Right-click relevant user --> Properties --> General tab --> (check) Password never expires

Saturday, July 23, 2022

uptime equivalent on Windows

To find out how long a Windows machine has been on, the equivalent of uptime on Linux - https://devblogs.microsoft.com/scripting/powertip-get-the-last-boot-time-with-powershell/

Get-CimInstance -ClassName win32_operatingsystem | select csname, lastbootuptime

Using this in a "Basic Task" with Task Scheduler did not work when not logged on. So, instead of creating a basic task, used "create task" and chose "run whether user is logged in or not." Also enabled run with highest privileges.

Friday, July 22, 2022

converting ppk to pem on Linux

I had some PuTTY private key in .ppk format which I wanted to use on a Linux machine. One way would have been to install putty on Linux. Another way was to convert the ppk to pem format, and then use the standard OpenSSH ssh command. 

The version of puttygen available via the ubuntu repos seemed to be too old - so, downloaded and installed via https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html as per

So, 

tar -xvf putty*.tar.gz
cd putty[version]
# from the README
cmake .
cmake --build .
sudo cp puttygen /usr/bin/

and then 
puttygen server.ppk -O private-openssh -o server.pem

Wednesday, July 20, 2022

restarting IIS from cmd prompt

Since we have some Windows servers to which we ssh, restarting IIS from the command prompt is useful - we don't have to start an RDP session etc etc. 

Just run
iisreset

Apparently iisreset is better than net start / stop etc, since it will also reset other related services like FTP, SNMP etc. 

scheduled reboot of Windows server

I was exploring various options for issues with one of our Windows servers. Running out of RAM etc. For Windows machines, rebooting usually solves most problems, so looking for solutions for scheduled reboot - Server Reboot - Microsoft Q&A

 (But it shows run only if my admin account is logged on. Will see how it goes.)

SSH server on Windows 2016 Server - documentation link dump - fix for vi blank page on Windows

A link dump below:

 
This doc above is only for server 2019 - ours is 2016, so must use the github link below.



https://www.tutorialspoint.com/how-to-install-the-msi-file-using-powershell#

administrators_authorized_keys needs to be created.

in  https://github.com/PowerShell/Win32-OpenSSH/wiki/sshd_config

to add path, the above wiki has some pointers.

How to Edit Files with a Real PowerShell Text Editor (adamtheautomator.com)



 
(
choco install nano -y
worked.

For using vim instead
choco install vim 
 
The open command: start a session - PuTTY Documentation
psftp syntax
open username@host port
like open myusername@myservername 22
 
Use puttygen to convert from id-rsa to ppk, using "Load an existing private key" option,



 
vim c:\programdata\ssh\sshd_config

public key can be appended by 
type id_rsa.pub >> c:\programdata\ssh\administrators_authorized_keys

page becomes blank when page down in vim
did not help, but using pagedown instead of down arrow worked.

recommended using 
powershell -command "Restart-Service sshd -Force"

Putty's tunnels saved in session, so we need to use
to save reg file to export if we want to send a Putty configuration to someone else.
 
Unfortunately, this does not work on some machines, since the registry entries like path etc may be different. They would need to manually recreate the tunnels, I guess.
 


 





Tuesday, July 19, 2022

general troubleshooting of server outages

Copy-pasting from an email exchange:

Is the web app also facing issues or is the issue only with not being to log on to the server with remote desktop for admin tasks? If the app is also facing issues, we need to look into that also.

Maybe we can follow a process of elimination, mitigating the most obvious issues first, and then checking for deeper hidden issues.

The most common attacks for web-based apps which display forms to the user are brute force attacks which try to submit the forms automatically with all sorts of junk and try to compromise the server. Our app and the web interface do some user authentication using certain pages/forms, right? Those forms/pages must be hardened as the first step of defense. That is, they should not accept more than x number of characters, and should not accept special characters (other than those which are needed.)


If user input sanitization is taken care, then if still problems persist, next we have to look into the app logs if available and see if particular user behaviour crashes the app. Or whether there is any issue with multiple users logging in etc. We had done a test of this several months ago, but some code changes might have changed things. 
etc. etc. etc.

how to create a Windows 11 boot USB

On Windows, the easiest way to create a bootable Windows installation on a USB drive would be via Rufus. On Linux, the manual way is described at
either woeusb via python or manually with gparted creation of two partitions.

Method 1. sudo apt install git p7zip-full python3-pip python3-wxgtk4.0
sudo pip3 install WoeUSB-ng

Method 2. (a) Using GParted, repartition the USB drive as GPT from the menu - Device - Create Partition Table - GPT
(b) create two partitions - the first one FAT32, 128 MB or so labelled as BOOT (all caps), the next one NTFS with the rest of the space.
(c) mount the Win11 iso, copy over the files to the NTFS partition. 
(d) copy the files from all the folders except the sources folder to the BOOT partition, and the sources folder to the NTFS partition - according to https://www.elevenforum.com/t/create-windows-11-bootable-usb-installation-media.750/
 
(In a Rufus created USB Windows-to-go, only the BOOT and EFI folders as well as the files in the root folder are seen inside the BOOT partition. So, maybe it would be a good idea to copy all the files to both partitions - except the sources folder, which is too big, and can only be copied to the NTFS partition.)  

removing an app which auto starts in Windows

I'd purchased a refurbished laptop from Amazon for A, and the seller rentopc had put a registration app to start whenever Windows logs in the user. Checked if there was anything in the startup folder, no

Then, found it in Start -> Settings -> Apps -> Startup

DKIM with PhpMailer

I generally prefer to send emails via Google Workspace, if necessary using sSMTP, but in case someone needs to use phpmailer and send out emails, phpmailer also makes DKIM signing relatively easy.

https://www.stechies.com/spf-dkim-verify-your-emails-using-phpmailer/

https://github.com/PHPMailer/PHPMailer/blob/master/examples/DKIM_sign.phps

$mail->DKIM_domain = 'ourdomain.com';
$mail->DKIM_private = 'path/to/private.key>';
$mail->DKIM_selector = 'whatever';
$mail->DKIM_passphrase = '';
$mail->DKIM_identity = $mail->From
;


Monday, July 18, 2022

troubleshooting email delivery issues

Copy-pasting from an email exchange:


1. SPF

You have to log on to the DNS control panel at

and change the SPF in the TXT record for thedomain.org from the current value of
v=spf1 include:_spf.google.com ~all
to
v=spf1 ip4:<ip of server sending the emails> include:_spf.google.com ~all

2. DKIM

Then, you can send me a screenshot of the dkim record, and I can tell you what to change it to.
 
Or you can send me an email from the domain's email id, and I can check the DKIM record if it exists etc. from the headers of the email.

Saturday, July 16, 2022

problem with not booting Linux Mint after kernel update

A couple of days ago, when I attempted to shut down Linux Mint 20.3 on the Macbook, there was no shut-down button visible on the usual shut-down dialog box. I thought this was some problem with the latest update, and thought that a restart would fix things. (That was a mistake, as you can see below). But after doing a sudo reboot from a terminal, the system would not boot up - it complained of a kernel panic, no working init found, and suggested trying to remove the init options. After googling some no working init found forum posts etc, thought I might need to check the disk for errors, but 

badblocks /dev/sda3

found no errors. Then I thought I would just try booting with another kernel - pressed F2 (more options) from reFind, booted with an older kernel 5.4.0-121-generic. Booted up with no issues. Tried doing 

sudo apt update
sudo apt upgrade

Then found the real culprit.

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem. $ sudo dpkg --configure -a
Setting up linux-image-5.15.0-41-generic (5.15.0-41.44~20.04.1) ...

Ah - so I was the culprit - Mint was not showing the shutdown button because the update was still in progress - I had somehow interrupted it. Anyway - running dpkg manually with the command above fixed the issue, and the system boots fine now with the 5.15.0-41-generic kernel too.

Friday, July 15, 2022

HTML audio loop attribute

There were some audio streams specifically made for the official app, which were just loopable content. Exploring the possibility of using just a link to the loopable file instead of an icecast stream, the way to implement a looping audio seems to be in code - javascript or html - like the html example below,


In the app, similar code can be executed based on which Java widget they have used.

preventing ssh time-outs

In addition to my earlier ssh keep alive post, some more way to keep ssh from timing out - on the client side, 
and
on the server side, 

On the client side on Linux etc, editing or creating the file $HOME/.ssh/config , giving it appropriate permissions, 

chmod 600 $HOME/.ssh/config

and adding the lines below - 

Host *
    ServerAliveInterval 240

On Putty, Connection -> seconds between keepalives - set it to 100 or something like that if timing out. 

Wednesday, July 13, 2022

web server port forwarding and workaround

There seemed to be some issues like Chrome and Edge (on Windows) not connecting to localhost, as mentioned at https://stackoverflow.com/questions/43889497/chrome-cannot-connect-to-http-localhost8080-but-http-127-0-0-18080-works

So, I just changed the SSH tunnel to port 8080, and used the url like http://127.0.0.1:8080/restOfURL for it to work.


 

Sunday, July 10, 2022

redo Income tax work on a different PC

Since the income tax dept in India has dropped Java (Linux) support for their offline utility and has only Windows/Mac versions, I tried out various methods to do the IT filing. When an 8 GB Win11 machine became available, I thought I would do the filing on that machine, and wanted to know where the data was saved on the old 4 GB Lenovo machine to copy it over. 
The above page talks about "import draft ITR filled in online mode", what I did was to export the json from the old machine and import it on the new machine. Probably I could have uploaded it to the online filing site, and then downloaded the json from there to import into the new machine also. 

interesting post about Legacy to UEFI in-place migration

 https://www.redhat.com/sysadmin/bios-uefi

- says "Move your Linux from legacy BIOS to UEFI in place with minimal downtime"

Thursday, July 07, 2022

Dell Latitude 3410 audio issues

Ac purchased a brand new Dell laptop pre-loaded with Ubuntu, Dell Latitude 3410. After he booted it up and finished the setup with his login, when he tried the headphone jack, it did not work. The sound stopped coming out of the speakers, but no sound from the headphones. 

At first, I wondered if it was a hardware fault. Then found that this is a known problem with these laptops as seen on Dell's help forum -
https://www.dell.com/community/Latitude/Latitude-3410-and-3510-Audio-Jack-Problem/td-p/7659856

Since the above solution, of installing the Dell Optimizer app, is for Windows, googling for help on Linux, found these two posts.


https://askubuntu.com/questions/1291829/no-audio-on-dell-latitude-3410-with-ubuntu-20

https://forums.linuxmint.com/viewtopic.php?t=335242&start=40

This second one worked - the solution was to comment out the line which automatically suspends "sinks/sources that become idle for too long"
in /etc/pulse/default.pa

### Automatically suspend sinks/sources that become idle for too long
#load-module module-suspend-on-idle

And then reboot. After the reboot, manually choosing the audio as headset and manually disabling the speakers output using the pulseaudio sound control app gives us the desired outcome.

Wednesday, July 06, 2022

Income tax filing notes

After the Income Tax department (India) have changed to their new income tax e-filing portal last year, there were some teething troubles, but this year things seem to go smoothly. Or perhaps it is because I have learnt last year's lesson and did the first submission using the offline utility instead of online, since last year the offline utility was more stable than the online software. Or maybe because their documentation, help and faq sections are pretty good. Some notes, in no particular order.

  1. For e-verifying returns using Canara bank, if you don't want to use the ATM method, the way is to choose to e-verify "using bank account details" - that directly sends an SMS with the verification code (EVC) to the linked mobile phone, and we can enter the EVC to e-verify. Probably the easiest way to e-verify would be using the Aadhaar-linked OTP, in case the Aadhaar is linked to a mobile number.
  2. For filling up the csv in the Long Term Capital Gains, which is Schedule 112A in ITR2, there is an explanatory pdf linked from the button labelled "Need help ?" on the top right. NOT the Help menu item right at the top. Reading those instructions would be essential for correctly filling up the csv template. I got the required data from CAMS and KFin profit/loss statements for mutual fund gains and the old as well as new sale deeds for house sale proceeds.
  3. Filling up this 112A does not automatically fill up the quarterly gain/loss in the schedules BYLA etc - we need to fill them manually.
  4. When filling up ITR2, deduction for Interest income up to Rs. 10,000, (section 80TTA) comes under schedule VI-A, where we have to choose to expand "Part C, CA and D".
  5. After paying tax, we have to again go back to "Computation of Taxes" schedule, enter the Challan serial number and other details of the tax we have paid, and again compute till the tax to be paid is zero.
  6. The donations for which I usually get a 100% and 50% exemption without any qualifying limit were not accepted - the verification step failed with the error "same pan cannot be entered for different donation type", it would only accept it if entered as 100% and 50% "subject to qualifying limit", and the limit seems to be 10% of adjusted gross total income.
     


FAQ about uploading an Android app to Google's Play store

These were some questions which I was asked about uploading an app to Google's Play store. I'm also testing out How To Toggle Between Hiding And Showing an Element or How To Create a Hoverable Side Navigation. Since adding CSS using SPAN tags in blogger is a bit clunky, I'm not doing the hoverable style for this post. The links are plain anchor links to div ids.

  1. What software readiness is required?  (This may or may not work.)
  2. Any documentation to be completed?   
  3. We are currently on version 1.3.6 which is distributed as a link on Google drive. The way it works is that if someone has 1.3.5 on their device, 1.3.6 understands that and overwrites 1.3.5 while installing 1.3.6. Now, if we place either 1.3.6 or the later version in Google PlayStore, will it automatically detect the version installed using a Google drive link?
  4. Some releases will be mandatory, and we would like the app to force update (for critical errors) and some releases may not be mandatory. Is this possible?
  5. Can our developer team place it in Google PlayStore or will it be placed by you?
1. What software readiness is required?
For adding an app to the Google Play store, it needs to be signed by the appropriate developer. If you wish the app to be seen under the developer id of our organisation, like
then the app apk has to be built again, using the developer key which we have, for our organisation. This takes between 5 minutes and half an hour, depending on how much RAM the development machine has. Then, the apk has to be uploaded using the ID which we have used for the earlier apps, for which we have the password. I had done it for the LMS app, and had documented it at

If you wish to add the app under a different developer id, then the process, starting with creating a developer id, is mentioned at many places like

2. Any documentation to be completed?
When we upload the app, there are some mandatory requirements. There needs to be a privacy page for the app, we need to provide the content rating (whether it is suitable for children and so on), and we have to choose in which regions of the world our app would be available.
(In the above link, we have already got the developer account etc, as mentioned above.)
After we submit the app, it would go for review by the google team, and would be available once it passes the review, which would take a few hours or a week.

3. We are currently on version 1.3.6 which is distributed as a link on Google drive. The way it works is that if someone has 1.3.5 on their device, 1.3.6 understands that and overwrites 1.3.5 while installing 1.3.6. Now, if we place either 1.3.6 or the later version in Google PlayStore, will it automatically detect the version installed using a Google drive link?
If the new version of the app is built with the same app id as the old version of the app,
(which is a string like org.sssvv.sssvvmobile, which is the app id of our LMS app,
then the old version will be overwritten with the new version. Otherwise not.

4. Some releases will be mandatory, and we would like the app to force update (for critical errors) and some releases may not be mandatory. Is this possible?
This behaviour is not default behaviour, it does not happen automatically. This needs code to be written in the app to periodically check for new versions, and if mandatory upgrade, not allow the user to use it till (s)he upgrades. One way of implementing this is using in-app upgrades, for example

5. Can our development team place it in Google PlayStore or will it be placed by you?
This is up to the management team. If you wish me to give the developer key + developer id password to the development team, I can do that, and they can place it in the Google Play Store. Or if the devel team give me the code, I can build the app and place it in the Google Play Store. In either case, it would be good if the management team provides
(a) Privacy page draft (or if the LMS app privacy page is enough, we would need to change the wording a little bit)
(b) Description for the app which comes in the "About this app" paragraph
(c) Logos and artwork as required. (this may be already available).
You could take a look at the LMS app for ideas,



Saturday, July 02, 2022

iframe contents resizing

We had an iframe with a blogspot blog being displayed on the website. But the iframe content was too wide, there were horizontal scroll-bars on the iframe. Looking for solutions to resize the content, this answer scales it by half, and this answer has support for more browsers. I used the latter, but without the pos. So,

....

<head>

....

<link rel="stylesheet" type="text/css" href="../../css/iframe-for-blog.css" />

....

</head>

and in the iframe-for-blog css file,

iframe {

/* Set the width of the iframe the size you want to transform it FROM */
width: 1108px;
height: 710px;
/* apply the transform */
-webkit-transform:scale(0.75);
-moz-transform:scale(0.75);
-o-transform:scale(0.75);
transform:scale(0.75);
/* position it, as if it was the original size
position: absolute; - we're not using this.
left: -400px;
top: -200px; */
}

 

 

Wednesday, June 29, 2022

regexmatch in google sheets

 https://spreadsheetpoint.com/regexmatch-function-google-sheets/

 Regexmatch() returns TRUE if expression matches, FALSE if it doesn't.

Syntax like
=if(regexmatch(D20,"NANDA"),if(regexmatch(D20,"LIFE"),G20,0),0)

means that the cell value would equal G20 if it matches both conditions, and 0 if it doesn't.

https://support.google.com/docs/answer/3093364?hl=en

IF(logical_expression, value_if_true, value_if_false)



Monday, June 27, 2022

adding applications to cinnamon menu

https://kerneltips.com/add-applications-to-cinnamon-menu-in-linux-mint-20

Right-click --> Configure --> Menu Editor --> New Item 

or

Right-click on Desktop --> Create new launcher here 

(it asks "Would you like to add this launcher to the menu also" and will add to the "Other" category.)

Sunday, June 26, 2022

notes on giving access to ad-hoc queries

Copy-pasting from an email exchange:

As you had asked :
who apart from admin can be given a role which will enable viewing and downloading ad-hoc data base query reports for example non editing teacher.

It is safer to keep the visibility of ad-hoc reports limited, because they are very powerful, and making a mistake can cause catastrophic damage to the database. 

But there is an option to send ad-hoc reports by email. Perhaps the non-admins can be sent the reports by email instead?
 
If we want to send those emails directly to those people, Moodle requires us to give access to the query to them - only then does it allow that user to be emailed the report. Instead, if the report is sent to you by email, and you forward it to the relevant users, would that be OK? 

The relevant queries for each user could be named in such a way that when you get emails from those queries, you could put in a GMail filter to automatically forward those emails to the respective people. 

I have set up a test query at
which will email daily at 3 pm. 


Saturday, June 25, 2022

local file sharing over wifi - Android to PC etc

https://linuxhint.com/wireless_file_sharing_apps_linux_android/

https://snapdrop.net

seemed to be the easiest option, since nothing needs to be installed. But right now it doesn't seem to work. Similarly,

https://www.sharedrop.io/

Maybe it is blocked by the Studio network, and would work at home?

Monday, June 06, 2022

changing DNS server for lookups on a systemd Linux machine using the terminal

GUI-based DNS changes are fine, but there seems to be a lot of conflicting info on changing the DNS server using the command line on Linux. For example, 

For Ubuntu 20.04, https://phoenixnap.com/kb/ubuntu-dns-nameservers needs the yaml file in /etc/netplan to be edited, but on Linux Mint 20.3, that yaml file does not contain anything except 

  # Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager

This post https://forums.linuxmint.com/viewtopic.php?t=321682 talks about installing resolvconf and creating / editing a file  /etc/resolvconf/resolv.conf.d/head which does not exist on Linux Mint 20.3

What does exist is 

/etc/systemd/resolved.conf

(but it has no entries) and also

/etc/resolv.conf

(but it says # This file is managed by man:systemd-resolved(8). Do not edit.
And it does not have the custom name server 8.8.8.8 I have configured via the GUI. )

From https://wiki.archlinux.org/title/Systemd-resolved#Manually I find that the file
/etc/systemd/resolved.conf.d/dns_servers.conf
does not exist - there is no directory called /etc/systemd/resolved.conf.d/

This thread
https://www.digitalocean.com/community/questions/fedora-33-how-to-persist-dns-settings-via-etc-resolv-conf
has some clues about why some methods work, and why some don't - various distros are changing the way in which DNS resolution works, so we would need to look at our specific distribution's docs for correct info.  

Edit: And this thread gives some details about Linux Mint 20.3 - basically saying that we have to use the GUI - https://forums.linuxmint.com/viewtopic.php?t=371120



Wednesday, June 01, 2022

restoring a Windows 11 laptop - Samsung Galaxy Book2 Windows 11 restore install with wifi not recognized

A Samsung Galaxy Book2 laptop which came with Windows 11 Home pre-loaded was not booting into Windows after MX Linux was installed. Checking, found that the reason why Windows was not booting was that MX Linux had been installed on top of the 200 GB Windows partition. The other Windows RE partition which was undisturbed was just the recovery partition, not the C drive. 

Going into "BIOS" settings was a bit of a chore. If Windows was booting, the method is to press Shift+click on Start - Reboot. Without Windows, we need to boot with some bootable device - if it is Grub based, there would be an entry similar to "System Settings", choosing which the machine would reboot into the "BIOS" screen - which in this case also had a GUI. Booting 3 times unsuccessfully is also supposed to take us to that screen. Then we can go to Boot - Boot Device Priority and choose a USB drive as the first boot device. 

Edit: Pressing F10 on power-on also gives the option to choose boot device and or change UEFI boot settings.

Creating a Windows 11 install disk on a 16 GB USB drive using Linux did not work, following the method given here. Perhaps it was due to the NTFS formatting? Or maybe due to some wrong boot flag? Anyway, created a bootable USB drive Windows 11 installer using Windows 10 on another computer, which took 2-3 hours because it downloaded around 5 GB. Booting from that device, once the installation was completed and "Restore from username" was chosen, files were restored from Microsoft OneDrive and activation of Windows 11 Home was also shown to be completed

Before the installation could complete, there was the same issue as with the Samsung Galaxy Book Go LTE, which is that the built in wifi network adapter was not recognized by the Windows 11 installer, so installation would stop at the point where it requires you to log in to a Microsoft account. The workaround in this case was to plug in a USB wifi adapter which was known to work with Linux, which also worked with the Windows 11 installer.   

Tuesday, May 31, 2022

cloning disks on Linux

Just a reminder to myself - dd can clone not just partitions but entire devices as well. https://linuxhint.com/clone-disk-using-dd-linux/ So, if only one partition needs to be cloned,

sudo dd if=/dev/sdb1 of=/dev/sdc1 status=progress

This will take only as much time as needed for the data present that one partition. 

If we want to make a complete clone of all partitions of one USB drive into another,

sudo dd if=/dev/sdb of=/dev/sdc status=progress

This will take much longer, even if the devices are mostly empty. For example, for 16 GB flash drives with only 2 GB of data, it took around 90 minutes on the Macbook Pro, using the default block size, going at around 3 MB per second.

16000 / 3 / 60 = 88.89 minutes.

Monday, May 30, 2022

checking battery cycles in Linux

Via https://forums.linuxmint.com/viewtopic.php?t=144301 
apt install tlp
and suggested packages
sudo apt install tp-smapi-dkms acpi-call-dkms smartmontools linux-tools-generic

sudo tlp-stat --battery
--- TLP 1.3.1 --------------------------------------------

+++ Battery Features: Charge Thresholds and Recalibrate
natacpi    = inactive (no kernel support)
tpacpi-bat = inactive (laptop not supported)
tp-smapi   = inactive (laptop not supported)

+++ Battery Status
No battery data available.

upower -i /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          (null)
  power supply:         no
  updated:              Thursday 01 January 1970 05:30:00 AM (1653903861 seconds ago)
  has history:          no
  has statistics:       no
  unknown
    warning-level:       unknown
    battery-level:       unknown
    icon-name:          '(null)'

Sunday, May 29, 2022

suspend to RAM - sleep mode - issue with Linux Mint 20.3

After an upgrade to Linux Mint 20.3 from 19.3, the Macbook was showing a garbled screen when waking up from sleep - i.e. suspend to RAM had some issue, probably with the graphics card. The suspend would also take 1 to 3 minutes to complete, with the fan being on for that time with a blank screen. Ctrl+Option+Fn+F2 was allowing a text-mode terminal to be opened, and syslog showed "Buffer eviction failed" before the suspend was taking effect.

 
After waking up, the display driver nouveau would complain of invalid op-code.

At first, I thought it might have something to do with the two displays being detected on the Macbook as mentioned on this post,
https://hnsws.blogspot.com/2021/03/linux-mint-workspace-size.html
since I had mirrored displays instead of disabling one display. But even after disabling one display, the same issue continued. 


The workaround was, as that thread suggested, adding the kernel parameter  init_on_alloc=0 on boot. Since I use refind to boot, in my case, the adding of the kernel parameter was done by editing the /boot/refind_linux.conf as in my previous post,
https://hnsws.blogspot.com/2021/08/verbose-display-while-booting-with.html

After doing that, I could check the parameters passed to the kernel in various ways as listed here,
https://www.cyberciti.biz/faq/display-view-linux-kernel-parameters-for-booted/
like 
dmesg | grep "Command line"
[    0.000000] Command line: \\boot\vmlinuz-5.4.0-113-generic root=UUID=65c50557-my-disk-uuid-c7b5d84509d2 ro init_on_alloc=0 initrd=boot\initrd.img-5.4.0-113-generic

And now suspend to RAM works.


Friday, May 27, 2022

mapping custom domains to github pages on multiple repositories

I was under the impression that one user can only map one custom domain to one repository with Github pages. But this post shows how to map multiple custom domains to multiple repositories for the same username -
https://deanattali.com/blog/multiple-github-pages-domains/

So, instead of Nettigritty's flaky domain redirection which doesn't work half the time, I've now used a meta redirect on another repo which has only index.html to redirect one of our websites. So the steps are:

  1. Add A records with IP addresses obtained by dig username.github.io
  2. Add CNAME record pointing to username.github.io (this is the tricky part which people miss out)
  3. Enable github pages in the Github repository settings
  4. Enable custom domain in the Github repository settings.
  5. After site works, enforce HTTPS in the Github repository settings - if necessary, wait 24 hours before doing this for DNS to propagate.


Wednesday, May 25, 2022

privacy policy and other policies in Moodle

There was a request to add an amended privacy and usage policy on one of our Moodle servers. It was desirable that users click to agree to the policy on their next sign-in.

Under Site Administration - Users tab - Privacy and Policies - Policy settings,
there is the option to change from the Default policy handler (which has the option only for a single site policy and a single site policy for guests)
to the policy_tool policy handler, which has the option to add more policies.

https://docs.moodle.org/400/en/Policies
According to this page, when a new policy is added using this tool, all users will be required to agree to that policy on next login.

After the policy handler is changed to policy_tool , then
The new policy can be added using the page
Site Administration - Users tab - Privacy and Policies - Manage policies
https://our.domain/admin/tool/policy/editpolicydoc.php

The policy can be of type
Site policy
Privacy policy
3rd party policy
or
Other policy




Monday, May 23, 2022

dos disk repair on Linux

 https://askubuntu.com/questions/147228/how-to-repair-a-corrupted-fat32-file-system

So, either

sudo apt-get install dosfstools

sudo dosfsck -w -r -l -a -v -t /dev/sdc1 

or

fsck.vfat -a /dev/sdc1

fsck.fat 4.1 (2017-01-24)
Logical sector size is zero.


https://ubuntuforums.org/showthread.php?t=1908329

Apparently

testdisk is the solution. 

Disk /dev/sdc: 232.91 GiB, 250059350016 bytes, 488397168 sectors
Disk model: External USB HDD
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4d2b50bb

Device     Boot Start       End   Sectors   Size Id Type
/dev/sdc1  *       63 488392064 488392002 232.9G 83 Linux

(In this case, found that the partition had been overwritten by a linux partition :)

Sunday, May 22, 2022

installing a printer on the samsung galaxy book go LTE laptop

Downloading and installing the drivers for the Pixma MG2440 multi-function device - printer and scanner - from Canon's website, the installation did not give any warnings or errors on the Samsung Galaxy Book Go LTE laptop, but the device did not work. No suitable driver found was the error message from the scanner / printer utility. This is probably because this machine has an ARM processor, and the Canon drivers are probably for x86. Even though the ARM-based Windows 11 is supposed to be able to run in emulation mode for 32-bit x86 apps, either the installer was installing 64-bit x86 drivers, or maybe 32-bit drivers don't work in emulation mode.

Anyway, the solution was to get Microsoft's generic Canon inkjet drivers from Windows Update. But the way to do this was not very intuitive. After clicking on "Update driver" in Control Panel, the Windows Update screen is shown, and after "Check for Updates", it shows "No updates found." But lower down, clicking on "Optional updates", it finds two drivers. Installing these made the printer work, albeit with a blank printout due to the ink being exhausted.

Saturday, May 21, 2022

troubleshooting ad-hoc query reports in Moodle

Number of files downloaded per user query

The following was my procedure for making corrections to this ad-hoc Moodle query:

Expanding out the sub-query and running it in DBeaver, could see the discrepancies in the count. Changed the select count() to just select, then went step by step to identify which rows were causing discrepancies, copy-pasting the filenames to adjacent columns on a temporary google sheet for easy comparison. 

It turns out the bugs in the query were due to some assumptions which I made about the prefix_logstore_standard_log table:
1. I assumed each file download led to a single log entry - no, there are multiple log entries for each download
2. I assumed that the shorter query which I used for counting the number of files will be sufficient, apparently it is not.
3. There were also overcounting in case the user was downloading the same file multiple times.

So, I have made some modifications to both the queries, now they shows the number of files downloaded which are of non-zero size. The files listing only shows one filename for each download and does not indicate multiple downloads, so now I have modified the number of files counted per user also to ignore multiple downloads of the same file.
 

In the case of these users I tested, one user has download some files many times, like

Even after this, there were mismatches in the count. The reason is that was, the query "Number of files downloaded per user" counted only distinct filenames.
Now, there are some files with the same name, but with different content, like Fractions.pdf which occurs with different content in different courses. The listing of files shows these separately.

I can correct for this by choosing
count(distinct f2.contenthash) instead of
count(distinct f2.filename)

But still the numbers won't match. This is because there are some files with exactly the same name and same content, in different courses.
For example,
VI Maths || Fractions || VC_Way of Sharing from the Whole.pptx || 779583
VI TNSSE Maths || Fractions Term III || VC_Way of Sharing from the Whole.pptx || 779583

which have both been downloaded by the user we checked.

So, in order to count these files also separately, I will count
count(distinct concat(f2.contenthash,l2.contextinstanceid) instead of simply
count(distinct f2.contenthash)

Then it matches for this user.

Files downloaded per user query

The reason for the "short name of the course, resource reviewed and files downloaded mismatch" for the other query was wrong mapping of resourceid in the log.

In our query, we have
left join vv_resource r on l.objectid = r.id
i.e. we are mapping the objectid to resourceid. But this seems to be wrong.

To see why, I went through all the columns in the logstore log table.
There is a column which says objecttable. For those entries where objecttable says resource, the mapping is correct. For example, pdf files. The contextinstanceid seems to be unique to each course section.

So, I modified the query so that instead of "Resource viewed", I have put the column "Course Module" which shows the correct course module -
vcs.name, from
left join {course_modules} vcm on l.contextinstanceid = vcm.id
left join {course_sections} vcs on vcm.section = vcs.id

Then the query gives correct results for pdf files as well as other file types like pptx.

 


Thursday, May 19, 2022

usrmerge message after fresh Linux Mint 20.3 Install

After a fresh installation of Linux Mint 20.1, which auto-updated to 20.3, there was a system report about usrmerge - 


https://community.linuxmint.com/software/view/usrmerge

This forum post
indicated that the command to be run, in case usrmerge had not yet happened,  
There are two scripts:
/usr/lib/convert-etc-shells
/usr/lib/convert-usrmerge
which execute the needed changes, in case they have not been done already.

But in my case, ls -l / was showing all the symlinks like bin -> usr/bin etc.  So I asked Mint to ignore this report and not show it again. 

Friday, May 13, 2022

Samsung Galaxy Book Go LTE - no wifi after factory reset

After a factory reset, I had shut down a Samsung Galaxy Book Go LTE laptop in order to give it to someone else. After a couple of days, when they were trying to set it up, initial setup was not proceeding after the point where it tries to connect to the network. Checking with a 4G SIM inserted, setup proceeded, and the laptop booted up into Windows 11. But no wifi networks were being detected. The wireless networking device was being flagged in Control Panel.

So, deleted the "Unknown device" in control panel, restarted the machine - now it recognized the wifi adapter, asked to connect to the network, and worked fine. 

Thursday, May 12, 2022

blocking phishing emails from Google Workspace

I was asked how an institution could block some phishing emails, which had the name of the current Vice-Chancellor in the "From" field, with some random gmail id. Excerpts from my reply:

1. Report phishing - You could ask the user to follow these steps - 
image.png

2. From admin.google.com , blocking this particular email - 
You can set up rules using the method at

For example, you could put in a filter so that any email which has
  • simple content search NameOfVC in headers
  • AND is from @gmail.com
  • should be blocked

Thursday, May 05, 2022

printing with HP LaserJet Tank 1020w with Android and Linux

Instead of just connecting the USB cable and using plug-and-play on Linux to install the drivers, thought I would directly try HP's Smart app on Android to install the printer. Worked OK, though it was nearly 100 MB in size. While printing documents shot as photos, my phone makes the background of the pics excessively grey - so probably need to edit the image, bump up brightness and contrast.

Trying to print from Linux Mint 19.3 Tricia, though the network printer was found, and as prompted by the wizard, I had installed the drivers it prompted, giving the print command did not lead to any action on the printer. Pressing the "i" information button was giving a test print on the printer, so the printer itself was fine. 
 
Found a youtube video detailing the installation of the HP Linux Imaging and Printing software hplip, which described the problem I faced exactly. In my case, it looked like hplip version 3.17.10+ was already installed by Linux Mint, but the printer needed a newer version as per

But going through the install process, came across multiple devel packages which the installer was not able to install for Linux Mint 19.3 - like SNMP devel package. 


Some forum posts indicate can make it work without the hplip package. Using the foo2zjs instead, method like
but using github as the source as indicated at

So, I first uninstalled the old version of hplip with apt (I had done this before trying to install the new version of hplip), and then

sudo apt-get update
 sudo apt-get remove cups hplip cups-filters hplip-data system-config-printer-udev
 sudo apt-get install cups build-essential tix groff dc axel
 sudo apt-get install cups-filters cups unp system-config-printer-gnome
 sudo rm -rf /usr/share/hplip
 cd /tmp
 rm foo*
git clone https://github.com/koenkooi/foo2zjs.git
cd foo2zjs
make

# Also, since source code from github already contains all firmware images,
# there is no need to run getweb, as per the askubuntu link above. 

sudo make install
sudo make install-hotplug

# Unplug and re-plug the USB printer into the PC
 # add new HP Laserjet 1020 printer via system-config-printer tool
 # and choose to use foo2zjs foomatic printer driver :

 system-config-printer

# at this step, my system was silent, since I did not connect via USB, but instead on network

Now when I tried a test page print via the network printer shown in Ubuntu, it worked. 
 
Edit 22 May -  On Linux Mint 20.3, which is based on Ubuntu 20.04, the printer installed automatically flawlessly. I just switched on the printer, which had already been set up on the wifi network, Linux automatically detected it and added the printer without me having to do anything, and a print from Gimp worked fine.