Setting date and time in linux

Sunday, May 9th, 2010

Server clocks has a tendency to drift, so to ensure correct date, time and zone once and for all is a good thing.

Setting the date
sudo date +%Y%m%d -s "20081128"

Setting the time
sudo date +%T -s "08:23:00"

Setting the timezone
This is done by making /etc/localtime into a symbolic link that goes to the timezone the server is to use.
sudo ln -sf /usr/share/zoneinfo/your/zone /etc/localtime

Setting UTC or local time
Change the content of the file /etc/sysconfig/clock to “UTC=true” or “UTC=false” (in norway it’s true).

Setting the hardware clock
Synchronizes the hw clock and system clock. Only add the “–utc” parameter if you are using UTC:
/sbin/hwclock --systohc --utc

Regurlarly synchronize the clock toward Network Time Protocol
This is done by adding this to crontab (ensure that the path to rdate is correct beforehand):
# update time with NTP server
0 3, 9, 15, 21 * * * /usr/sbin/rdate 128. 2. 136. 71 | logger -t NTP

Automount Windows Active Directory shared drives in Linux

Friday, August 28th, 2009

Requirements:
Likewise-open is installed and working.

Likewise-open plug in to pam to authenticate Windows AD users on a linux box. pam-mount will mount shared drives at login time using the login credentials. There is no need for samba to do this, and no need to write down your username and password in a file.

  1. Install pam-mount.
    sudo apt-get install libpam-mount
    sudo mkdir -p /media/shared_folder_name
  2. Set up shared drives to mount:
    sudo gedit /etc/security/pam_mount.conf.xml
    <!-- Volume definitions -->
    <!-- <volume fstype="cifs" server="server ip adress" user="*" path="to_shared_folder" mountpoint="shared_folder_name" /> -->
    <volume fstype="cifs" server="192.168.140.00" user="*" path="felles" mountpoint="/media/server_felles" />
  3. Make gdm automatically mount shared folders at login:
    sudo gedit /etc/pam.d/gdm
    At the bottom of the file, add the following:
    @include common-pammount

Reboot and log in again. The shared drive should be available.

Resources:
wiki.ubuntu.com