How to Change Console Fonts In Ubuntu for 4K Screen

Recently I bought HP Spectre x360 Convertible that has a fantastic crisp 4K screen. Using CTRL+F1 (upto F6 usually) one can access console. With 4K screens now becoming available the default font size becomes really minute and one would need to increase it somehow. gnome-terminal provides shortcut SHIFT+CTRL and plus key (+) to increase font size when needed, or profiles which can be changed. But with console something more is necessary. Font used in the console is monospaced and is not the same as the tt or otf fonts used for document and browsers. In addition, there is also a limited selection fonts and sizes to choose from. So here is how to do that. Go to a console and login. Following command has to be run as root or using sudo.

sudo dpkg-reconfigure console-setup

Leave the first two screen settings as is. On third one you will see list of Font styles as Fixed, Terminus (and its variations), VGA and few others. Fixed is the default one and at least for me its biggest font size was still small for me. So I used VGA. Terminus looks fantastic but as the warning says it is not good for programming because of the way some of characters are represented. So select VGA and move to next screen. Select the biggest font and press enter. Within few seconds change will take effect. Try other font styles and sizes to suit your need.

HP Spectre x360 convertible and Linux

For a while I was mulling to buy an ultrabook. 13.3″ screen, less than 3 LB and powerful. Came across HP Spectre x360 convertible that supports upto Core i7 8th gen, 16GB RAM, upto a terabye SSD, Beautiful UHD Touch Screen, Tilt Pen support, FingerPrint Scanner and best of all tablet like features where one can fold the laptop full 360 degrees.

Next step was to find if it can run Linux. Certainly it can but requires non-free drivers like for Intel wifi. So I tried live-cd of Ubuntu 18.04. And viola all worked. So first I went back to windows, migrated windows installation to create a disk partition for Linux. Finally installed Ubuntu. The Spectre boots so fast that for first time I thought it was only waking up from Standby but it was full boot and felt like instant ON. Another great thing is the battery life. So far I am able to get more than full day worth of work done on single charge. Keyboard is great. Only things that do not work on Ubuntu yet are the Fingerprint scanner and HP IR Camera. But those are the things I can live without for now. Intel Wifi is so fast that now I finally have a wifi device at home that can give me 100MBps download as advertised by Optimum (my ISP).

It even came with a folio/soft cover to secure my device from scratches when traveling. That was one unpublished feature (or maybe I missed it). But that was a pleasant surprise.

Now comes to the cost. I loaded the system to max except for the SSD. So I got Core i7 8th Gen, 16GB RAM, 512GB SSD, UHD Touch Screen and HP Tilt Pen. Original cost about USD 1550. With discounts etc price dropped to 1333.33 (including Tax etc). So I went to Raise.com and found few gift cards that were already selling for cheap. Saved another USD 50. Shipping was after about a week of order. During that time price dropped for the same device by USD 30. So I called HP for a pricematch and they obliged. So I ended up paying USD 1300 only. And later on because I used Ebates and they have 10% off cashback I got another 125$ back (price before tax). You cannot go wrong with that. I selected for the regular shipping but Fedex ended up delivering in 2 days after it was shipped. So there you have it. You can have the cake and eat it too :-).

I will go on adding my posts here for the experience with Linux and tweaks I had to do perform in order to use the hardware to its full scope.

Suspend button in Gnome3

The button is not visible with shutdown and logout buttons. But by pressing ALT key the Shutdown button changes to Suspend/Pause button in Gnome3. No need to install a plugin to find it. Just a keystroke.

Compare files ignoring a field or column using Process Substitution

Lets say the data contains multiple fields/columns separated by space or comma or some other delimiter. And we want to compare two files ignoring a specific column. Lets divide work in two small issues. First is to ignore the provided field/column.

If we simply want to ignore the first column, we can use one of the following cut constructs.

cut -d',' -f 1 --complement datafile
cut -d',' -f 2- fileName.csv

If we want to ignore a specific one we can use awk in following manner which is much more generalized because you can specify which column to ignore, be it first, third or last.

This can be used as

awk -F',' -v FieldToIgnore=3 -f ignoreField.awk datafile

Next part is to diff the output after ignoring (read removing) the column. That is where process substitution comes handy. Here are two examples.

# ignore 1st column from two csv datafiles while comparing
diff -u <(cut -d, -f 2- datafile1) <(cut -d, -f 2- datafile2)
# ignore column 3 from two csv datafiles while comparing
diff -u <(awk -F',' -v FieldToIgnore=3 -f ignoreField.awk datafile1) <(awk -F',' -v FieldToIgnore=3 -f ignoreField.awk datafile2)

So instead of giving it two real files, we give it two redirected streams. Same solution can be used to pre-process files differently (e.g. ignore any comments or empty lines or compare two unsorted files).

See below for more information on Process Substitution.
http://www.tldp.org/LDP/abs/html/process-sub.html
http://wiki.bash-hackers.org/syntax/expansion/proc_subst

Application Logging Improvement – Part 3 Making it Readable

