Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

Tuesday, 10 February 2015

Quick Tip - Centre an iframe in Blogger Using CSS

I draft most of my blog posts in a text editor before uploading them to Blogger. The advantage is that I keep a local copy (for prosperity or vanity I have yet to determine) and I can play around with presentation and layouts at my leisure. However, it's often easier to get things where you want them using CSS in a text editor than in Blogger itself but, for routine settings, you can customise the style sheet in Blogger and make the changes permanent.

Today, I wanted to centre an embedded video (an iframe), so I updated my style sheet as indicated below:

  1. From your Blogger home page, click the more options drop-down list & click the Template option.
  2. Click the Customise option.
  3. Click the Advanced option & then scroll down to Add CSS option.
  4. Add the following code in the Add custom css text box:
  5. iframe { display: block; margin: 0 auto; border: 0; }
  6. Click Apply to Blog button (top RHC of web page).

This should work with any CSS, but bear in mind that it will become the default style once the code is uploaded. In this case, all iframe objects on this blog will be centred from now on.

Sources & References:

  • None

Wednesday, 17 December 2014

Reconnecting With Your SSH Server after an Upgrade

I recently got around to updating my file server's operating system (from Mint 16 to Mint 17) and, in accordance with the law of unintended consequences, I found that I could no longer access my files using secure shell!

What I did get was an error message telling me that the host key verification [test had] failed. When you think about it, I should have anticipated the problem, after all, the original key was hashed under a different implementation of SSH Server as well as a different operating system! Fortunately, the fix is quite simple, particularly if you're only connecting to one host.

For a Single Host


Navigate to to the .ssh folder in the home/username directory (username will be unique to your circumstances). Remember that the period (full stop) indicates that this is a hidden folder, so you should ensure that you have the Show Hidden Files option enabled in your file browser. Delete the known_hosts file in the .ssh directory.

Now reconnect with your SSH host and a new key will be created following the usual warning that this is a new (and unknown!) host.

For Multiple Hosts

The error message will identify a line number in the know_hosts file; make a note of the number and open a terminal:

gksu gedit /home/username/.ssh/known_hosts

You will be prompted for your password. When the file is opened, delete the offending line, save the file and reconnect with your server. You should be prompted to recreate the key as if this were a first connection.

If you accidentally delete the wrong line (or the whole file, for that matter), fear not, the individual keys will be recreated when you next connect to your SSH server(s).

Sources & Resources:

  • None

Saturday, 1 November 2014

Quick Tip - Auto Shutdown

I'm currently copying some video files to my network drive so that I can stream them through the house. It's a time consuming business so it makes sense to batch some up to copy overnight. However, being tight, I hate the idea that the system will be idle for hours after the task is finished, needlessly consuming power. The solution is simple; tell the system to shutdown automatically at a set time.

Estimate your shutdown time and open a terminal:

sudo shutdown -h hh:mm

where hh:mm is the time (in 24 hour format). So, to close my system at 03:00am:

sudo shutdown -h 03:00

I type in my password, turn of my monitor (and any other peripherals) and go to bed!

Sources & References:

  • None

Monday, 20 October 2014

Quick Tip: Fixing Album Art

Having recently ripped an album to my file server, I couldn't get the album art to display in xbmc. The solution turned out to be changing the file permissions to read/write for all users & groups.

Sources & References:

  • None

Sunday, 28 September 2014

SSH - Sharing Privately

Apart from loving the look and feel of the Cinnamon desktop, Mint 17 has another attraction over some other Ubuntu derivatives such as Lubuntu: Secure Shell (SSH) has native support from the file manager GUI.

Many of my posts over the last four years have been about networking & file sharing using Ubuntu and I have used (and promoted) Samba as the solution to my particular circumstances. However, recently I have become increasingly aware that Samba is not without its problems, particularly read/write permissions and lock files on the remote server. These problems aren't terribly serious and there are ways to work around the issues; but I want my file server to be just that and I don't want to find workarounds for simple file sharing on a private network.

As an example, you may know that I spend much of my free time in the mountains of North Wales and take some of my pictures on my mobile (cell) phone. Rather than slip the ssd out of the phone and into a card reader (meaning that I have to stop the card and disassemble the phone) I normally use Bluetooth and set up a personal area network (PAN) to transfer the files to a laptop or desktop. Using Samba, I find that I can't simply copy the new files to my pictures directory on the server because I don't have the necessary permissions. Try as I might, I can't seem get the read/write access right. I've also had problems with GnuCash, meaning that I have to use the program on the server to update my finances - not ideal!

