Groesbeek, view of the 'National Liberation Museum 1944-1945' in Groesbeek. © Ton Kersten
Fork me on GitHub
Posts tagged as linux

Fix a lot of rights

2012-06-18 (114) by Ton Kersten, tagged as linux, sysadm

A customer called and wanted help with an error they made.

The error was simple, they typed:

chmod -R 660 /

and now things broke. Of course things broke. If they would not brake that would be very weird.

Luckily they had a second server and a simple one-liner stole all the rights from this second server and and we could put these on the broken one.

The oneliner

find / -depth -printf 'chmod %m\t\t-- "%p"\nchown %u:%g\t-- "%p"\n' > rights.sh

produces output like this

chmod 644       -- "/etc/sysconfig/kdump"
chown root:root -- "/etc/sysconfig/kdump"
chmod 644       -- "/etc/sysconfig/rhn/sources"
chown root:root -- "/etc/sysconfig/rhn/sources"
chmod 644       -- "/etc/sysconfig/rhn/sources.rpmforge.txt"
chown root:root -- "/etc/sysconfig/rhn/sources.rpmforge.txt"

Running this script on the broken server left us with something that was working.

Running

dpkg -x <package name>

on all cached packages in /var/cache and after that a

dpkg --reconfigure -a

Solved the rest.

Pheeeuuwww, we were lucky smiley

Updated to Linux 3.0

2011-08-14 (106) by Ton Kersten, tagged as linux

I have a eeePC 900 (the 9" version) running Arch Linux for some time now. I didn't update it for a while, so, today being a rainy Sunday, I decided it was time to do it.

So, I typed:

pacman -Syu

and waited for about half an hour.

And look what I got

Linux eeetje 3.0-ARCH

Everything is running nice and smooth, so I'm very happy.

Can't wait to get my hands on Linux 3.11 for Workgroups smiley

umask per directory

2010-12-08 (83) by Ton Kersten, tagged as linux, puppet, sysadm

Some users insist on using bash. This is a good shell, but not as good as zsh. But, I do want them to be able to use the per directory umask as well as all the zsh users.

So I started digging, as the bash shell does not support a chpwd hook.

This is what I came up with:

chpwd()
{   # Set the initial umask
    case "${PWD}/"
    in
        /etc/puppet/*)
            um=$(umask)
            umask 007
        ;;
        *)
            [[ x"${um}" != x"" ]] && umask ${um}
        ;;
    esac
}
function cd()
{
    builtin cd "${@}"
    chpwd
}

Now, when I change to the directory /etc/puppet I do get a umask of 007 and when I cd somewhere else, I do get the original umask.

I do redefine the intercal cd command to run the chpwd hook. There must be a more elegant way to do this, but this does the job.