Friday, November 30, 2001

Sharing Directies under linux using NFS

Linux (or UNIX in general) can share directories with other machines in a network with the NFS utilities. These are a set of programs (daemons) that might have been installed with you put Linux in your machine. How to make NFS work is a complicated matter that requires a post (or posts). In this post I will only explain how to configure the different options to share directories via NFS. I assume therefore that NFS runs in your machine when it boots.

The configuration file for NFS is /etc/exports There you write which directories have to be shared, with which machines, and the possible options. An example of an entry in that file is the following:

/usr/local/ host1.localnetwork.domain(rw)

This means that the host called host1.localnetwork.domain can access the directory /usr/local from the machine where you are working, and can read and write (rw) in it.

A general entry has the following format (there can be many entries in the file):

directory host(options)

Here directory is the directory from the local machine that you want to share across the network. The host is the name of the host or hosts that are allowed to access the given directory. You can put a single host as in the example above, or you could give a range with something like *.localnetwork.domain which means all hosts whose names end in localnetwork.domain. You can also put * which means any host connected to yours; it could be in the local network, or in any part of the world if you are connected to the Internet without any restricitions like firewall, so be carful when you use the star symbol (called a wild card). You can also specify the hosts with a combination of IP numbers and netmask (don’t worry if you do not know what I mean). For example, a host entry like means all hosts with IP number from to This is equivalent to

Some options you can include are the following:

1. rw the machines authorised can read and write in the given directory
2. ro for read-only
3. async is a technical option that means when a client (a machine that has shared a directory from yours, say) writes something the server (your machine) will not wait for the file to be written in the hard disk and continue the "connection" with the client
4. sync is the opposite of the previous option: the server waits for files to be written to the disk before it informs to the client that the operation is done. If you do not put any of these two options the sync one will be assumed.

For more information you can look at the manual page of exports (man exports) or of the program exportfs. I will post on this program in the future, and more on NFS details too.

Sunday, November 18, 2001

Shared Library Dependency

Check for a particular Program what all library it uses :

[root@mybox unix]# ldd /usr/sbin/grub => /lib/ (0x40023000) => /lib/i686/ (0x40063000) => /usr/lib/ (0x40193000)
/lib/ => /lib/ (0x40000000) => /lib/i686/ (0x4019a000)

This will print the shared library Dependencies

Saturday, November 03, 2001

Memory Status

Processes use memory (RAM) to run. Actually, most Linux computers have two types of memory: RAM and swap space (okay, hard disk and other storage devices are also consider memory, but let’s use this term for things that get erased when you put off the computer). The RAM comes with the computer system as a set of chips that store data as long as the machine is powered. Its access time is much faster than hard disk’s access time, and programs are loaded into memory by the Operating System for execution. Since RAM might not be enough, Linux has one part of the hard disk known as swap space that acts like an extra RAM, though a little slower.

If you want to know how much RAM and swap space is available and used in your machine, type free. The output of this command depends of course on what is running in the system: more processes means less memory free.

Another command related to memory usage is memstat, which tells you what files/processes are using memory, how much and the process number. One possible way of using this command is as this example:

memstat | sort -n

This will sort out the output by the memory usage, so you get the processes using more memory at the end of your output, which can be useful to identify processes that consume resources.