Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Thursday, December 25, 2025

Rust and WebAssembly quick start guide 2025

Rust and WebAssembly quick start guide 2025

As of December 2025, Rust and WebAssembly is reorganizing. Documentation is currently out of date and not working. This is my notes on getting started using Rust WebAssembly. Most of the documentation still works - below is distilled version.

Install Rust toolchain
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Below shows my Rust toolchain versions
q@x1m9:~/tmp$ cargo --version
cargo 1.92.0 (344c4567c 2025-10-21)
q@x1m9:~/tmp$ rustc --version
rustc 1.92.0 (ded5c06cf 2025-12-08)


Install wasm-pack - your one-stop shop for building, testing, and publishing Rust-generated WebAssembly.
$ sudo apt install build-essential
$ cargo install wasm-pack
wasm-pack version
q@x1m9:~/tmp$ wasm-pack --version
wasm-pack 0.13.1


Install cargo-generate - helps you get up and running quickly with a new Rust project by leveraging a pre-existing git repository as a template.
$ sudo apt install libssl-dev
$ sudo apt install pkg-config
$ cargo install cargo-generate
cargo-generate version
q@x1m9:~/tmp$ cargo-generate --version
cargo generate 0.23.7


Install npm

Install node version manager - nvm
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
nvm version
q@x1m9:~/tmp$ nvm --version
0.40.3


Now install latest version of node
$ nvm install node
node version
q@x1m9:~/tmp$ node --version
v25.2.1


Clone project template
$ cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name wasm-game-of-life
$ cd wasm-game-of-life


Build the project
$ wasm-pack build


Putting it into a webpage, run in project root
$ sudo apt install git
$ npm init wasm-app www


Install dependencies
$ cd ~/p/wasm-game-of-life/www
$ npm install


Edit ~/p/wasm-game-of-life/www/package.json
$ nvim ~/p/wasm-game-of-life/www/package.json 


Add wasm-game-of-life to dependencies section of package.json and also note that devDependencies is updated.
{
  "name": "create-wasm-app",
  "version": "0.1.0",
  "description": "create an app to consume rust-generated wasm packages",
  "main": "index.js",
  "bin": {
    "create-wasm-app": ".bin/create-wasm-app.js"
  },
  "scripts": {
    "build": "webpack --config webpack.config.js",
    "start": "webpack-dev-server"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/rustwasm/create-wasm-app.git"
  },
  "keywords": [
    "webassembly",
    "wasm",
    "rust",
    "webpack"
  ],
  "author": "Ashley Williams ",
  "license": "(MIT OR Apache-2.0)",
  "bugs": {
    "url": "https://github.com/rustwasm/create-wasm-app/issues"
  },
  "homepage": "https://github.com/rustwasm/create-wasm-app#readme",
  "devDependencies": {
    "webpack": "^5.0.0",
    "webpack-cli": "^5.0.0",
    "webpack-dev-server": "^4.0.0",
    "copy-webpack-plugin": "^11.0.0",
    "hello-wasm-pack": "^0.1.0"
  },
  "dependencies": {
    "wasm-game-of-life": "file:../pkg"
  }
}


Edit ~/p/wasm-game-of-life/www/index.js
$ nvim ~/p/wasm-game-of-life/www/index.js


Add wasm-game-of-life package to index.js
import * as wasm from "wasm-game-of-life";

wasm.greet();


Install wasm-game-of-life package and force clean as we have upgraded devDependencies
$ cd ~/p/wasm-game-of-life/www
$ rm -rf node_modules package-lock.json
$ npm install


Fix ~/p/wasm-game-of-life/www/webpack.config.js
$ nvim ~/p/wasm-game-of-life/www/webpack.config.js


Observe we have changed CopyWebpackPlugin and added asyncWebAssembly
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require('path');

module.exports = {
  entry: "./bootstrap.js",
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "bootstrap.js",
  },
  mode: "development",
  plugins: [
    new CopyWebpackPlugin({
      patterns: [
        { from: "index.html" },
      ],
    })
  ],
  experiments: {
    asyncWebAssembly: true,
  },
};


Now run it
$ npm run start


Open http://localhost:8080

Thursday, November 27, 2025

Installing TigerVNC in Ubuntu 24.04

Installing TigerVNC in Ubuntu 24.04

Ubuntu 24.04 supports RPD protocol but it behaves in a way that is not fit for my needs. The Desktop Sharing mode needs to have a user logged in or set to automatically login on reboot. Anyone will have access to your desktop if they are physically present. The Remote Login would have been the best option but when the connection is lost, all applications running on that session are gone. So you can't reconnect to that same session.

