Quit a program on Ubuntu with Alt + Q

It has been just over 3 weeks since I  started using Linux as my daily driver. It hasn’t been an unpleasant experience – although there have been tweaks and fixes along the way.

Instead of bringing over something from Windows that I am so used to having; today’s tweak comes from the Mac – where you can use Command (⌘) + Q to quit a program. This is mush more elegant than Alt + F4 on Windows and Ubuntu.

On my Microsoft 600 Keyboard Alt + Q feels very much like Command (⌘) + Q on the Mac – so I will go with that.

First of all I will remove the old keybinding for Close Window. This can be done by entering the following into a Terminal window.

gsettings set org.gnome.desktop.wm.keybindings close "@as []"

Now I will add the keybinding for Alt + Q. This can be done by entering the following into a Terminal window.

gsettings set org.gnome.desktop.wm.keybindings close "'<Alt>q'"

You can now quit programs on a PC running Ubuntu the way the Apple Corporation running under Steve Jobs intended.

Or close enough to it!

Minimise windows on Ubuntu 18.04 with Super + M

This has turned somewhat into a series of blog posts outlining my transition to Linux as my daily driver. I’m not new to Linux, and have run various variants of Linux on servers (Slackware and Ubuntu mostly). The desktop experience has been a little different as there are certain things I have been so used to on Windows – and I don’t like too much change all at once!

These steps may carry over to other versions of Ubuntu. I will now show you how to Minimise windows on Ubuntu 18.04 with Super + M.

This post will go though changing the ‘minimise all windows’ keyboard shortcut from Control + Super (Windows Key) + D to Super (Windows Key) + M.

Super + M by default on Ubuntu 18.04 opens the Message Tray. The Message Tray can also be opened with Super + V.

First up I will remove the key bindings for ‘toggle message tray’. To do this open Terminal and run the following command:

gsettings set org.gnome.shell.keybindings toggle-message-tray "@as []"

This will  remove the key bindings for both Super + M &  Super + V. We can re-add Super + V so we still have a keyboard shortcut for the message tray with the following command.

gsettings set org.gnome.shell.keybindings toggle-message-tray "['<Super>v']"

Now to add Super + M to minimise windows.

gsettings set org.gnome.desktop.wm.keybindings show-desktop "['<Super>m']"

You can now minimise all open windows the way the 90’s Microsoft Corporation intended.

Fixing the Calculator Key in Ubuntu 18.04

Recently I decided to give Ubuntu 18.04 a go as my daily driver. I have slowly been finding things that do not work as expected, and will blog about them here.

So far I’ve found there was no date in the top bar, my printer doesn’t work, and sudo didn’t curse me if my password was entered incorrectly.

This time my issue is the calculator keyboard shortcut on the Microsoft Wired Keyboard 600, doesn’t open the Calculator. I use this key many times a day, and eventually got sick of searching calc in the Application menu.

I did a bit of Googling and found this post on askubuntu.com, It appears to be a common issue on Ubuntu 18.04 – and fortunately it is a simple fix. Here is a link to the bug report.

The issue looks to be with the gnome-calculator snap package. To fix the issue, first we need to remove gnome-calculator and reinstall it using apt. Type the following commands into a terminal window.

sudo snap remove gnome-calculator

followed by

sudo apt install gnome-calculator

The keyboard shortcut for the fancy abacus will now work as the mighty Sumerian and Egyptian empires intended.

Holiday Season maintenance for Family and Friends

The holiday season is quickly approaching – during which, many of us will visit (or be visited by) family and friends. If you’re employed in any role that involves using a computer you will no doubt be bombarded with technical questions over the silly season.

This is just a few simple tasks I’ve put together to help family and friends have a better computing experience and be more secure – and possibly save you from having to remove the same junkware from their machine again next holidays.

