Ajitabh Pandey's Soul & Syntax

Exploring systems, souls, and stories – one post at a time

Tag: OpenBSD

  • Time-zone Setting in Linux and BSDs from Shell

    Often the default time-zone in a linux and bsd system does not match our preferences. On a system which we have installed ourself, we may have selected the appropriate time-zone during installation, but as systems administrators we often get our hands on a system which is pre-installed and after taking over we want to change the time-zone to something which we are comfortable understanding and co-relating various system events in the time of our comfort.

    The time-zone of  the system is determined by a file called “/etc/localtime”, which a binary file. In order to change the time-zone, we need to replace this file with an appropriate file of our time-zone. All time-zone files are found in “/usr/share/zoneinfo”.

    On some systems “/etc/localtime” is a copy and in some cases a hard link of one of the time-zone found in “/usr/share/zoneinfo” directory. In OpenBSD, “/etc/localtime” is a symlink to one of the files in “/usr/share/zoneinfo”. I prefer the symlink approach, you can pick any of the methods to make appropriate “/etc/localtime” file available.

    In order to change the time-zone of my system from UTC to IST, I did the following.

    $ sudo ln -sf/usr/share/zoneinfo/Asia/Kolkata /etc/localtime

    In case you accidentally delete the “/etc/localtime” file, the timezone of the system reverts to UTC and upon having the correct file present again, it will reflect the correct timezone again. See below (I did this on a RHEL 6 machine) –

    $ date
    Wed Dec 18 13:56:05 IST 2013
    $ sudo rm -f /etc/localtime
    $ date
    Wed Dec 18 08:36:29 UTC 2013
    $ ls -l /etc/localtime
    ls: cannot access /etc/localtime: No such file or directory
    $ sudo ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
    $ date
    Wed Dec 18 14:07:03 IST 2013

     

  • Recovering from lost root password in OpenBSD

    Want to recover a lost root password in OpenBSD, type boot -s at the boot prompt in OpenBSD hit enter when prompted for shell and enter vt220 as the TERM.

    boot> boot -s
    Enter pathname of shell or RETURN for sh:
    Enter Terminal: vt220
    

    Next run an fsck on the root filesystem and mount it read-write. If you have a seperate /usr filesystem then you should also mount it read-write. Finally run the passwd command to change the password.

    # fsck /
    # mount -uw /
    # passwd