Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

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/src-hilite-lesspipe.sh %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.

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  

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] lifeskillsfromthedojo.com

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 Mad-Scientist.us 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

[References]
Mad-Scientist.us
Bohdi Linux Forums

Thursday, 6 December 2012

Printing from the Linux command line

To print a file from the Linux command line, use the simple command:
 lpr FILENAME  
It's that easy!

I came across this while trying to print all pdf files in a directory. To do this, the simple bash script you need is:
 #!/bin/bash  
 for file in *.pdf; do  
   /usr/bin/lpr "$file"  
 done  

Save this into a file - I called mine print-all-pdfs.sh. Then make it executable using
 chmod +x print-all-pdfs.sh  

Copy it to the directory you want to run it in, then execute with
 ./print-all-pdfs.sh  

For an additional challenge, can anyone adapt the above script to print all .pdfs from directories recursively? Answers in the comments below!


[References] Bash script adapted from a LinuxForums post.

Tuesday, 4 December 2012

How to add a menu item for SPSS in Linux

I keep forgetting where SPSS installs itself - this .desktop file may be of help to others too.

Create .desktop file for SPSS:
 sudo leafpad /usr/share/applications/spss.desktop  

Add this text to that file:
 [Desktop Entry]  
 Name=SPSS  
 GenericName=SPSS  
 Comment=Statistics program  
 Exec=/opt/IBM/SPSS/Statistics/19/bin/stats  
 Icon=gnome-monitor  
 Terminal=false  
 Type=Application  
 Categories=Application;Education;  

Save, then log out and back in again, or restart the desktop using
 xfdesktop --reload  
if using an XFCE desktop.

 SPSS will now be available under Applications -> Education.

Thursday, 20 September 2012

Install the latest version of R in Ubuntu

The R version in the Ubuntu repositories is not the latest, so here's how to install R into Ubuntu 12.04:

Add the SSL key and import into apt:
 gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9  
 gpg -a --export E084DAB9 | sudo apt-key add -  

Add the repository to your sources list, by doing:
 sudo nano /etc/apt/sources.list  

Then add this line to the bottom of the sources file:
 deb http://cran.ma.imperial.ac.uk/bin/linux/ubuntu precise/  

Then, to install the latest version of R, do:
 sudo apt-get update  
 sudo apt-get install r-base  

Hit yes at the prompts, and voila, the latest version of R is installed!

Monday, 10 September 2012

Great gEdit Theme Repository

I'm a fan of light on dark backgrounds when writing or coding, and Githubber kalmi maintains a great collection of gEdit (the default text editor in Gnome) themes - they can be found here: https://github.com/kalmi/gedit-themes

To use, clone the repo into a temporary directory, using:
 git clone https://github.com/kalmi/gedit-themes.git 

Then copy them into a styles folder in the gEdit directory, using the install script from the repo:
 cd gedit-themes
 ./install.sh  

To use them, open gEdit, then go to Edit -> Preferences -> Fonts and Colours. The themes should now be available in the Colour Scheme scroll box.

Enjoy!

Thursday, 19 July 2012

Mounting an executable CD Drive in Linux

I ran into the below problem while installing Matlab onto a Linux machine. Hopefully this will help someone else!

On most modern Linux systems, CD drives are automatically mounted. The problem comes when they are mounted without any exec permissions - this means that any scripts, etc on the CD, or .iso, will be unable to run. To resolve this, follow the steps below:
  1. Find the name of your mounted CD drive by using:
     mount  
    
  2. Then remount the device with the exec bit set:
     mount -o remount,exec $DEVICE
Where $DEVICE is the name of the CD drive.

You'll then be able to run all executables on the drive - in my case, the Matlab executable was then launched using the below commands:
 $ su  
 $ /path/to/mounted/cdrom/./install  

Remember to logout as root when the installer has finished!
 logout  

Thursday, 12 July 2012

Getting number of lines in all files in a directory - Unix

The bash command
 wc -l <file>
will print out the number of lines in <file>.

If you have a collection of files (.csv in the example below), and want to know how many rows are in each file, the command:
 for f in *.csv; do wc -l $f; done  
will print out a list of all the files ending in .csv, along with the number of lines in them.

To print the number of lines, without the filename, the cut command can be used, with the following parameters:
cut -d' ' -f1  