Windows

  • Remove the junk: AdwCleaner seams to clean up most of the rubbish that users manage to install. It is offered for free by Malwarebytes.
  • Run Disk-Cleanup: If it hasn’t been done for a while, it will free up quite a bit of disk space.
  • Ensure operating system is up to date: No doubt there will be many friends or family members saying their computer “isn’t going to work” after January. Time to upgrade to Windows 10. If Windows 10 is out of their price range check out Ubuntu (Or Lubuntu for older hardware).
  • Install Google Chrome (If you are Privacy conscious maybe look at Mozilla Firefox).
  • Install uBlock Origin & HTTPS Everywhere
  • Modify the HOSTS file using the HOST file from someonewhocares: It might break the advertising links at the top of a Google search if this is going to be a problem.
  • Ensure AV is up to date: Use a paid AV if possible (I recommend ESET) If paid is not possible ensure Windows Defender is enabled on Windows 10.
  • Create a new Administrator account: and set the main user as a Standard user. Don’t keep the password to yourself, otherwise you will get many phone calls from your family and friends every time they need to change a setting. Running as a standard users prevents malware or other nasties from running as administrator as they stealthily try to execute in the background.

MacOS

  • Install latest patches for macOS: If device is too old and slow (or running an unsupported OS) consider installing Lubuntu.
  • Install Google Chrome (If you are Privacy conscious maybe look at Mozilla Firefox).
  • Install uBlock Origin & HTTPS Everywhere
  • Create a new Administrator account: and set the main user as a Standard user. Don’t keep the password to yourself, otherwise you will get many phone calls from your family and friends every time they need to change a setting. Running as a standard users prevents malware or other nasties from running as administrator as they stealthily try to execute in the background.
  • If using a Mac ensure the inbuilt firewall is enabled.

iOS

Turn on Passcode or Face ID: Settings > Touch ID & Passcode (Face ID & Passcode) > Turn Passcode On.

Turn on Automatic Updates for iOS: Settings > General > Software Update > Automatic Updates = On.

Android

Passwords

Talk about Passwords: Yes Passwords suck, but sucky passwords suck more. Teach them about diceware. Need a gift idea? Buy a family member a diceware password. Help to setup a password manager. KeePassXC works well, and I have had many clients find 1Password nice and easy to use.

Help configure 2FA – You probably don’t want to setup up all their accounts with 2FA but perhaps start with important things like email and banking. If you have a tech savvy friend or family member perhaps a YubiKey would be a good gift.

If I have missed anything feel free to let me know and I’ll add it!

Turn on Sudo Insults

As part of using Linux as my daily driver, there are certain things I like having on my Servers that I can now have on the Desktop. i.e. Sudo Insults.

‘Sudo insults’ swaps the ‘incorrect password message’ for a funny one-liner, or better – an insult – when you have incorrectly entered your password using sudo.

To enable insults we need to edit the sudoers file. This should always be done using visudo. To edit the sudoers file enter the following command:

sudo visudo

Add the following line under Defaults env_reset

Defaults insults

Save your file and exit.

You will now be insulted when you incorrectly enter your password, just as the Unix beards of old intended.

Show date in Ubuntu 18.04 top bar

I have recently starting running Linux as my daily driver. Of course, after using Windows almost every day of my working life, there are things that I am used to just having. In this case a quick option to look at the date along with the time.

By default, Ubuntu 18.04 shows just the time. You can click on it to view a calendar and see the day. Sometimes you just want a way to quickly see the date (for the 11th time that day and you still cant remember what the date is). To enable the date I have installed Gnome Tweak Tools and then used dconf to see what has been changed when I use the GUI to make changes, so that it can just be done easily in Terminal.

Start by opening Terminal and then enter the following commands:

sudo apt-get update
sudo apt-get install gnome-tweak-tool

GNOME Tweak Tool will now be installed. You can open the GUI for GNOME Tweak Tool by clicking the Show Application button at the bottom left of the screen and selecting Tweaks

The Date can easily be added to the top menu by running the following command:

gsettings set org.gnome.desktop.interface clock-show-date true

You now have the date displayed alongside the time – Just as Chronos intended.

Linux as my daily driver

I recently retired the first Linux server I had ever configured. It was only a simple server – Slackware running Samba as a network share. It was pretty low maintenance, but it was where I had learned and practiced my Linux skills.

I found myself in a position where Windows Servers now outweigh my Linux servers, and as a way to keep my Linux skills sharp – I thought, why not run Linux as my daily driver?

