#Linux system how tos

<a name="set_system_date"></a>

##Set the system date & time

Your Acme board has two clocks:

*  One called **System Clock** that is a software clock maintained by the Linux Operating System
*  Another one called Real Time Clock (RTC) and implemented in hardware inside the Atmel CPU. This clock is powered by a Lithium battery to mantain the clock alive when the main power supply is off.

### The System Clock

[date](http://www.manpages.info/linux/date.1.html) is the Linux command to manage the systems clock.

To read the currently System Clock type:

<pre class="terminal">
~# <b>date</b>
Fri Oct  8 17:44:42 CEST 2010
</pre>

To set it type:

<pre class="terminal">
~# <b>date -s "8 OCT 2010 18:45:00"</b>
Fri Oct  8 18:45:00 CEST 2010
</pre>

This time is active until the main power supply board is on. When off the system clock is lost.

### The Real Time Clock (RTC)

To read the Hardware Clock type:

<pre class="terminal">
~# <b>hwclock -r</b>
Fri Oct  8 17:46:43 2010  -0.004115 seconds
</pre>

To set the Hardware Clock using the System Clock current time  type:

<pre class="terminal">
~# <b>hwclock -w</b>
</pre>

Now check it typing:

<pre class="terminal">
~# <b>date</b>
Fri Oct  8 18:49:02 CEST 2010
~# <b>hwclock -r</b>
Fri Oct  8 18:49:10 2010  -0.004076 seconds
</pre>

<!--------------------------------------------------------------------->
<!--------------------------------------------------------------------->

<a name="keyboard_configuration"></a>
##Set the keyboard configuration

<pre class="terminal">
~# dpkg-reconfigure keyboard-configuration
~# invoke-rc.d keyboard-setup start
</pre>

<!--------------------------------------------------------------------->
<!--------------------------------------------------------------------->

<a name="eth_config"></a>
##Set the speed and duplex settings of eth

###Change the Ethernet setting on the fly

To change the Ethernet parms on the fly type this command:

<pre class="terminal">
~# <b>mii-tool [-F mode] eth0</b> 
...
</pre>

Where <b>mode</b> can be:

* 100baseTx-HD
* 100baseTx-FD
* 10baseT-HD
* 10baseT-FD

The setting will be valid until the next system reboot.

[Mii-tool Man page](http://net-tools.berlios.de/man/mii-tool.8.html)

###Change the Ethernet setting at the end

Edit the <b>/etc/network/interfaces</b> file and the bold line if you are using
the dchp:

<pre class="terminal">
auto eth0                                                                       
iface eth0 inet dhcp                                                            
  <b>up mii-tool -F 10baseT-HD eth0</b>
</pre>
 
or this line if you are using a static IP configuration:

<pre class="terminal">
auto eth0                                                                      
iface eth0 inet static                                                         
  address 192.168.1.10                                                                      
  netmask 255.255.255.0                                                         
  gateway 192.168.1.1
  <b>up mii-tool -F 10baseT-HD eth0</b>
</pre>

the reboot or type:

<pre class="terminal">
~# <b>ifdown eth0</b>
...
~# <b>ifup eth0</b>
...
</pre>

<!--------------------------------------------------------------------->
<!--------------------------------------------------------------------->

<a name="usb_automount"></a>

## USB memories automount

This article explains how to automount an USB stick when inserted and unmount it automatically when unplugged

### Install the required packages

The automounter facility is managed by **autofs**. Autofs controls the 
operation of the automount daemons. The automount daemons automatically 
mount filesystems when they are used and unmount them after a period of 
inactivity. This is done based on a set of pre-configured maps.

To install autofs type:

<pre class="terminal">
~# <b>apt-get update</b>
~# <b>apt-get install autofs</b>
</pre>

### Configure autofs

Insert an USB stick and check on which device it appears by typing:

<pre class="terminal">
~# <b>dmesg</b>
</pre>

<pre class="terminal">
usb 1-2: new full speed USB device using at91_ohci and address 2
scsi0 : usb-storage 1-2:1.0
scsi 0:0:0:0: Direct-Access     UDISK    PDU01-8G 8AH2.0  0.00 PQ: 0 ANSI: 2
sd 0:0:0:0: [<b>sda</b>] 15794176 512-byte logical blocks: (8.08 GB/7.53 GiB)
...
sd 8:0:0:0: [sda] Assuming drive cache: write through
 sda:
...
</pre>

In this case the device is <b>/dev/sda</b>. If your USB stick has more than one partition you will see sda1, sda2, etc. for each partition.

Edit the file <b>/etc/auto.master</b> adding this line:

<pre class="minicom">
/var/autofs/removable   /etc/auto.removable --timeout=2
</pre>

Where:

*  <b>/var/autofs/removable</b> is the directory where  your USB stick will be mounted
*  <b>/etc/auto.removable</b> is another file that we have to create
*  <b>--timeout=2</b> tells that the device will be umounted after 2 seconds of idling

Now create the file <b>/etc/auto.removable</b> with this contents:

<pre class="minicom">
usbstick	-fstype=vfat,rw,umask=002	:/dev/sda
</pre>

then restart autofs typing:

<pre class="terminal">
~# <b>/etc/init.d/autofs restart</b>
</pre>

Now move to the <b>/var/autofs/removable</b> directory:

<pre class="terminal">
~# <b>cd /var/autofs/removable</b>
/var/autofs/removable# <b>ls</b>
/var/autofs/removable# <b>ls usbstick</b>
[ .. list on my files on the usbstick ]
</pre>

As you can see the usbstick directory will appear when requested and disappear after 2 seconds.

### Related links

* [AutoFs doc from Debian](http://wiki.debian.org/AutoFs)
* [The article from which I drew inspiration for this tip](http://www.greenfly.org/tips/usb_drive.html)
* [Autofs Man pages](http://linux.die.net/man/5/autofs)

<!--------------------------------------------------------------------->
<!--------------------------------------------------------------------->

<a name="disable_system_logs"></a>
##Disable the system logs

###Disable rsyslog

The most part of application program log created on **/var/log** are created by **rsyslog** daemon. To disable it type:

<pre class="terminal">
~# <b>cd /etc/rc2.d</b>
/etc/rc2.d# <b>mv S01rsyslog K01rsyslog</b>
</pre>

###Disable /var/log/dmesg

The system message log on **/var/log/dmesg** is created by **bootlogs** daemon. To disable it type:

<pre class="terminal">
~# <b>cd /etc/rc2.d</b>
/etc/rc2.d# <b>mv S01bootlogs K01bootlogs</b>
</pre>

###Disable /var/log/lastlog

Comment the line:

<pre class="minicom">
session    optional   pam_lastlog.so
</pre>

in **/etc/pam.d/login**.

<!--------------------------------------------------------------------->
<!--------------------------------------------------------------------->

<a name="remove_packages_cache"></a>
##Deleting the cache of package files to save space

The Debian package installation utility **apt-get** keeps all the packages it has downloaded in case they are needed in the future in **/var/cache/apt/archives** directory.

It is possible to save space removing them by typing:

<pre class="minicom">
~#<b>apt-get clean</b>
</pre>