Combining them, we can use:
 for f in *.csv; do wc -l $f |cut -d' ' -f1; done  
to print out just the number of lines in each file ending in .csv in the directory.

Wednesday, 16 May 2012

Visual Ruby and Glade: cannot create instance of abstract (non-instantiatable) type `GtkBox'

If you get the error:

GLib-GObject-WARNING **:cannot create instance of abstract (non-instantiatable) type `GtkBox'

When using Visual Ruby and/or Glade to design a Ruby-GNOME2 user interface, the reason is that the latest version of Glade (3.10) has dropped support for Gtk::VBox and Gtk::HBox - it replaces them both with Gtk::Box. This breaks Gtk::Builder. The solution is to use Glade 3.08, which can be installed (for Ubuntu, and Ubuntu based distributions such as Linux Mint) using:
 sudo apt-get install glade-gtk2=3.8.0-0ubuntu3  


To find the correct version/package name for your distribution, use:
 apt-cache showpkg glade-gtk2  

and find version 3.8.0.

If using Visual Ruby, be sure to update the Glade Command Line setting by going to Tools -> Settings and entering
 glade-gtk2  

in the Glade Command Line box.

Friday, 11 May 2012

Connecting to a VPN from the command line in Linux Mint / Ubuntu

Set up the VPN using the Network Manager applet, then open a Terminal. The command to connect to a VPN is:
 nmcli con up uuid <your-uuid-here> 

To find out the UUID of the VPN connection, use:
 nmcli -p con list

The command to disconnect from a VPN is:
 nmcli con down uuid <your-uuid-here>

Fixing Hibernate Problems in Linux Mint Part II

My previous attempts to make hibernation work for my Linux Mint installation didn't entirely solve the problem. My system has been hanging far less than usual, but would still occasionally hang at the s2disk hibernating screen.

After a lot of reading, it seems to me that there's problem with the s2disk utility, and so I've worked around the problem using an older, more stable method of hibernation:
 sudo echo disk > /sys/power/state  

This will hibernate the machine, and resume the session when it is powered back up. It's not as fast as s2disk, and doesn't display any information while hibernating (it shows a black screen unless there are errors), but is far more stable, for my set up at least.

I put the command into a one line script, in /usr/bin/hib-script.sh, then added an entry in sudoers (see this post) to remove the requirement for a password to be entered. Finally, I added a launcher to Cairo-dock, so that now I have a consistent, stable hibernation function for my Linux Mint installation.


How to run a script requiring sudo without needing a password

To run a script that has a sudo command in it, without needing to enter a password whenever the script is executed, add an entry in sudoers.
First, open sudoers using visudo:
 sudo visudo  

Then add the following line to the bottom of the file:
 <user> ALL=NOPASSWD: <absolute_path_to_script_file>  

Where <user> is the user running the script, and <absolute_path_to_script_file> is...self explanatory :). Though I've found that the script needs to be placed in /usr/bin/ to for the entry in sudoers to be effective.

Save the changes to the file, and log in and out to enact the change. Now, when you sudo script, there will be no prompt for a password.

Monday, 7 May 2012

Spell Checking a Latex Document using Aspell

Use:
 aspell --mode=tex check <filename>  
or

 aspell --mode=tex -c <filename>  

Where <filename> is the file to be spell checked.

Saturday, 28 April 2012

Fixing Hibernate Problems in Linux Mint

Hibernate was working fairly inconsistently on my machine; sometimes it would work, and sometimes it would hang with s2disk pending onscreen. Google turns up a lot of Linux hibernate problems, below is how I resolved mine.

First, ensure you have more swap space than RAM (1.5 - 2x RAM as a guideline), using the command:
 swapon -s  

If you don't have enough space, follow the instructions here before continuing.

Once you are sure you have enough swap space, if hibernate still isn't working, install the powermanagement-interface package, using:
 sudo apt-get install powermanagement-interface  

This got hibernation working on my machine, I hope it helps you too.

Update: Make sure you check out Part II of this post, should this post not help you fully resolve your hibernate problems.

Friday, 27 April 2012

Finding and killing a process in Linux

To find a process, use
 ps ux | grep <process_name>  

Where <process_name> is the name, or part of the name of the process you want to find.

Look up the process ID (the number in the output), and then use
 kill -9 <process_number>  

Where <process_number> is the process ID of the process you want to kill.