This is part three of my Application Logging improvement plan. So far I have discussed that log should be machine readable for application performance, management and monitoring. In this post I give an example of how to make the log readable to human (or make the log just like everyone has been used to seeing them). I am going to use vim to view the log files and have it configured so it knows how to handle the file with syntax etc.

First thing is configure vim to recognize the format. Continue reading “Application Logging Improvement – Part 3 Making it Readable”

Application Logging Improvement – Part 2 Multithreading

Multi-threading is now becoming a norm. Obvious issue with logging is how to synchronize between threads. As discussed in last post Application Logging Improvement Plan – Part 1, we want to log as much as possible in machine readable format. So there comes a problem with multiple threads trying to log at the same time. Two possible implementations come to mind but both are flawed.

  1. Synchronize between threads for logging – Disk writes are slow and now locking contention would only make it worse. This slows down the business logic and is a big no-no.
  2. Log without synchronizing – Business logic works but logs get jumbled up because multiple threads are trying to log at the same time. This leaves logs in worst shape and unusable.

We can do better by combining both of above to get a solution. We will create a per thread logging buffer (lets call it LogBuffer) where each thread would log without any conflicts. And at a certain threshold, threads synchronize and log their LogBuffer to the disk (lets call this Flush).  Continue reading “Application Logging Improvement – Part 2 Multithreading”

Application Logging Improvement Plan – Part 1

People are divided on how to log, what to log, how much to log. A never ending discussion this is. In addition many open source libraries are available for logging. Not to mention many standards. I am not going to go in details of what is available out there. Use Google to pick your poison. What I am going to discuss here is what I think makes most sense with available technology.
Continue reading “Application Logging Improvement Plan – Part 1”

mimikatz : Export non-exporteable Private certificate from Symantec PKI

Recently our organization started to provision Private certificates using Symantec Managed PKI Service. It has lot more appeal for IT admins because it takes out all user intervention which always creates support nightmares.

Previously I had direct access to the private key so it was easy to export it to all my devices and use for VPN and other secure stuff that needed to verify that I am indeed the real user. Because Symantec PKI is not available for Linux, it broke the VPN access from my Ubuntu system. Naturally I started to look for ways to export the key out of windows system. So here is what I did to get me out of the bind.

How to export certificates

First I installed Symantec PKI client on a windows 7 system. That was a no brainer because there was no other choice. I did not try with Windows 8 so YMMV. The main issue was that Windows certificate manager showed that the private key was not exportable. If it was then my quest would have been over right there. But I had to take another step. Mimikatz was the answer which marks them exportable and also allows to export them. Note: The patching that it does only lasts for that session. Once you reboot windows system you have to patch again using mimikatz. I used latest version which is 2.0 at the writing of this post. Continue reading “mimikatz : Export non-exporteable Private certificate from Symantec PKI”

Setup WebEx on 64 bit Ubuntu 12.04 using 32 bit Oracle Java

WebEx would not work on Ubuntu 12.04 64 bit with default configuration. It requires 32 bit java. WebEx control window would launch but desktop sharing, application sharing, white-board etc. do not show up. Neither I could see other people’s shared content nor I could share mine even if I am the host of the meeting.

Starting Firefox from command line on a terminal shows ELFCLASS32 error from WebEx shared objects. So it was clear that WebEx would not work on 64 bit system as is and would need 32 bit java to work. Because I use 64 bit system I do not want to downgrade to a 32 bit version just for the sake of WebEx.

In brief, these three steps cover the fix.

  1. Install 32 bit Oracle Java locally. Oracle Java is must and OpenJDK would not cut. Warning: because it is local installation, user would need to manually keep on updating as new java becomes available. Recently there have been many releases from Oracle which came with very little time in between addressing major security issues so this would be concerning.
  2. Install Firefox locally so it can be configured to use this 32 bit java. Add a different profile and use a different theme so it does not conflict with the native Firefox and clearly stands out if both are running.
  3. (Optional) Add shortcut in Unity HUD for quick access.
    Continue reading “Setup WebEx on 64 bit Ubuntu 12.04 using 32 bit Oracle Java”

Add a custom script in Unity HUD

Here is how to add a custom script in Unity HUD/dash for quick access. /usr/share/applications directory has all shortcuts for Unity desktop. So create a file named “mycustomscript.desktop” (or any_name_you_like.desktop) there which has information about the custom script. Additionally an icon could be added by pointing to an image. Files in /usr/share/applications directory have to be created as root.

 [Desktop Entry]
 Version=1.0
 Type=Application
 Terminal=false
 StartupNotify=true
 Icon=/home/vishalj/Pictures/mycustomscript.jpeg
 Name=MyCustomScript
 Comment=My Custom Script for X, Y and Z
 Exec=/home/vishalj/scripts/mycustomscript.sh
 Categories=Application;Productivity
 

Then run sudo update-desktop-database after which you will be able to use Unity HUD for invoking the custom script. Also note that each time you update a .desktop file you have to run update-desktop-database.