VNC Server Setup on Rocky Linux 8.4 (Red Hat 8.4 Variants)

These instructions worked for me on Rocky Linux 8.4. The configuration instructions for various Red Hat 8.X VNC server setups have varied substantially over the 8.X versions.

These instructions do not involve setting up an encrypted data channel. Only use this setup on a known secure local network or consider using a SSH tunnel between the client and server.

The graphical system needs to be running at bootup:

systemctl set-default graphical.target

Install the VNC server binaries:

dnf install tigervnc-server

Configure the firewall to accept connections to the port:

Note: The following steps are done per user changing the port number for each user: ‘1’ = port 5901, ‘2’ = port 5902, etc.

 firewall-cmd --get-default-zone
 firewall-cmd --permanent --zone=public --add-port 5901/tcp
 firewall-cmd --reload 

Create the VNC user password:

 su - <username>
 vncpassword   
     Note: View Only = "n" 

Create a port mapping per user:

 echo ':1=<username>' >> /etc/tigervnc/vncserver.users

Create a systemd unit file:

 cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service 

Enable and start the VNC service:

 systemctl enable vncserver@:1.service
 systemctl start vncserver@:1.service 

Get server status:

 systemctl status vncserver@:1.service 

What Domains(VM’s) are Using what Hard Drive Volumes in KVM/Libvirt?

I noticed in my well-used test KVM virtual environment that I had a few volumes that had different names than did the existing domain (VM) names. I also noticed that I had more volumes than domains. So how do I tell which volumes are being used by which VM? And how can I tell what volumes are orphaned? Note for path purposes, my host is running Ubuntu 18.04.

I tried several “virsh” commands and spent time looking in the man pages. Nothing stood out so here is what I ended up doing.

First: I needed to list and locate the volumes in the “default” pool:

virsh vol-list --pool default

This also provides the path to the “default” pool where the volumes are located. I also noticed that I had a volume listed that was not shown when I did “ls -l” on the “/var/lib/libvirt/images/” directory. No problem, just update the pool listing:

virsh pool-refresh default

Solved that problem. Now I need to tie the volumes back to the VMs:

virsh dumpxml "my vm name"

That works but is cumbersome for multiple VMs and multiple volumes. So where are the VM configuration files located? A quick look around the directories where the volumes are stored turned up nothing, so best guess is /etc:

grep - ir "my vm name" /etc

That returns “/etc/libvirt/qemu/” and looking in that directory indicates we have found the VM config files. So now I need a list of VMs and their associated volume drives. Note that I am literally grepping for “source file” here:

grep -i "source file" /etc/libvirt/qemu/*

That allows me to tie the VM names to volume names that don’t match.

Now I can double check to make sure that a volume is or is not associated to a VM:

grep -i "name.qcow2" /etc/libvirt/qemu/*

Locating a Preconfigured “ls” Alias in CentOS Using grep

Linux distributions sometimes configure “ll” (lowercase L’s) as an alias to “ls -l”. Debian based OS’s typically do this from the users ~/.bashrc file. This is not the case with Red Hat/CentOS based OS’s. I couldn’t remember where CentOS set the alias and I needed to locate it. As a non-root user, this proved to be a little more challenging than I first expected. Yes, I could look it up on the web but I decided to make an exercise out of it and it was more challenging than it would first seem.

grep -riE "alias ?ll" /etc/ 2> /dev/null

I’m sure there are other ways to it but this worked. In short. I knew I needed to search for “ll” in /etc, but “ll” is also common in many words. Also, I’m running as a normal user so I wanted to avoid “Permission Denied” and other errors that cluttered the search.

Note the the following also returns the same:

 grep -riE "alias ?ll" /etc/ 2>&1 | grep -v "Permission"