So, we are back to the tried and tested VNC protocol. To get TigerVNC working on Ubuntu 24.04 is a little tricky due to Wayland becoming the default in 24.04. To workaround Wayland, we need to install XFCE, like so:
$ sudo apt install --no-install-recommends xubuntu-desktop
This installs base XFCE4 with very applications specific to XFCE.

Install xfce4-terminal for convenience. GNOME-Terminal is pretty heavy and uxterm/xterm are not to my liking.
$ sudo apt install xfce4-terminal
Now install TigerVNC
$ sudo apt install tigervnc-standalone-server
Then set the password that will be used to connect to the VNC server by running it like below:
$ vncpasswd
Now we have to define the mapping between a VNC session and user for that session. To do this open /etc/tigervnc/vncserver.users, like:
$ sudo vim /etc/tigervnc/vncserver.users
Below is an example that shows user u1 is mapped to VNC server session 2:
# TigerVNC User assignment
#
# This file assigns users to specific VNC display numbers.
# The syntax is <display>=<username>. E.g.:
#
# :2=andrew
# :3=lisa
:2=u1
Now run VNC server, like:
$ vncserver -geometry=1360x768 -xstartup /usr/bin/startxfce4 :2 -localhost no
Using RealVNC client on Windows, you can calculate geometry of the server like this to get maximum client area: The same script can be used to calculate client dimensions for remote desktop client.

Should you need to close/kill the session, do:
$ vncserver -kill :2


There is a big caveat that I haven't figured out, yet. No user should be logged in to the console/physical session. Otherwise, everything goes crazy.
References:
https://medium.com/oracledevs/your-next-developer-desktop-with-ubuntu-24-04-and-tigervnc-on-oci-d0356ffa0cf9

Wednesday, September 17, 2025

Several modules must be compiled when running VMware Workstation on Ubuntu

Several modules must be compiled when running VMware Workstation on Ubuntu

I have a machine with Ubuntu 24.04.2 with VMware Workstation working as expected. When I connected to the machine Ubuntu told me there were packages available that can be updated inlcuding the kernel. So, I did the update and rebooted the machine. Running VMware Workstation failed with "several modules must be compiled". The fix is quite easy, run the following to fix it.
$ sudo vmware-modconfig --console --install-all
Notes:
- VMWare Workstation: 17.6.3
- Host: Ubuntu 24.04.2 LTS

Wednesday, May 07, 2025

Configuring TUN/TAP virtual network interface for use with QEMU on Xubuntu 24.04

Configuring TUN/TAP virtual network interface for use with QEMU on Xubuntu 24.04

I am planning to run qemu-system-ppc to play around QEMU and PPC with networking support. The quest and U-Boot will need to interact with external services, namely, tftp. The recommended network is to have TUN/TAP virtual network interface configured on the host. My host is Xubuntu 24.04/Ubuntu 24.04.

Let's start by creating tap0 using systemd
u1@m18:~$ sudo nvim /etc/systemd/system/tap0.service
Copy/paste content below Change u1 to the user who needs access to tap0

Run command below to create tap0. This should also presist after reboot
u1@m18:~$ sudo systemctl daemon-reexec
u1@m18:~$ sudo systemctl enable --now tap0.service
Create a backup of existing netplan configuration
u1@m18:~$ mkdir ~/backup
u1@m18:~$ cd /etc/netplan
u1@m18:~$ sudo mv * ~/backup
Create new netplan configuration, let us call it 01-netcfg.yaml
u1@m18:~$ sudo touch /etc/netplan01-netcfg.yaml
u1@m18:~$ sudo chmod 600 /etc/netplan/01-netcfg.yaml
u1@m18:~$ sudo nvim /etc/netplan/01-netcfg.yaml
Copy/paste gist below into 01-netcfg.yaml. Note that ens33 is my interface name, so update that as appropriate.

Now disable Network Manager and enable networkd. The command below will reconfure your network, so you need to be on the console and not via ssh.
u1@m18:~$ sudo systemctl stop NetworkManager.service
u1@m18:~$ sudo systemctl disable NetworkManager.service
u1@m18:~$ sudo systemctl start systemd-networkd.service
u1@m18:~$ sudo systemctl enable systemd-networkd.service
Now apply netplan configuration
u1@m18:~$ sudo netplan apply
Running QEMU below and issuing dhcp at U-boot prompt should allow the guest to get IP address from DHCP server. Of course, I am assuming that there is DHCP server in the network.
u1@m18:~$ qemu-system-ppc -M mpc8544ds -cpu mpc8540 -m 512 -nographic -netdev tap,id=net0,ifname=tap0,script=no,downscript=no -device e1000,netdev=net0 -serial mon:stdio