Using Secure Shell to connect to my server resolves all of these permission issues at a stroke and, for all intents and purposes, it behaves exactly the same as accessing local files. It has the additional advantage in that directories on the server do not need to be shared in the conventional sense and that makes them accessible only to me (or anyone that steal my login credentials).

To access your files you need only to invoke the Connect to Server... dialog from Nemo (File > Connect to Server...) and provide the necessary details.

If you've set up Samba to recognize netbios names, then it's pretty straightforward: the port default for SSH is 22 (and will only change if you've changed it!). Once connected, you can access your files and directories from Nemo's GUI and use them locally. This may be overkill on a private network, but using SSH also resolves another irritating problem: file lock. Using Samba, if an application wasn't closed before shutting down the client pc, the file lock would remain on the server (effectively making the file, read only): SHH seems to resolve this problem because Nemo is closed down as part of the normal shutdown sequence.

One final tip, if you're having trouble connecting to your server, check that ufw is allowing incoming traffic on port 22:

sudo ufw allow proto tcp from 192.168.0.0/24 to any port 22

Sources & References:

Wednesday, 27 August 2014

Quick Tip - Minification In Linux

Often, when building and testing a website, you may be working with two or more style sheets. However, before uploading your site it's best practise to merge your css files in order to reduce any lag between request and response. There are several tools available to achieve this but Linux has its own command line tool, cssmin.

To install cssmin, open a terminal and:

sudo apt-get install cssmin

Enter your password and allow the application to install. To merge your style sheets:

cat file1.css file2.css file3.css | cssmin > output.min.css

Where filen.css are the source files and output.min.css is the output file. Obviously, you will need to link your html files to the new style sheet.

Sources & Resources:

Monday, 23 June 2014

Quick Tip - Fix the Flicker

If you're using Cairo Dock on Mint 17 & you are witnessing flickering when you hover the mouse over the dock, the fix is simple!

Open the Startup Applications dialog (Main Menu > Preferences > Startup Applications), select the Cairo-Dock entry, & click Edit.

Amend the Command field to read:

cairo-dock -o

This forces Cairo Dock to use the Open Graphics Library at startup and should resolve any flickering problems.

If this doesn't do the trick, try using the Cairo backend:

cairo-dock -c

Sources & References:

Sunday, 15 June 2014

Quick Tip - List Applications

You can view a list of installed applications using the terminal - this works in Ubuntu 14.04 & Mint 16. Open a terminal and type:

dpkg --get-selections

If you want to export the output to a file:

dpkg --get-selections > /home/[user]/Documents/app_list.txt

Change [user] to suit your circumstances.

This will place a text file in your Documents folder called, app_list.txt. Double click to open from your file manager.

Sources & References:

  • None

Wednesday, 4 June 2014

By Popular Demand - Fixing On-Demand Video in Mint 16

After a brutal shift at work, all I wanted to do this afternoon was crash in front of the TV but I got home to find that I had no signal. So, I thought I'd catch up with some on-demand TV from Channel 5 but I couldn't get any video to play via Chromium on any of my Mint 16 systems.

A little research suggested that installing the (now deprecated) hardware abstraction layer (HAL) should get everything except Amazon Prime working. If I've understood the concept correctly, HAL is (more accurately, was) simply a generic way of allowing the OS to access the system hardware regardless of type: conceptually, I think of it as a universal translater! Installing it on Mint 16 is simple. First you need to close Chromium and add a new PPA:

sudo add-apt-repository ppa:mjblenner/ppa-hal

Next, install HAL:

sudo apt-get update && sudo apt-get install hal

This was all that was needed on the DELL Dimension 8400, but I needed to reboot the Aluetia for the changes to take effect. It was worth it though, TV always looks better on a bigger screen!

Sources & References:

Monday, 26 May 2014

GnuCash - Creating New Accounts/Categories

I've seen a number of questions online asking how to create new expense categories in GnuCash. The question itself demonstrates a fundamental misunderstanding of how basic bookkeeping works: an expense category is really nothing more (and nothing less!) than an account where cash values are allocated as spent. Think of a category as a bucket or container for certain types of expenditure: although the cash is gone, the category is a record of where it went.

Once you've understood this principle, creating your new category should be obvious: create a new account under the Expenses parent. Suppose that we want to create a new expense category called "Household" to differentiate non-perishable household items from perishable items (food!):

From the Accounts page, click on the Create as new account icon or (from the main menu), select Actions & New Account to summon the New Account dialog box.

Once the dialog appears, we can give it a name (in this case, Household) and a description. We also need to select Expense as the account type and Expenses as the parent type.

When you click OK your new account will be created and will appear in the account list under Expenses.

Now when you enter a transaction and click on the the transfer type, the new account will appear in the list as an option.

The good news is that this category will be reportable but just be cautious about adding too much granularity: you may end up not seeing the wood for the trees.

Sources & References:

  • None

Monday, 12 May 2014

(Another) Ubuntu 14.04LTS Keyboard Fix

Whilst browsing the Lubuntu Blog for installation issues, I came across a known bug in the keyboard layout for some languages (in particular, GB Eng) - reading the bug report suggests that this problem exists across all flavors of the Ubuntu 14.04 distribution.

If my previous suggestion on fixing your keyboard language doesn't work, there are a number of fixes in the bug report. As always, try the simple ones first & in this case, Branimir Butorac's post (26) put me on the right track for my Ubuntu installation on the DELL Inspiron 6400.

Open The settings Menu & select Language Support from the Personal settings. Under the Keyboard input method system, select none.

Reboot to check persistence.

Sources & References:

Sunday, 11 May 2014

DELL 6400 Integrated Card Reader & Ubuntu (sudo v gksu)

I've written on getting the integrated card reader to work on my Inspiron 6400 before. After changing/re-installing my operating system, this is one of those important/non-urgent jobs that gets done when I need to read a memory card (& usually not before!). However, I have noticed that the fix that I posted last July doesn't persist: that is, if I unmount a card, I can't (always) mount another without rebooting my laptop.

There's a good reason for this: I didn't understand that you should never launch a graphical application from the terminal using the sudo command.

"You should never use normal sudo to start graphical applications as Root. You should use gksudo (kdesudo on Kubuntu) to run such programs. gksudo sets HOME=~root, and copies .Xauthority to a tmp directory. This prevents files in your home directory becoming owned by Root. "
[Source]

It seems that when running a graphical application via the sudo command, the application is granted root privilege but utilizes the users configuration file. Therefore, best practise dictates that, when opening graphical applications with administrator privilege, you should invoke the application using the gksu command.

So, I'm compelled to revise my advice for fixing the integrated card reader on the Inspiron 6400. Open a terminal & then:

gksu gedit /etc/modules

Instead of being prompted for your password in the terminal (as you would if you had invoked Gedit using sudo), a administrative dialog will appear requiring your authentication. Enter your password & click OK to open Gedit as root.

When Gedit opens, add the following code to the bottom of the file:

sm_ftl

This is a better solution than the one posted last year but it is not completely effective (delayed unmounts will sometimes result in a return of the problem behaviour). However, maintaining focus on the file manager whilst swapping out cards generally displays fix persistence.

Sources & References:

Saturday, 10 May 2014

ufw - Letting Samba Play

In yesterday's post on security I mentioned that, if you share files on your network using Samba, you'll have to add some special rules to your firewall. Fear not, this is pretty easy!

Open a terminal and type the following commands pressing enter after each one.

sudo ufw allow proto udp from 192.168.1.0/24 to any port 137

sudo ufw allow proto udp from 192.168.1.0/24 to any port 138

sudo ufw allow proto tcp from 192.168.1.0/24 to any port 139

sudo ufw allow proto tcp from 192.168.1.0/24 to any port 445

You may not have the same address as the one used in the example code above - you can check your own ip address in your terminal (in Linux) using:

ifconfig -a

Find your (live) network connection from the list and identify the inet addr data and amend the above rules accordingly. As you add each new rule, the terminal will confirm that it has been added successfully. However, you can check the status of your firewall once all of the rules have been added with:

sudo ufw status

If all's gone well, you should see something like the screen below:

Remember, to access folders and files you'll need a Samba password on the server (you'll be prompted for your username & password when you try to access the files through your file manager). You can add a user and password from the terminal:

sudo smbpasswd -a [username]

Change [username] to suit your circumstances. You'll be prompted for you root password (if you're not already operating at elevated permissions) and then for a SMB password - this is the password that you'll use to access files from a client computer. Confirm your SMB password when prompted.

Reboot and you should be able to access files from a remote client. Remember, you will have to open these ports on any pc with ufw enabled if you want to share folders and files using Samba.

Sources & References:

Friday, 9 May 2014

So, 'Nix is Safe, Right?

There's always been a lot of debate about how safe Linux is from virus and hacking attacks: inevitably the discussion is distilled to a simplistic comparison between the distribution in question & Windows, but I usually find these comparisons to be unhelpful.

There's a lot of reasons that Windows is more susceptible to attack, not least it dominates the PC market, giving attackers a larger pool of potential victims. Moreover, viruses for 'nix are unheard of in the wild but, before we Linux users get too smug, that doesn't mean that we're impervious to attack! The reality is that all operating systems are vulnerable to some extent and vigilance is always recommended whatever system you choose.

The good news is that there are some very simple steps that new users can take in order to mitigate their exposure to attack. The first, and probably most important, is to choose a strong password. This mitigates the chance that an attacker can guess your password or use a dictionary attack to gain access to your system.

Another important action is to enable the bundled firewall, ufw. The firewall is not enabled by default in Ubuntu or its derivatives but it's easy to enable and, for most users, can be run using default settings1. Open a terminal & then:

sudo ufw enable

Provide your password at the prompt and hit enter. To check your firewall status, at the terminal prompt, type:

sudo ufw status

If all's gone well, you should see the output:

status: active

You may also see some additional rules (but only if you've customized your firewall).

Finally, don't forget to install security updates as soon as they become available: these patch your system and close vulnerabilities that attackers might exploit.

Ultimately, security relies on the user, but these simple tips can help keep your system (and your data) secure.

Sources & References:

Notes:

    1 If you share files across a network, you'll need to add some firewall rules: more about that in another post but I've referenced guidance in the sources section.

Saturday, 3 May 2014

Quick Tip - 14.04 Summoning the Keyboard Shortcut Splash Screen

Do you remember the shortcut splash screen that appeared on your desktop the first few times you booted into Ubuntu Trusty? After a while it no longer appears automatically, but you can summon it at any time by pressing & holding the super key (also called the Windows Key).

Sources & Resources:

  • None

Thursday, 1 May 2014

14.04 Keyboard Conundrum Continued...

One little problem that has popped up since my upgrade to 14.04 is that the keyboard, despite being set to English UK, layout is not reflected in the keystrokes. This can be irritating when you press the hash (#) key and get a forward slash (/) symbol.

Fortunately, I've come across this problem before and the fix is satisfyingly easy! Open a terminal (Ctrl+Alt+T) and type:

sudo setkeycodes 91 100

Done!

Sources & References:

Tuesday, 29 April 2014

Quick Tip - Identify Sites That Share Your GMAIL Address

A fascinating article on MaximumPC gave me a heads up on a little trick to keep my gmail address private (or, at least, find out who's sharing it without my permission).

When signing up for online accounts, append your normal gamil account with a unique identifier, thus: john+xxx@gmail.com. Where xxx is a unique string of arbitrary length that identifies a particular supplier or website.

For instance, if your email address is john.komphix@gmail.com and you want to sign up for komphix newsletters, you could append your email address to be john.komphix+komphix@gmail.com

Brilliant!

The whole article is worthy of your time if you want to make the most of your gmail account.

Sources & References:

Monday, 28 April 2014

14.04 LTS - ttf-mscorefonts-installer Package (Again!)

If you get an information update message about mscorefonts after upgrading to 14.04 LTS, the fix seems to be to reinstall the ttf-mscorefonts-installer:

In a terminal:

sudo apt-get install --reinstall ttf-mscorefonts-installer

Sources & References:

Sunday, 27 April 2014

Chromium Flash Player in 14.04 LTS

If, like me, you're not a big fan of Firefox, you may prefer an alternative browser - I like Chromium, but in 14.04 flash player is not enabled by default. In 14.04 the fix is fairly straight forward, in a terminal, copy & paste:

sudo apt-get install pepperflashplugin-nonfree

Followed by:

sudo update-pepperflashplugin-nonfree --install

If restarting your browser doesn't enable flash video, rebooting my PC worked for me.

Sources & References:

Tuesday, 23 July 2013

DELL 6400 Integrated Card Reader & Ubuntu 12.04

My six year old laptop has become my primary machine over the last few months. I've always liked the DELL Inspiron 6400 but it's never been used as much as it should have been - until now!

Unsurprising then that I should only now realize that the integrated card reader doesn't work! I've been meaning to look into it for a couple of days and finally got round to it this evening: the fix took seconds!

Open a terminal and type:

sudo gedit /etc/modules

When Gedit opens, add the following code to the bottom of the file:

sm_ftl

Save and close the modules file and reboot. Inserting a SD card on restart resulted in a welcome media prompt.

I always like the easy fixes!

Sources & References: