Tag Archives: Ubuntu

Adjust the Screen Resolution of an Ubuntu Hyper-V Virtual Machine

I use Ubuntu for a lot of the courses I teach, due to its popularity. While I have some computers running it “bare metal” as they say, in order to test different scenarios, as well as record my Pluralsight courses, I also setup virtual machines within Hyper-V.

It’s a bit annoying though, as it doesn’t seem to allow the guest extensions to easily resize the VM. (I create my VMs from the downloaded ISOs as opposed to using the pre-built images in the Hyper-V store). But it can be done! All you need is a few quick edits to the grub file.

Start by opening up a terminal window. Then you can use your favorite editor to open the grub file. I’m using VIM in this example, but you could substitute nano or another text editor of your choice. (I’ll assume you know how to use your editor to edit and save changes.)

sudo vim /etc/default/grub

Now scroll down and find the line that begins with GRUB_CMDLINE_LINUX_DEFAULT. To the end of it, append the following string:

video=hyperv_fb:1280x720

Or use 1920×1080, 2560×1440, or whatever resolution you prefer. The line should look something like the following, all on one line without any wrapping.

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1280x720"

Looking good, but you’re not quite done yet. You’ll need to append the same to the next line so it looks similar to the following, again all on one line with no wrapping.

GRUB_CMDLINE_LINUX="quiet splash video=hyperv_fb:1280x720"

Of course, you’ll want to make sure the resolution you select matches on both lines, 1920×1080, etc.

Now save the contents and exit your editor.

Next, and this is an important step, you have to update grub using the following command:

sudo update-grub

If you skip this step, you won’t see your resolution updated.

Finally, you’ll need to reboot. I’ve not had great success with doing a reboot of Ubuntu running in Hyper-V, it frequently hangs, so I suggest doing a power off, then start Ubuntu again in Hyper-V.

When it does reboot, you should be running at your new resolution.

Getting Started with PowerShell Core on Linux and macOS

My newest course, Getting Started with PowerShell Core on Linux and macOS, is now live on Pluralsight! This course is my eighteenth in a long line of Pluralsight courses.

I begin the course explaining the difference between PowerShell for Windows (version 5.1) and the all-new PowerShell Core (version 6.2 was used for this course), which works not only on Windows but on Linux and macOS as well. I then show how to install PowerShell Core, along with a few other key components such as Visual Studio Code, on both Linux and macOS.

Not familiar with PowerShell? No problem! I quickly cover the basics of PowerShell including cmdlets, the use of the pipeline, how to write functions, and how to put those functions in reusable scripts.

As if that weren’t enough, I show how to do some “cool things” with PowerShell Core, including working with Docker containers, SQL Server, and Azure.

For the course, I primarily used Ubuntu 19.04 and macOS Mojave. The code was also tested on Ubuntu 18.04 LTS and 18.10, as well as macOS High Sierra. In addition, I tested the Linux installs on a variety of distributions including CentOS, Manjaro, and more. The samples include markdown files with information on how to install on these other distributions.

All of the samples are included in the downloadable components of the course on Pluralsight. New with this course I have the samples also available on my GitHub site. As I move into the future the GitHub codebase will be updated with new samples and information.

Also included in the samples are several markdown files that have additional information not included in the course, such as setting VSCode on Windows to use PowerShell Core instead of Windows PowerShell 5.1 as the default terminal.

While you are up on my GitHub site be sure to check out the full list of repositories, I have a lot of examples on it, including some from previous courses such as my recent Reporting Services course. (For a full list of my courses just check out the About ArcaneCode page on this site.)

Note the sample file on Pluralsight will remain static, so if someone watches the course their samples will reflect what is in the course. For the latest updated samples see the GitHub site referenced above.

What? You don’t have a Pluralsight subscription yet? Well, no worries dear reader, just email me, free @ arcanetc.com and I can send you a code good for 30 days with which you can watch all 18 of my courses, plus anyone else’s course at Pluralsight.

Setting Your Ubuntu 18.10 Favorites Bar In A Script

Of late I’ve been setting up and tearing down a lot of Ubuntu virtual machines as part of a PowerShell Core on Linux and macOS course I’m working on for Pluralsight. I wanted to create a script to install everything I need in one fell swoop so I could start testing my PowerShell Core code on a new box.

The one thing that annoyed me though was the Ubuntu Favorites bar on the left. I wanted to be able to add and remove my favorited automatically, rather than manually setting them up each time.

I didn’t think it’d be that hard, but it took a surprising amount of web searching to find the correct answer.

From inside a bash terminal session, you can issue the following command:

/usr/bin/gsettings get org.gnome.shell favorite-apps
(If /usr/bin is in your path, which it likely is, you could omit that part as we’ll see in a moment.) This will produce an array containing a list of your favorites.
['ubiquity.desktop', 'firefox.desktop', 'thunderbird.desktop', 'org.gnome.Nautilus.desktop', 'rhythmbox.desktop', 'libreoffice-writer.desktop', 'org.gnome.Software.desktop', 'yelp.desktop', 'ubuntu-amazon-default.desktop']
I’ve seen all sorts of suggestions on how to update the array, Use Python, Ruby, you could even use PowerShell to rearrange it if you wanted. To be honest though, I took the simple approach.
I just set my favorites manually, one last time. That way I could let Ubuntu tell me the correct application names to use in the background, without having to hunt them down. Once I had them set, I simply ran the gsettings get command (see above) again to get the list of apps, in the order I wanted them.
I then used gsettings again, this time in set mode.
gsettings set org.gnome.shell favorite-apps "['firefox.desktop', 'org.gnome.Terminal.desktop', 'org.gnome.Nautilus.desktop', 'code_code.desktop', 'azuredatastudio.desktop', 'org.gnome.Software.desktop', 'yelp.desktop']"
Just add this to your setup bash script, or enter it at the terminal, and ta-da! Your favorites are now setup like you want.
Naturally all of this is entered as a single line, this is just wrapped here due to space. Also, these are the favorites I want for my situation. Rather than just copy and pasting above, follow my suggestion to set things up manually, then use the output of gsettings get as input for the set.
I have tested this in Ubuntu 18.10, in theory it should work in 18.04 as well. I would imagine it would also work in 19.04 when it’s released, I’ll come back and update this post once I’ve had time to test it.