Monday, 26 August 2019

LibreOffice can't open files on NFS server

Trying to open a LibreOffice spreadsheet on an NFS-mounted directory within my home network.  LibreOffice comes up with "locked for editing by unknown user". 

Many posts will tell you to look for a hidden lock file in the same directory: I had none.  In fact there were no files anywhere of any consequence with the names *lck* or *lock*.

I found a comment on an Ubuntu LibreOffice bug 1751005 which corresponded with some AppArmor messages I found in the local client log, and took the requisite action: I still had the problem.  I'm now running LibreOffice 6 so that action may have been unnecessary, actually.

I tailed the server log and attempted the failing access: instantly there came a lockd: cannot monitor myclient message.

Finally I found the problem: rpc-statd.service was not running on the Ubuntu 18.04 server which was providing the NFS mounts.  I enabled the service and all is now well.

Friday, 14 December 2018

Why has emacs stopped running in a window?

I use several editors (and also Eclipse, which has its own) and manage to be reasonably productive with all of them, but all other things being equal emacs is my favourite.I have it installed as an icon on the Linux Mint start bar.

Imagine my annoyance and distress when yesterday clicking on the emacs icon did nothing; no error message, no window display, just a momentary blink and then nothing.  emacs would run in a terminal window, but not in its own emacs window on the desktop.  Reinstalling the "emacs" package didn't help.

I traced the problem to a mistake I made yesterday.  I have a list of packages to install on a remote Ubuntu server, which has no X windows installed and which runs headless.  In error I typed the "apt install" command into a window which was not ssh-ed into the local machine, thus installing all those packages on my local laptop (the one where emacs was failing to run).  I do my development and testing locally so in fact installing those packages was a no-op, with one important exception: I use emacs on the Ubuntu Server system, but to avoid problems install only the terminal-only version, called emacs-nox.  So of course I had installed emacs-nox on my laptop, which had faithfully done what was required of it: stop emacs running in an X Window.  I purged it, reinstalled emacs and all was well. 

Saturday, 6 January 2018

A run-once system for linux

Current development of the Linux image for the community centre I'm involved with requires me to be able to carry out tasks just once (a "run once" capability). Moreover, I have need to run such tasks at three different stages in the overall process:
  1. At start up before the network is active (to manipulate network definitions)
  2. At start up after the network is active but before users log in (in my case to incorporate the IP address into a workspace wallpaper)
  3. At shut down, after the users are logged off but while the filesystems are still mounted.

The run-once script

I have a run-once script /usr/local/bin/runonce, based on one I found here.
[ -z $RUNONCE_DIR ] && RUNONCE_DIR=/etc/local/runonce.d

[ ! -d $RUNONCE_DIR/ran ] && mkdir -p $RUNONCE_DIR/ran

