Entries in System Administration (49)

Saturday
Jan162021

Hamster ball fixes network problem

One Saturday morning a year or two ago my wife complained that she couldn't get 'onto' her emails.  She said this had happened several times in the previous few days but only when she was using the computer in the living room.  This computer was connected to our modem router by an Ethernet cable and inspection showed that the cable had been nibbled where it ran along the floor.  My wife admitted that she had been allowing our hamster to run free in the living room while I was at work.  I went out and bought a replacement cable. My wife went out and bought a hamster ball.  The connection problems did not occur again.

Thursday
Aug162012

Firefox Right-Click Menus in Ubuntu Unity

Following my upgrade from Ubuntu 10.04 LTS to 12.04 LTS, my greatest annoyance with the Unity interface has been the way it broke my web browsing experience.  When using Firefox I make much use of Control-Right-Click to open multiple bookmark menu items.  In Unity, this simply just does not work.  The cause of this appears to be changes made to Firefox to integrate it with the Unity global menu.  Fortunately, these changes can be removed quite easily.  In the Firefox menus click:

Tools > Add-ons > Global Menu Bar integration > Disable > Restart now

Now the Firefox menus will respond correctly to Control-Right-Clicks. 

Disabling Global Menu Bar integration also means that the Firefox menus stay at the top of the Firefox window instead of going up to the global menu bar.  This will please my wife who found Firefox under Unity very confusing: "Where have all the menus gone?  Where's my back button?  Where's the address box?  What have you done to my Firefox?  It no longer works.  I want the old one back".  I suspect that these reactions will be fairly typical of the majority of Ubuntu users.

Sunday
Aug122012

The Ubuntu Unity Super Key on a Thinkpad

Since 2005 I have had a IBM Thinkpad R50e laptop on which I have run various releases of Ubuntu from 5.04 onward.  Recently I upgraded from Ubuntu 10.04 LTS to 12.04 LTS.  The change in interface from Gnome 2 to Unity was a profound shock to my system and it took me several weeks to get used to it.  At one point I even installed Debian 6 in an attempt to get back to a system I felt more at home with (however, I quickly went back to Ubuntu when I realized Debian does not come with Firefox readily available). 

The main problem facing anyone using Unity on a Thinkpad is the lack of a 'Windows' key.  Unity maps its 'Super' key onto the Windows key, and the Super key is at the heart of how the Unity interface operates, being the basis for many keyboard shortcuts.  Without it you will spend a lot of time switching back and forth between mouse and keyboard.

The solution I chose was to map Caps Lock to the Super key as follows: 

System Settings > Keyboard Layout > Options > Caps Lock key behaviour > Make Caps Lock an additional Super

Now pressing Caps Lock brings up the Unity Dash.

Friday
Jul202012

Why .profile, .bash_profile, and .bash_login?

Configuring the startup of bash can seem to be an unnecessarily complex process with a plethora of configuration files all being read or ignored according to a mystifying set of rules.  The Invocation section of bash man page describes these rules in some detail but gives very few clues as to the reasons for their existence and the problems they were intended to solve. It is common for a change to one of the configuration files either to have no effect at all (ie: to be ignored), or to have unintended side-effects in another type of start-up.  Indeed, a search of Linux and Unix forums will reveal many threads dealing with of this type of problem.

This post is part of an attempt by me to understand the complexities of bash startup and to draw up some rules to simplify the use of the configuration files.  This attempt was inspired by installing RVM, the Ruby Version Manager which screwed up my Bash settings by creating a .bash_login file.  And this particular post was inspired by reading the following two paragraphs from Learning the bash Shell, 2nd Edition, Cameron Newham and Bill Rosenblatt, O'Reilly, 1998, page 59:

bash allows two synonyms for .bash_profile: .bash_login, derived from the C shell's file named .login, and .profile, derived from the Bourne shell and Korn shell files named .profile. Only one of these three is read when you log in. If .bash_profile doesn't exist in your home directory, then bash will look for .bash_login. If that doesn't exist it will look for .profile.

One advantage of bash's ability to look for either synonym is that you can retain your .profile if you have been using the Bourne shell. If you need to add bash-specific commands, you can put them in .bash_profile followed by the command source .profile. When you log in, all the bash-specific commands will be executed and bash will source .profile, executing the remaining commands. If you decide to switch to using the Bourne shell you don't have to modify your existing files. A similar approach was intended for .bash_login and the C shell .login, but due to differences in the basic syntax of the shells, this is not a good idea.

From these paragraphs I draw the following conclusions:

  • .bash_login was introduced as part of an unsuccessful attempt at compatibility with the C shell.  This suggests that its use can be and should be avoided.  You should never create a .bash_login and if you have one you should not allow it to be activated (creating a .bash_profile should ensure this) and should delete it.
  • .bash_profile is the appropriate place to put bash-specific commands to be run when starting a login shell.  It would seem sensible to always have a .bash_profile file and to never allow bash to read .profile directly.  Instead the .bash_profile should always end with a command to include the .profile, but rather than just source .profile it would be better to test .profile exists first, for example:
    if [ -f "$HOME/.profile" ]; then
      source "$HOME/.profile"
    fi
    
    Always having a .bash_profile has the additional benefit of preventing any .bash_login from running. 

The problems of what bash-specific commands are appropriate to a login shell and, indeed, what a login shell is and how it differs from a non-login shell, I will leave for another post.

Thursday
Jul122012

How to set the Position and Size of Windows in Ubuntu 12.04 LTS

A few web pages that I found useful when writing scripts to set up windows with particular positions and sizes in Ubuntu 12.04 LTS:

Automate opening of nautilus windows? - a thread at Ubuntu Forums

wmctrl examples from Spiral of Hope

wmctrl(1) - Linux Man Page

In the Spiral of Hope page I am not sure what the constructs of the form [#r -r] are meant to do.  Maybe they were part of the option syntax for earlty versions of wmctrl?  Anyhow, the examples seem to work if you replace each occurrence of [#r -r] by just -r (and similarly for the other [#..] constructs).