Installing QNX 6.5.1 on Ubuntu 24.04

Installing QNX 6.5.1 on Ubuntu 24.04

Install pre-requisites
$: sudo dpkg --add-architecture i386
$: sudo apt update
$: sudo apt install libc6:i386 default-jre-headless:i386 libgtk2.0-0:i386 libcanberra-gtk-module:i386 gtk2-engines-murrine:i386 libatk-adaptor:i386 gtk2-engines-pixbuf:i386 gtk2-engines:i386 libasound2-plugins:i386 libxtst6:i386
Mount QNX 6.5.0 (I am using qnxsdp-6.5.0-201007091524-dvd.iso), then install like so:
$: cd /media/$USER/QNXSDP650
$: sudo -E ./qnxsdp-6.5.0-201007091524-linux.bin -silent
Logout and then log back in, then run Momentics IDE. This is to verify that installation of QNX 6.5.0 was successful.
$: qde
Mount QNX 6.5 SP1 (I am using qnxsdp-6.5.0SP1.iso), then install like so:
$: cd cd /media/$USER/qnxsdp-6.5.0SP1
$: sudo -E ./qnxsdp-6.5.0SP1-201206271006-linux.bin -silent
Verify that SP1 was installed using qconfig
u1@m18:/media/u1/qnxsdp-6.5.0SP1$ qconfig
QNX Installations 

  Installation Name: QNX Software Development Platform 6.5.0
            Version: 6.5.0
     Base Directory: /opt/qnx650
           QNX_HOST: /opt/qnx650/host/linux/x86
         QNX_TARGET: /opt/qnx650/target/qnx6

Additional Packages

	  Package Name: QNX Software Development Platform
	       Version: 6.5.0SP1
	          Base: QNX SDP 6.5.0
	  Installation Path: /opt/qnx650

Sunday, September 01, 2024

Installing QNX 6.4.1 on Ubuntu 20.04

Installing QNX 6.4.1 on Ubuntu 20.04

Install pre-requisites
$: sudo dpkg --add-architecture i386
$: sudo apt update
$: sudo apt install libc6:i386 default-jre-headless:i386 libgtk2.0-0:i386 libcanberra-gtk-module:i386 gtk2-engines-murrine:i386 libatk-adaptor:i386 gtk2-engines-pixbuf:i386 gtk2-engines:i386 libasound2-plugins:i386 libxtst6:i386
Mount QNX 6.4.1 (I am using qnxsdp-6.4.1-200905201802-dvd.iso), then install like so:
$: sudo ./qnxsdp-6.4.1-200905201802-linux.bin -silent
Logout and then log back in, then run Momentics IDE:
$: qde

Monday, December 25, 2023

Neovim: How to enable yanking to system clipboard in Ubuntu

Neovim: How to enable yanking to system clipboard in Ubuntu

Yanking or copying to system clipboard can be enabled using the following command
set clipboard=unnamedplus

Saturday, July 15, 2023

Running OPC UA .Net Standard PubSub reference server on Ubuntu 22.04 using dotnet-sdk-6.0

Running OPC UA .Net Standard PubSub reference server on Ubuntu 22.04 using dotnet-sdk-6.0

System info:
OS: Ubuntu 22.04
OPC UA .Net Standard under test: 1.4.371.96

Install MQTT broker

$: sudo apt install mosquitto

Install dotnet-sdk-6.0

$: sudo apt install dotnet-sdk-6.0

Install git as needed

$: sudo apt install git

Clone OPC UA .Net Standard git repo

$: mkdir ~/prj
$: cd ~/prj
$: git clone https://github.com/OPCFoundation/UA-.NETStandard.git
$: cd UA-.NETStandard
$: git checkout refs/tags/1.4.371.96

Run publisher

$: dotnet run --project Applications/ConsoleReferencePublisher/ConsoleReferencePublisher.csproj --framework net6.0

Run subscriber (on another terminal)

$: cd ~/prj/UA-.NETStandard
$: dotnet run --project Applications/ConsoleReferenceSubscriber/ConsoleReferenceSubscriber.csproj --framework net6.0

Unable to install updates (null): cannot refresh "snap-store": snap "snap-store" has running apps (snap-store)

Unable to install updates
(null): cannot refresh "snap-store": snap "snap-store" has running apps (snap-store), pids:#####

Using Ubuntu Software to update Snap packages failed on Ubuntu 22.04.
To fix it run the following:
$: killall snap-store
$: snap refresh

Running OPC UA .Net Standard PubSub reference server on Ubuntu 20.04 using dotnet-sdk-3.1

Running OPC UA .Net Standard PubSub reference server on Ubuntu 20.04 using dotnet-sdk-3.1

High Level Info:


OPC UA .Net Standard under test: 1.4.371.96
OS: Ubuntu 20.04 (>20.04 not working due to dotnet-sdk-3.1 is not supported)

Install dotnet-sdk-3.1

$: wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
$: sudo dpkg -i packages-microsoft-prod.deb
$: rm packages-microsoft-prod.deb
$: sudo apt update
$: sudo apt install dotnet-sdk-3.1

Clone OPC UA .Net Standard git repo

$: mkdir -p ~/prj
$: git clone -b 1.4.371.96 https://github.com/OPCFoundation/UA-.NETStandard.git

Install MQTT broker Mosquitto and supporting tools

$: sudo apt install mosquitto
$: sudo apt  install mosquitto-clients

Run mqtt sub client to see traffic

$: mosquitto_sub -h localhost -v -t '#'

Run reference PubSub publisher

$: cd ~/prj/UA-.NETStandard/Applications/ConsoleReferencePublisher
$: dotnet run --project ConsoleReferencePublisher.csproj --framework netcoreapp3.1

Run reference PubSub subscriber

$: cd ~/prj/UA-.NETStandard/Applications/ConsoleReferenceSubscriber
$: dotnet run --project ConsoleReferenceSubscriber.csproj --framework netcoreapp3.1
Ref(s):
Install the .NET SDK or the .NET Runtime on Ubuntu

Sunday, December 25, 2022

Add hard drive into Linux Mint 21.1 Vera/Ubuntu/Debian

Add hard drive into Linux Mint 21.1 Vera/Ubuntu/Debian

This is a condensed version on how to add hard disk into Linux Mint/Ubuntu/Debian. First check hard drives in the system, like so:
$: sudo lshw -C disk
It should show (partial data only) like this:
*-disk:1
   description: ATA Disk
   product: WDC WD3200AAKX-0
   vendor: Western Digital
   physical id: 1
   bus info: scsi@1:0.0.0
   logical name: /dev/sdb
   version: 1H15
   serial: WD-WMC2E0871450
   size: 298GiB (320GB)
   capabilities: partitioned partitioned:dos
   configuration: ansiversion=5 logicalsectorsize=512 sectorsize=512 signature=e32ff1f9
Using parted, let's now configure the harddisk/partition
$: sudo parted /dev/sdb
In parted prompt, create a new GPT partition table
(parted) mklabel gpt
Change the default unit to GB
(parted) unit GB
Create one partition occupying all the space on the drive
(parted) mkpart primary ext4 0 100%
Check to verify the layout
(parted) print
It should show something like below:
Model: ATA WDC WD3200AAKX-0 (scsi)
Disk /dev/sdb: 320GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End    Size   File system  Name     Flags
 1      0.00GB  320GB  320GB  ext4         primary
Save and quit parted
(parted) quit
Format the partition using ext4
$: sudo mkfs -t ext4 /dev/sdb1
Formatting process should show something like below:
mke2fs 1.46.5 (30-Dec-2021)
/dev/sdb1 contains a ext4 file system labelled 'VMs'
        last mounted on /mnt/b41faa95-6135-47f6-a24e-ed1909d6fc18 on Sun Dec 25 19:06:43 2022
Proceed anyway? (y,N) y
Creating filesystem with 78142464 4k blocks and 19537920 inodes
Filesystem UUID: 1b7f46da-9aa6-4c30-afec-d983f35a19d5
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks):
done
Writing superblocks and filesystem accounting information: done
Now let us create a mount point
$: sudo mkdir /mnt/vmdisk
Add an entry in fstab to automount the new partition
$: sudo vim /etc/fstab
Add a line entry in fstab like below
/dev/sdb1    /mnt/vmdisk   ext4    defaults     0        0
We should be able to use the partition without rebooting, so mount it manually for now.
$: sudo mount /mnt/vmdisk
Add directory to be writable by user
$: sudo mkdir /mnt/vmdisk/vms
Make the user named timus owner of the new folder
$: sudo chown -R timus:timus /mnt/vmdisk/vms
Refs:
https://help.ubuntu.com/community/InstallingANewHardDrive

Sunday, November 21, 2021

How to expand Ubuntu VM root partition

How to expand Ubuntu VM root partition

In this post I have expanded the virtual disk of a Ubuntu VM via VirtualBox Media Manager. The OS inside the VM will not automatically use the additional space. In this post I will show how to expand the root partition to make use of the additional space.

There are multiple ways to expand a partition in Linux, in this post I will document how to do it using GParted.

  1.  Change the VM configuration to boot using Ubuntu installer. 
  2. Boot the VM using the Ubuntu ISO installer
  3. Run GParted - in the warning dialog that says not all space is used, hit on the Fix button
  4. Select the partition to resize and click Resize/Move partition button
  5. Expand the partition to the desired size

  6. The hit on Apply All Operations

  7. Shutdown the VM, remove/detach ISO, then reboot the computer

 

.end.

How to expand virtual hard disk in VirtualBox

How to expand virtual hard disk in VirtualBox

To expand a virtual disk in VirtualBox open Oracle VM Virtual Manager then do File | Virtual Media Manager... (Ctrl+D) menu option. Then select the disk you wanted to expand. Note that VirtualBox does not support expanding a snapshot - you can expand but it will not work. You either have to delete all the snapshots or create a full clone of the snapshot. In the screen capture below I have created a full clone of Ubu2110 to Ubu2110-C1 and adjusted the size from 10GB to 12GB.

In the next post, we will explore how to expand storage of a Ubuntu VM to make use of the additional space.

Keywords:
VirtualBox Ubuntu Expand

Thursday, November 18, 2021

Resolve Windows NetBIOS name in Ubuntu 20.04

Resolve Windows NetBIOS name in Ubuntu 20.04

It is very common to have a mix of Windows and Ubuntu/Linux in an enterprise environment. There are scenarios where Ubuntu can get IP via DHCP but not enroll the machine to DNS. To resolve Windows NetBIOS machine name in Ubuntu in a workgroup environment do the following. Install nss-winbind like below

$: sudo apt install libnss-winbind

Then update /etc/nsswitch.conf. On Ubuntu 20.04, this will be line 12, which should look like below:
hosts:          files wins dns

Refs:
https://8thstring.blogspot.com/2010/05/resolve-netbios-name-in-ubuntu.html

Sunday, May 16, 2021

WSL2: Ubuntu fails to start ssh server

WSL2: Ubuntu fails to start ssh server
Running sudo service ssh start fails with error message like below:
* Starting OpenBSD Secure Shell server sshd
sshd: no hostkeys available -- exiting.
It is failing because there are no keys generated in the system, to fix it do:
$: sudo ssh-keygen -A
You should now able to able to start it, like:
$: sudo service ssh start

Installing WSL2 on Windows Server 20H2

Installing WSL2 on Windows Server 20H2

Environment info

  •  Host: Windows 10 Release 1909 Pro
  • Virtualization: VMware Professional 14 Pro

 Prerequisite

  •  Windows Server 20H2
  • VMware Tools installed - mount the installer (Menu | Install VMware Tools...)
  • PS C:\>setup.exe /S /v "/qn REBOOT=R ADDLOCAL=ALL"
    PS C:\>shutdown /t 0 /f /r
    
  • Enable nested virtulization on the VM
Install WSL2 Ubuntu 20.04
PS C:\>dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
PS C:\>dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
PS C:\>shutdown /t 0 /f /r
PS C:\>#Wait for the reboot to complete
PS C:\>Invoke-WebRequest https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi -OutFile $HOME\Downloads\wsl_update_x64.msi
PS C:\>cd $HOME\Downloads
PS C:\>msiexec.exe /i wsl_update_x64.msi /quiet /qn
PS C:\>wsl --set-default-version 2
PS C:\>curl.exe -L -o ubuntu-2004.zip https://aka.ms/wslubuntu2004
PS C:\>md C:\Distros\Ubuntu2004
PS C:\>Expand-Archive ubuntu-2004.zip C:\Distros\Ubuntu2004
PS C:\>cd C:\Distros\Ubuntu2004
PS C:\>.\ubuntu2004.exe

You will be prompted to install and create a user account in Ubuntu. And you should be all set. 

To open wsl2 again, do:

PS C:\>.\wsl.exe -d Ubuntu-20.04

Keywords:(WSL2, Ubuntu, VMware Workstation)

Sunday, January 03, 2021

iftop shows qqqq under tmux

 Running iftop in tmux shows qqqq for the border, like below.




To fix this do:

$: sudo TERM=xterm iftop

Tuesday, December 29, 2020

Monday, September 07, 2020

Check if package is installed in Ubuntu/Debian/Mint

To check if a package is installed on Ubuntu/Debian/Mint, do:

$: dpkg -s dkms

This will display information if dkms is installed.

Reference(s):
http://www.cyberciti.biz/faq/find-out-if-package-is-installed-in-linux/


Monday, July 27, 2020

How To: Consume COM server in Common Lisp

How To: Consume COM server in Common Lisp Goal: Simple example to consume COM server/object using Common Lisp Version info: - OS: Win...