next up previous
Next: Disk Space and Usage Up: Introduction to the Linux Previous: Files That Aren't Files

Directories That Aren't Directories

You can use ln -s to make links to directories, and use cd to follow the link and take you to the directory it points to. This can be a little confusing, as it means doing cd .. will not always get you back where you started.

A more important type of directory is a mount point. In Linux different devices are not given names or drive letters, their contents are placed inside special directories. Usually all of a computer's hard drives will already be set up and you don't need to care about any of this, but it does matter when you have removable media such as USB memory sticks.

Taking a device with a filesystem on it and putting it under a particular directory is called mounting the device, and the directory you put it under is called the mount point. Usually only root can mount a device, but it is possible for root to set up predefined devices and mount points for everyone to use. This are found in a file called the file system table, /etc/fstab.

[phasnip@mijpnb1 ~]$ cat /etc/fstab
/dev/hda5 / ext2 noatime 1 1
none /dev/pts devpts mode=0620 0 0
none /dev/shm tmpfs defaults 0 0
/dev/hda7 /home ext2 noatime 1 2
/dev/hdc /mnt/cdrom auto user,iocharset=iso8859-1,umask=0,exec,codepage=850,ro,noauto 0 0
/dev/fd0 /mnt/floppy auto user,iocharset=iso8859-1,umask=0,sync,exec,codepage=850,noauto 0 0
/dev/hda1 /mnt/windows vfat iocharset=iso8859-1,umask=0,codepage=850 0 0
none /proc proc defaults 0 0
/dev/hda8 /usr/local ext2 noatime 1 2
/dev/hda6 swap swap defaults 0 0
/dev/sda1 /mnt/usb auto user,iocharset=iso8859-1,umask=0,sync,exec,codepage=850,noauto 0 0
/dev/sda /mnt/usb auto noauto,owner,user 0 0

Notice the last entry. Device /dev/sda has a mount point /mnt/usb defined.

[phasnip@mijpnb1 ~]$ ls /mnt/usb
[phasnip@mijpnb1 ~]$ mount /mnt/usb
[phasnip@mijpnb1 ~]$ ls /mnt/usb
Castep                   Italy      Wannier_and_Berry.ppt  wave.F90
dm2.dat                  linux.tar  wannier_mlwf.pdf       Workshop
edft2.dat                Old Rules  wannier_orig.pdf
Finding_Groundstate.ppt  Rules      wannier.ppt

Before removing any storage device from the system you must unmount it with the umount command.

[phasnip@mijpnb1 ~]$ umount /mnt/usb
[phasnip@mijpnb1 ~]$ ls /mnt/usb


next up previous
Next: Disk Space and Usage Up: Introduction to the Linux Previous: Files That Aren't Files
Phil Hasnip 2007-08-23