for FILE in $RUNONCE_DIR/*; do
    [ -d "$FILE" ] && continue
    COMMAND_NAME=$(basename $FILE)
    logger -it runonce -p "Running: $FILE"
    mv "$FILE" "$RUNONCE_DIR/ran/$COMMAND_NAME-$$-$(date +%Y%m%d-%H%M%S)"
    logger -it runonce -p "Ran: $FILE"

I use it in all three places, with three directories /etc/local/runonce-a.d, /etc/local/runonce-b.d and so on.  The parameter to the runonce job specifies which one to use.

The three jobs are then controlled by systemd unit files (I'm just getting used to systemd ..), as follows:


# Run-once service; runs any executable in /etc/local/runonce-a.d
# Ensuring that it runs before the network is active
Description=Run once programs (pre network)

ExecStart=/usr/local/bin/runonce /etc/local/runonce-a.d



# Run-once service; runs any executable in /etc/local/runonce-b.d
# Ensuring that it runs after the network is active
Description=Run once programs (post-network)

ExecStart=/usr/local/bin/runonce /etc/local/runonce-b.d



# Run-once service; runs any executable in /etc/local/runonce-c.d
# before the system is shut down or rebooted.
Description=Run once programs (before shutdown)

ExecStop=/usr/local/bin/runonce /etc/local/runonce-c.d


It took quite a while to assemble the various bits of this from around the web; hope it helps someone else.

Wednesday, 12 October 2016

Windows 7 PC can't see anything on the network

If you have this problem and go searching on the web you'll find a huge number of posts: it's terribly common.  So common that you'd have thought that Microsoft would have fixed it, but there we are.

Here's my experience today, which isn't as far as I can see the same as any of the twenty or so hits (none of them saying anything definitive) which I looked at this morning.


  • Clicking on "network" showed only the local machine, the defined network printers, and an icon representing the NAS to which I was trying to get access.  Not the sort of icon that allows you to get at the files, though.
  • Opening a command window and pinging the device by name (I haven't bothered creating a hosts file) worked fine, so the TCP/IP parts were working.

The cure

I can't call this a "fix" since it makes no sense.  In order to check whether some firewall rule was dropping the relevant traffic I turned the firewall off.  Bingo!  The network appeared.  "Ah, a firewall problem," I said to myself.  "Now what on earth is causing that?"

I turned the firewall back on again, and the network was still visible.  Job done ... but why?  Oh well, Windows is like that. 

Friday, 30 September 2016

You told Windows 10 that your network was "public": what do you do now?

When you connect to a new network Windows 10 will ask you whether it's "private" or "public".  It's clear that some people don't understand the real intention of this, which isn't to do with whether or not the network is used by "the public", but rather is to do with whether you trust the people that configure and administer it.  So the network at the community centre whose IT I look after is "private".

If you designate a network "public" Windows 10 will--correctly in my opinion--tightly constrain what the machine will "see" in that network.  File shares won't work, printers can't be seen, and so forth.  The only trouble comes if you designate a network as "public" by mistake: there is no easy way to change it to "private"!  This seems to be a major oversight on Microsoft's part.

Faced with the problem this morning I found the way to fix it.  It involves using the Deep Magic of the powershell, but it worked first time for me.  It comes from this page, about half way down.
  1. Windows-key and search for "power"; you'll get a list of "powershell" options.
  2. Right click on the simple "powershell" one and select "Run as Administrator".
  3. In the blue window that comes up, type Get-NetConnectionProfile
  4. You'll get a list of network connections, each with a number.  Select the one you want to change and make a note of its number (let's say it's number 2).
  5. Now type Set-NetConnectionProfile -InterfaceIndex 2 -NetworkCategory Private, where you replace "2" with whatever your interface is.
That web page says you should reboot after this but I found it worked fine without.  And I've no idea whether you need to respect the upper- and lower-case letters in those commands: I typed them as they are.

Thursday, 29 September 2016

Windows 10 file sharing: frustration and a workround

Setting up a new laptop for a colleague; it runs Windows 10 and my knowledge stopped, more or less, at Windows 7.

There's software I need on the Samba file server on the home network.  But can I get this thing to see the server?  I've spent hours on it, and seen hundreds of articles on the web in which the same problem is discussed, and almost as many attempts to fix it.  I tried a few of the most likely (enable discovery and file sharing, fiddle around with SMB protocols) all to no avail.

I can ping the server; I can list the shares with net view; I just can't get them to appear in the "Network" explorer.

I still haven't fixed it, but I have managed to get access to the drive I need by the simple expedient of selecting "Map a network drive", filling in the IP address of the server and telling it to use different credentials.  Up it comes.

It appears that Microsoft have changed (spell that b-r-o-k-e-n) something in the way that Windows 10 connects to file shares, but nobody knows quite what.

Thursday, 1 September 2016

Disabling the Google Chrome sign-on screen

When you start Google Chrome it comes up with a page inviting you to "sign in to Chrome" (which I think is the same as signing in to Google).  The users that sit in front of my "teaching" machines have only the vaguest clue about "signing in" to something, and they certainly won't understand the difference between signing in to Google and signing in to some other application (such as the DWP's job-search system, which is often the only thing they use).  If they take any notice of the screen at all it would put them off, since they wouldn't have an account and a password and would think they couldn't continue until they had signed in.

So I'd like to disable the sign-in screen as part of the build, using some preferences file somewhere.  But guess what?  The Chrome sign-in screen isn't controlled by a preferences file.  Assiduous web searching suggests that it was once controlled by a "sync_promo" section in the "Preferences" file, but testing shows that that section isn't there, at least in the 32-bit version that I'm obliged to use.  And in any case you can't pre-populate a user with a Preferences file because it's different for every user and every time that Chrome is opened.

I'd like this blog to contain solutions to problems, but in this case it records the fact that I've given up trying to do this.  Thanks, Google.