Monday, March 13, 2023

Troubles, Confusion, and Hope

The paddy fields in Thalpavila.
Last long weekend, I went to Matara to my home town with my wife. We don't get to travel to Matara very often --- just once a month in the best case. This is mostly due to us getting busy over the weekends. The renovation work at home in Matara has been progressing well, although in a slow pace since the last year. It's a pleasure to see the beautiful transformation of our childhood home getting refurbished and modernised. The economic hardships in the country challenged us in various stages of this project due to increase cost of raw material and labour. Although I carry my work with me to Matara hoping that I would be able to do some work there, I didn't do any work at home in the last weekend. It would be unfair to my family if I spend holidays in front of my computer doing works; holidays are holidays after all. It's a safe haven for us to take a break from work and have a breath and good sleep.

In Matara, my younger brother has a bicycle. Every time I go to Matara, I wanted to take it out and ride in the neighborhood. One day a few months back, I went on a ride across the village over a long distance.  In that journey, I managed to go through roads that I had either never traveled or haven't traveled for a long time. In the last weekend, I took the bicycle to go all the way closer to the Kekanadura railway station. Although the expressed objective of this journey was to buy some bread, my real objective was to visit a water stream near Kenanadura railway station. Over 25 years ago, when I was in 6th, 7th, and 8th grades, I used to walk from home to Kekanadura to attend tuition classes in weekends. In evenings, after a class, I would walk with a few neighborhood friends back home, sipping an ice packet — not that drug, but a frozen sweetened beverage in a polythene packaging. Somewhere in between Kekanadura and Thalpavila — near modern-day railway station — there used to be this stream of water. It brought water, what I believe to be from Allakanda Reservoir, to the paddy fields all around that area. As kids, we used to stop by this stream, on our way home, to have a look at various types of fishes. This time after 25 years, my visit in a bicycle to this place revealed that a lot of construction work has happened and the stream is gone. It is sad that urbanisation is taking over the nature.

The lab with new arrangement of equipment.

 In my research, I have been struggling to complete many work I had started since last year. The year 2022 has been mostly occupied with various new administration duties at the university. Due to that, I had less time to make progress in my research, impacting negatively to my profile. This year, I got one paper accepted in MDPI Applied Sciences journal, which was a much needed achievement to start this year 2023. Meanwhile, I'm facing a serious challenge from the ongoing research project funded by Dialog Axiata. The research assistant and the interns assigned to the project were making very little progress in the project, which was very tight in terms of timeline. I was constantly under pressure to move even tiny steps forward in that project's tasks. I think, there is an issue in the way I have been recruiting and managing human resources. This project taught me many lessons on how to manage a project and how to deal with employees. Just throwing people into a project and expecting that they would do a good job on their own is not realistic; as PI, I have to proactively engage and monitor the progress of a project from the beginning.

In a tough time like this, it is necessary to have a proper research team who can help each other and make everybody in company. The lack of such a team is impacting my research negatively. Under such circumstances, I've found a good companion who has the same enthusiasm towards research as myself. Akila was a Master's degree student, whom I supervised for his final project. Since I started supervising his project, we turned into good friends and are in constant contact. He successfully completed his project and submitted his thesis recently. He regularly visits UCSC and do various kinds of experiments whenever he finds something interesting. It is a great pleasure to work with him. Last few days, I got together with him and arranged the lab in a novel way so that we now have a better working environment in the lab. I hope that the support I'm getting from him would help me to keep my enthusiasm high on continuing my research work.

Saturday, February 4, 2023

Blogging: My Lost Habit

I've used to be a very enthusiastic blog writer over a decade ago. With time, the number of posts I write per year decreased drastically. By the year 2022, I was barely writing a single post — even that's after noticing the risk that I might go without a single post in that year. 

The benches at Kyunpook National University (KNU) in Daegu, South Korea. The picture was taken on a Sunday in mid-September, 2013. I was waiting for someone to meet me there.
Back in the days, most of my blog posts were on new technical knowledge that I had acquired. For example, while doing some project work, a research work in the lab, or even when trying to do some course work-related task, I've come across various challenging situations. The answers to such challenges were found by either searching in the web, or by exploring myself. Solutions I find in such situations are so precious and potentially can arise in the future again, to me and to others. Due to this very reason, such things deserve to be written down somewhere that myself and other's can easily find — that's what the blog is for. I've written very detailed blog posts on how to do this and that over the years.

In addition to technical posts, I have occasionally written about important events, experiences, and thoughts that I've came across. After several years, these special posts are a pleasure to read; they refresh memories and take me back across time.

So, all these facts points to the importance of keep writing blogs. In this year 2023, I'll restart the blogging habit and try to write as much as possible.

Wednesday, October 5, 2022

Editing Binary Files on Vim Editor

 Here's a quick method I use to edit binary files on the vim editor. Suppose that the binary file name that we need to edit is called hello. Let's open it using the xxd hex viewer utility and pipe it to the vim editor as follows using the terminal. This produces the hex view of the binary file on the vim editor.

xxd hello | vim -

Now, we are good to go with editing the hex values in the file as you would do with any text file on the vim editor. Once we are done with the editing, we can now convert this updated hexdump view on the vim editor back to a new binary file. In order to do that, go to the command mode of the vim editor, and type and enter the following command. It will save the edited binary into a new file; the new file can be named anything while I have made it to be hello-new.

%!xxd -r > hello-new

Now, you can safely quit the vim editor with q! on the command mode as you would always quit it. :) Cheers!

References:

[1] https://vi.stackexchange.com/questions/343/how-to-edit-binary-files-with-vim

Tuesday, December 14, 2021

Creating a Window 10 Live USB Stick on an Ubuntu GNU/Linux Computer

As a hardcore user of GNU/Linux systems, I don't usually come across any requirement to use Windows operating system. However recently, I had to install Windows in somebody else's computer as a help. It took me a while to find out how to prepare a installation USB drive for the purpose. Here's the steps I followed, hoping that my future self may need to refer back one day.

1. Download Window 10 ISO file from the official Microsoft website.


2. Download and install WoeUSB-ng on the Ubuntu computer using the information in the following Github page: https://github.com/WoeUSB/WoeUSB-ng


3. Run the following command to make the USB device (/dev/sdb in my case) bootable with the downloaded Windows ISO file. If there are files in the Windows 10 ISO file that are bigger than 4GB, the following command will automatically revert to NTFS format. 


sudo woeusb --target-filesystem FAT --device ~/Downloads/Win10_21H2_EnglishInternational_x64.iso /dev/sdb 

References:

Thursday, March 25, 2021

Enabling Hibernation in Ubuntu 20.04 LTS using a Swap File

Enabling of the hibernation option on Ubuntu 20.04 LTS didn't work in the way I used to do. So, I had to explore further and do it slightly differently. This blog post records those things I did to get hibernation option working.

1. First of all, create a swap file using the following commands.

sudo fallocate -l 17G /swapfile

sudo chmod 600 /swapfile

sudo mkswap /swapfile

sudo swapon /swapfile


Once done, add an entry to the end of /etc/fstab file to make use of this swap file as follows.

/swapfile none swap sw 0 0

2. Check the UUID of the partition where the swap file is located using the following command.

cat /etc/fstab

Take note of the UUID string, which we will need in a later step.

3. Check the offset to the swapfile with in the storage device using either of the following commands. Take note of that offset value.

sudo filefrag -v /swapfile | awk '{ if($1=="0:"){print substr($4, 1, length($4)-2)} }'

sudo swap-offset /swapfile

4. Now, open the /etc/default/grub file and add update the correct line as follows.

Original line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

Updated line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=a27fc21e-3315-4497-99aa-1fe7fad64091 resume_offset=9807872"

Note that the UUID value and the resume offset value are found using the above steps 2 and 3.

Once this grub file is updated, run the following command to take the changes effect.

sudo update-grub

5. Test whether the hibernation option is working now, use either of the following commands. I personally prefer the second command as it provides some verbose output while the system is being hibernated and being resumed later.

sudo systemctl hibernate

sudo pm-hibernate

Cheers!


References:

  1. https://linuxize.com/post/create-a-linux-swap-file/
  2. https://askubuntu.com/questions/1240123/how-to-enable-hibernate-option-in-ubuntu-20-04
  3. https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file


Tuesday, April 21, 2020

Encrypting Files Using GnuPG

This post shows how to use GnuPG to encrypt and decrypt files on a Linux environment.

1. If you haven't created your GnuPG key pair yet, you can use the following commands to create them and view their details.

Create a pair of GnuPG keys using the following command.

gpg --gen-key

The keys and their relevant information are stored in .gnupg directory under your home directory. You can view the public keys in your keyring using the following command.

gpg --list-key

You can view the private keys using the following command.

gpg --list-secret-keys

2. Encrypting a file called "private-file.txt" can be done as follows. We can either specify a new name for the encrypted file or GnuPG will automatically name the new file by appending .gpg extension to the name of the plaintext file.

gpg --encrypt --recipient your.email@gdomain.com private-file.txt

gpg --output encrypted.gpg --encrypt --recipient your.email@gdomain.com private-file.txt

3. Decrypting a file called "private-file.txt.gpg" can be done as follows. Similar to the previous case, we can either specify a name for the decrypted file or leave it to the default.

gpg --output private-file.txt --decrypt private-file.txt.gpg

gpg --decrypt encrypted.gpg > private-file.txt

4. Encrypting all the files in a directory can be done as follows.

gpg --encrypt-files --recipient your.email@gdomain.com /path/to/the/directory/*

5. Decrypting all the .gpg files in a particular directory can be done as follows.

gpg --decrypt-files /path/to/the/directory/*.gpg

Resources: 

1. https://blog.ghostinthemachines.com/2015/03/01/how-to-use-gpg-command-line/

2. https://www.gnupg.org/gph/en/manual.pdf

~*************~

Friday, April 17, 2020

Sending Secure Emails with OpenPGP

Use of encryption in our electronic communication is essential to protect our security and privacy. Here's how we can use OpenPGP standard to send and receive emails securly. While there are many software tools to get this done, I prefer this way.

1. Create a pair of GNU Pritty Good Privacy (PGP) keys using the following command.

gpg --gen-key

The keys and their relevant information are stored in .gnupg directory under your home directory. You can view the public keys in your keyring using the following command.

gpg --list-key

You can view the private keys using the following command.

gpg --list-secret-keys

2. Log-in to your email account from Thunderbird email client. Thunderbird is available by default in most Linux systems including Ubuntu Linux.

3. Install the Enigmail plug-in in Thunderbird. Since we have already created the GPG keys, Enigmail will automatically detect them and start using them. If we didn't have created the keys already, Enigmail facilitates creating them as well.

4. From the menu bar of Thunderbird, select the Enigmail item and then Key Management option, which will display your key. Right-click on your key and select the option "Upload Public Keys to Kerservers". This will post your public key to a public key server.

5. Now, we are good to go with sending and receiving encrypted emails. When you compose an email with Thunderbird, there is a padlock button that stands for encryption of the email. When you enable it and then hit send button, Enigmail will prompt you if the public key of the recipient is not available locally. In that case, it will also facilitate to obtain the required keys from keyservers as well.

References:

1. https://emailselfdefense.fsf.org/en/

2. https://blog.ghostinthemachines.com/2015/03/01/how-to-use-gpg-command-line/

~***********~