Thursday, 28 November 2013

Going back to a previous directory in the Linux terminal

 A little cd trick to cd back in Linux terminal history:
 cd -  

So useful I had to share!

Wednesday, 27 November 2013

Adding Syntax Highlighting to Linux less

Install source-highlight:
 sudo apt-get install source-highlight  

Add the following two lines to~/.bashrc
 export LESSOPEN="| /usr/share/source-highlight/ %s"  
 export LESS=' -R '  

Now source files opened with less will be nicely syntax highlighted. source-highlight supports many languages - see
 source-highlight --lang-list  
for a full listing.

Tuesday, 7 May 2013

Using Nautilus file manager with Enlightenment window manager

I'm a fan of Bodhi Linux, which uses the Enlightenment window manager and is pretty speedy on all kinds of hardware. Unfortunately however, the built in file manager isn't yet fully functional in my opinion. As Dropbox has a dependency on Nautilus, I've integrated that into Enlightenment as the primary file manager.

To do this, we need to start Nautilus with the --no-desktop option. Start by making moving /usr/bin/nautilus to /usr/bin/nautilus.original, and create a new script at /usr/bin/nautilus containing the following command:
 nautilus.original --no-desktop $@ &  

The $@ expands any passed arguments, allowing the use of the script as if it were the original Nautilus binary.

To ensure Enlightenment uses only Nautilus, we need to disable the integrated file manager from the Modules settings (Run Everything -> Modules -> Files). Disable EFM (Starter) and EFM Operation Info and close the settings window.

If you use the Places module, either on the desktop or in a panel, you'll also want to ensure that this launches Nautilus instead of the integrated file manager. To do this, right-click on the gadget, then go to Settings.  Finally, select Use a custom file manager and enter nautilus in the box.

And we're done - we're now using Nautilus as a replacement for the Enlightenment File Manager.

References:[Crunchbang Forums: Make nautilus --no-desktop default.]

Saturday, 6 April 2013

Scanf in Go lang on Windows

A little gotcha when using fmt.Scanf in Go:

fmt.Scanf currently relies on the Unix line ending \n, while Windows uses \r\n. This means that when using fmt.Scanf, you must include the \n if you're building your Go program for Windows. For example:
 fmt.Scanf("%d", &num)  
will work in Unix but not in Windows. You're most likely to notice this when using fmt.Scanf multiple times - either in a for loop or simply sequentially. fmt.Scanf will likely appear to run twice as often as you expect, leading to unexpected program flow.

To resolve this issue, just make sure to include the \n in your use of fmt.Scanf, as demonstrated below.
 fmt.Scanf("%d\n", &num)  