I picked Ubuntu 18.04 LTS. I have used Ubuntu before, but mostly Ubuntu Server. Last time I used Ubuntu Desktop, the distribution was still using Unity. It was not my cup of tea. Ubuntu 18.04 uses GNOME Shell instead – which I do find is a little better.

So far I was off to a good start. Many programs I use work on Windows, Linux, and Mac. So these things moved over smoothly. One major issue I had right off the bat, was my printer doesn’t work, and drivers for my fax modem (yes I still need to send the odd fax), wouldn’t work either. I’m sure this is something I will sort out over time.

So wish me luck as I go down the new path of Linux on the desktop. I will keep this post updated with my experiences on making Linux my daily driver.

 


Quit a Program on Ubuntu with Alt + Q

Minimise Windows on Ubuntu 18.04 with Super + M

Fixing the Calculator Key in Ubuntu

Turn on Sudo Insults

Show Date in Ubuntu 18.04 Top Bar

Use NotePad ++ like Vim with ViSimulator

If you come from a *nix environment, you would at some stage used Vi or Vim. Some people love it, some people hate it. While I am not a Vim power user, I do find the keyboard shortcuts come in very handy.

On Windows my editor of choice is Notepad ++. As the name suggests it is a “plus” version of Windows Notepad. I won’t go into details of Notepad ++ here, but you can visit their website to find out more.

To make Notepad ++ feel more like Vim we can install the plugin, ViSimulator. This can be enabled via the Plugins menu.

From the Plugins menu navigate to Plugin Manager & click Show Plugin Manager.

Scroll down the list until you see ViSimulator for Notepad ++. Tick the box and then click install.

Notepad ++ will require and restart, follow the prompts to restart now.

Once Notepad ++ restarts you can now enable ViSimulator.

To do this Click the Plugins Menu, navigate to ViSimulator, and then click on Enable ViSimulator.

You can now use Vim commands in Notepad ++

Don’t worry you can still quit the program by clicking the X!

Diceware Passphrase Generator

Update:

Python 3 Version can be found on GitHub.

Diceware Passphrase Generator – Python 2.7

It has been a while since I have done anything with Python so as a quick easy ‘get back into it’ I though I would create a Diceware Passphrase Generator. This is not a truly secure implementation as I am only using the python random function, as this quote from the Python Document Library explains:

Warning: The pseudo-random generators of this module should not be used for security purposes. Use os.urandom() or SystemRandom if you require a cryptographically secure pseudo-random number generator.

diceware passphrase

I will be modifying the script to use the os.urandom() function and will post it here when I do.

The wordlist I used can be found here; more information about Diceware Passphrases can be read here.

And here is the code:

import random

def dicenumber():
    diceout = ""
    for i in range(5): # 5 dice rolls
        diceout += `random.randint(1,6)` # add result of dice roll to variable
    return diceout

def diceware(x):
    wordlist = open('diceware.wordlist.asc', 'r')
    for line in wordlist:
        if line.startswith(x):
            wordlist.close()
            return line

for i in range(4): print diceware(dicenumber()), # increase number for longer passphrases

Simple disk repartition and format with diskpart

Disclaimer: These steps will wipe the hard drive permanently. If you need to keep the data create a backup first.

At an elevated Command Prompt/PowerShell type diskpart. This will bring up diskpart utility. Diskpart allows you to manage disks, partitions, and volumes. Diskpart is ready when you can see DISKPART> on the Command Prompt/PowerShell window. We can now repartition and format the hard drive.

  • First identify the disk you wish to repartiton. To do this type list disk. The disk will be identified with a number. i.e. Disk 3.
  • Select the disk by typing select disk 3 or whatever number corresponds with your drive.
  • Type list partition to view the current partitions. Make note of the  partition/s you wish to remove. i.e. partition 1.
  • To remove a partition first type select partition 1, or whatever number corresponds with the partition you wish to remove.
  • Delete the partition by typing delete partition. This will remove the currently selected partition. Repeat for multiple partitions.
  • Create a new partition by typing create partition primary. Your new partition is created and ready to format.
  • Format the partition by typing format fs=ntfs label=”Local Disk”. The drive will now be formatted. If you requrie a qucik format you can type format fs=ntfs label=”Local Disk” quick

Your hard drive is now formatted and ready to use.