Search This Blog

Showing posts with label error. Show all posts
Showing posts with label error. Show all posts

Monday, 17 October 2016

Using a USB Serial cable on Ubuntu (without needing to sudo)

For those who know me, my views on using Windows as a desktop environment are well known. I wouldn't say it was necessarily a bad thing, it works for a great number of people, but for those of us in the world who care about freedom, choice and the greater good, then there are numerous alternatives.

My house is filled with precisely one laptop, and that's a Chromebook. I'm fairly well invested in the Google ecosystem, and it works well for me.  My company however have provided me with two laptops, one for doing my company business (e-mails, documentation, and the like), and one for conducting business on customer sites (networking tasks mainly).

My networking laptop was handed to me with Windows 8.1, as was the company standard at the time, and I subsequently (read very quickly) removed Windows and installed Ubuntu Gnome. I love Ubuntu Gnome, I find it to be a very clean, efficient and fast operating system, and works perfectly for my needs. When there is a need to do anything "Windows-ish", I have a VirtualBox VM running Windows 10.

Now, I'm a networking man, and my terminal emulator of choice has always been PuTTY. One of the annoyances I find with PuTTY is that as a user or administrator on an Ubuntu system, you need to run PuTTY using a sudo command to avoid the application showing the error message "Putty Fatal Error: Unable to open connection to: Unable to open serial port" when PuTTY tries to interact with the USB Serial Port. This can be worked around by launching a terminal window within Ubuntu, and running the following command:

sudo putty

This is all well and good, and will get you round the issue without any problems.  However, for me, this always seemed like an unnecessary obstacle to me getting my work done.

After a little investigation, I found that when I connect my USB Serial port to my laptop, it gets installed on Ubuntu as a device called /dev/ttyUSB0, and this device is a member of a group called "dialout", as shown in the screenshot below:



This theoretically meant that if my user account were a member of the "dialout" group, it would have the relevant permissions to access the port.  I checked my group membership be running the command "groups"



As I suspected, there is no reference to the group "dialout" in my list of groups.  By running the following command, I was able to add the "dialout" group to my list of groups.

sudo usermod -a -G dialout david

You need to log out and then back in to apply the changes.  When you the run the command "groups", you will see that "dialout" in the list of groups.




This too should work for you, if you substitute my username above "david" for your own username on the system.

Just for your information, the above command is broken down to illustrate what is happening:

sudo: run the following with highest privileges
usermod: invoke the user modification program
-a: specifies that usermod should be adding an entry
-G (note the capital G): specifies that what follows is an addition to an existing group
dialout: this is the group to which a user should be added
david: is the user who should be added to the above group

I hope this helps someone
Have a nice day
Dave

Friday, 21 March 2014

Windows, hey? Who'd have it...!?

I long for the day when I'm in a job where I can abandon Windows as the Enterprise Operating System of choice, and switch to a more stable, more reliable and generally quicker Operating System. With more firms moving to the likes of Ubuntu and Mac OSX, and Cloud Services becoming more prevalent I can't see any reason why Windows needs to be the de facto standard for Enterprises any more.  This being said, I am unfortunately stuck with it.

The 'it' being Windows 7, which I'll admit is my second favourite Windows OS of all time (Windows 98SE sits at the number one spot), and has been a solid OS since it's release in 2009.  I found a very strange quirk in Windows 7 a few months ago after an update.  I'm afraid I don't know which of the updates was involved as they're all managed by my employers IT team.  This update somehow removed all of the default entries in the Windows Sounds dialog box.

This meant that all of the default Windows beeps, clangs and donks were gone. Not only that, but all of the Microsoft Outlook mail notification sounds and the Microsoft Lync ringtones as well.  This is quite an inconvenience when you need to explain to your boss why you haven't been answering the phone or any e-mails.

Being the tinkerer that I am, I checked the Windows Sound dialog from Control Panel and found an entirely empty list.

What the...?

The IT Team mentioned above were a tad stumped and could offer no real solution short of a rebuild of the laptop. As much as I understand the many benefits of a full rebuild: the speed increase for one, and the resulting tidiness of the desktop, I didn't much fancy the idea of going through the usual headache of backup and restore jobs and the inevitable items which get forgotten.  I thanked the team for their time, and decided to go it alone. Thanking my lucky stars that my employer trusts me with administrative rights on my machine.

After a few minutes of Googling, I managed to identify that the Sound Dialog draws its listing from a Registry Key, namely:
HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\
When navigating to this Key in my own registry, I could see that it was devoid of entries.

Rather than scouring the internet looking for a dodgy registry file to download, I decided to fire up VirtualBox, and using my Windows 7 DVD I installed a fresh OS onto a new Virtual PC.  Once this was up and running I configured a Shared Folder to enable me to share files between my PC and the new virtual machine.

Navigating the registry in my fresh Windows 7 OS, I exported the above registry key to the Shared Folder.  Back on my broken PC I found the exported registry file and imported it into my registry. A quick reboot later, and all my sounds were back, as good as new.

If you don't have the time, inclination or know-how to try this yourself, you can download the registry file I exported from Google Drive.