Incidentally, if you're trying to track down errors like this one, you can always check function error codes, as demonstrated below.
  n, err := fmt.Scanf("%d", &num)  
     if err != nil {  
       fmt.Println(n, err)  
In the above case, we get this error:
 20 unexpected newline  
Which gives us the line number, and the issue from that line.

[References] Stack Overflow: parallel processing: How do I use fmt.Scanf in Go

Wednesday, 6 March 2013

Linux hibernate hangs on resume - Solved

If s2disk successfully hibernates your machine, but on powering up the resume screen appears to hang, after it has appeared to stop working try pressing Alt-SysRq-E. This ends all processes in the virtual terminal used by s2disk, and, for me at least, allows me to resume working in my hibernated session.

Odd, but this might help others close to giving up on hibernation in Linux.

Monday, 4 March 2013

Fixing plugin problems with Banshee music player in Linux

After installing Banshee on my minimalist Bodhi Linux install, trying to play music lead to Banshee asking to install plugins, and then hanging. Installing the following packages using the command below resolves the issue.
 sudo aptitude install gstreamer0.10-plugins-bad gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly  

Thursday, 21 February 2013

Converting Latex to HTML using Pandoc

Install Pandoc using your disto's package manager, or by following the installation instructions here.

Then use:
 pandoc input.tex -o output.html --mathjax  

Nice and straightforward!

Wednesday, 20 February 2013

Linux Remote Desktops: A Comparison

This is the final post in a three part series exploring Ubuntu-based remote desktop options. See posts one and two for an exploration of NoMachine and ThinLinc.

My primary motivation for testing these remote desktop solutions was my desire to find a remote desktop solution that worked as Windows Remote Desktop - in terms of speed and functionality. While Linux and Windows do have differing user paradigms - Windows being designed around a single user logon, I was looking for the ability to log on to my system both at work and at home, resuming my session from wherever I was. My work machine is behind a VPN, and I need my sessions to be responsive enough to work as if I was working on the local machine.

Productivity therefore is of primary importance to me, and closely tied to this is the latency of a connection. I find that a slow, lagging connection impairs not only my ability to work in the graphical environments I require, but also affects my desire and motivation to try to continue to work remotely. For these reasons, I've found that using NoMachine, via the FreeNx client is most suitable for my purposes - there was just too much latency within a Cendio Thinlinc connection during my testing. To be clear, your mileage may vary - the latency I experienced may be down to a specific interaction between something in my setup and Thinlinc, but during testing over a number of days, at a variety of times, under different network condition, the NoMachine sessions consistently delivered a near desktop speed experience.

I'm interested to hear about the experience of others, using either of the Linux remote desktop solutions I tested - feel free to add them in the comments below.

[Image Credit]

Another Linux Remote Desktop Solution: Cendio ThinLinc

This is the second post in a three part series exploring Ubuntu-based remote desktop options. See posts one and three for further exploration and conclusions.

After the popularity of my earlier post reviewing FreeNx, Pierre Ossman, a developer at Cendio, informed me of their product, which provides an alternative remote desktop/thin client option for Linux. This post details my comparison of FreeNx and Cendio ThinLinc, as options for remote desktop solutions that rival Windows remote desktop.

Installation and use of Cendio ThinLinc

Obtaining and installing the software is relatively easy - you do have to give Cendio your email address before they will email you the download link, but the installation instructions are straightforward, and the installer does a good job of pulling in any additional required packages. The installation instructions simply consist of unzipping the downloaded package and executing an install script.

For me, the installer did seem to pull a a significant number of additional packages - these packages may just be required as ThinLinc provides a little more functionality than Nx. Overall, the ThinLinc installation took longer and felt a little less friendly than Nx, requiring slightly more configuration and interaction during the install process.

ThinLinc administration page
Once installed, the ThinLinc server is administered via a webpage at http://localhost:1010

Downloading and installing the client is also a simple process, and connecting to the server is straightforward, as can be seen in the box below:

It took me a bit of time to figure out how to disconnect from a session without logging off - the ability to resume a session from multiple locations is a primary driver of my remote desktop use. After some digging around in the documentation however, I found the relevant information - pressing F8 while logged into a remote session pops up a menu that provides the option to disconnect from the session, without ending it.

Now for the best bit - downloading and running the client on the same machine as the server allows you to start a ThinLinc session on that machine. Working in this session then allows connection from another location - using the ThinLinc client at work, for example, leaving programs running and then using the client from home to connect to that same machine gives the same experience as Windows Remote Desktop - the one feature I've missed ever since I've moved to using Linux full time.

Finally, it's worth noting that neither ThinLinc or NoMachine support the full Unity desktop that that is default in Ubuntu versions later than 11.04. Because of this, you need to ensure that gnome-session-fallback is installed:
 sudo apt-get install gnome-session-fallback  

The Comparison
The results of my comparison can be found in the final post of this series: Linux Remote Desktops: A Comparison.

[Image credit] RoomMaster2000

Juniper Network Connect in Bodhi, Ubuntu and Linux Mint

The Juniper Network Connect client simply wouldn't launch for me under any of the Linux distributions listed in the title of this post, even after trying multiple Java version installations.

Thankfully, Paul Smith at has put together a great script which allows connection to a Juniper WebVPN from a Ubuntu-based distro. He has a great write up on his blog, so I won't repeat his instructions here, other than to say he makes it incredibly simple to get connected to your institution WebVPN.

I followed his instructions on a reasonably fresh install of Bodhi Linux*, and ended up running into a "missing /etc/resolv.conf" error. This can be fixed by running the following command:
 sudo dpkg-reconfigure resolvconf  
Answer Yes to all the prompts and restart your machine once the tool finishes.

Launching Paul's script (hosted here at Github, should you want to check out the code), should now present you with a working GUI, allowing you to connect you to your WebVPN. He also provides the option of connecting via the command line, detailed further in his blog post

As usual, any issues or comments in the box below!

* If you haven't checked this distro out, I highly recommend it - it absolutely flies even on older hardware, and is Ubuntu-based giving access to the huge Ubuntu software repositories

Bohdi Linux Forums

Monday, 21 January 2013

LaTeX Error: File `algorithm.sty' not found

To resolve this error in a Debian based Linux distribution (Debian, Ubuntu, Mint, etc), the fastest way to continue working is to install the texlive-science package, using:
 sudo apt-get install texlive-science