Okay, so that's working at least. The "sudo gainroot" shouldn't be asking for a password though, so the next thing to do is check whether the sudoers entry is correct - what's the result of running (as root) the following?: Code: grep gainroot /etc/sudoers.d/01sudo As for the lock error, you can try checking for applications holding the lock file. You'll need to be root, and have lsof installed (not sure whether it's standard or not - it's in the Nokia SSU repository though), then run: Code: lsof /var/lib/dpkg/lock If that doesn't list anything, I'd also suggest checking rootfs space (df -h /) - it may well be unable to lock the file if there's no rootfs space free.
grep gainroot /etc/sudoers.d/01sudo
lsof /var/lib/dpkg/lock