Thursday, July 30, 2009

The directory tree in Ubuntu


The directory tree is the hierarchal structure that organizes directories and files in a Unix-based system. In the Unix directory tree, the top order of the hierarchy is the root directory. A good understanding of the Ubuntu directory tree will make your work with linux easier. Below, you will find each of the directories under the root directory, along with some of the important files and subdirectories they contain. Understanding which directories are home to certain files is essential to your exploration and mastery of the shell.

/bin - The bin directory contains the commands and utilities that are used most commonly in GNU/Linux like ls, cd, and rm. Since these are executable binary files, the directory is named bin for short.

/boot - The boot directory contains the Linux kernel, the bootloader configuration files, and all other files that the system needs in order to start up, or boot.

/dev - This is where all of the device files for the system are stored. This directory is rather unique since the files are actually the hardware devices themselves and are treated just like files in that you can read and write them. The label /dev/sda (or /dev/hda) refers to the computer's first hard drive. SCSI drives are labeled sda, while IDE drives are hda.

/etc - Pronounced "et-see," this directory is home to all of the system-global configuration files for all system users. For example, /etc/passwd contains information that defines all of the user accounts, while /etc/init.d is home to the scripts that run when Ubuntu is booting up.

/home - Home is where the files are—the user's files, that is. This is where documents, music, pictures, videos, and so on, are stored for the individual user. Its size depends on how many users will be using the system and what files are to be stored in their directories. Each user on a computer has his or her directory under /home.

/lib - Shared libraries and kernel modules are stored in this directory. The files here are similar to DLL files in Microsoft Windows.

/media - The media directory serves as the mount point for all external devices like CDs or DVDs. Devices mounted to the media directory are done automatically.

/mnt - The mnt directory is home to temporarily mounted devices like a network shared folder. Mounts to the mnt directory are done manually as opposed to automatically as with the media directory.

/opt - The opt directory is used to store software that is not managed by the package manager. These are generally add-on software packages that the user downloads outside of the Ubuntu repositories.

/proc - The proc directory is actually a virtual directory that provides a means for the kernel to communicate with the processes running on the computer. Each process that is running is assigned a numbered entry, which we will learn more about shortly.

/sbin - This directory contains files and commands like the bin directory does; however, the programs housed in sbin are only used in system administration tasks and require superuser privileges to run them. When you run something using the sudo command, odds are it comes from this directory.

/srv - This directory is home to the data files used to run services like HTTP, FTP, or TELNET.

/sys - This is another virtual file system that was added for plug-and-play devices. It contains files showing the resources that are allocated to each device on the system.

/tmp - The tmp directory stores temporary files. Nothing more, nothing less. Some applications — including archive manipulators, CD/DVD authoring tools, and multimedia software — may use /tmp to temporarily store image files.

/usr - This is the directory that stores everything for the user's applications such as dictionaries for spell checkers, documentation, and source code files. Subdirectories such as /usr/bin and /usr/lib contain all user programs, libraries and documentation.

/var - Files that change while the system is running are stored here. Log files, print spools, cache files, and anything else that would be considered a dynamic file would be found in the var directory. The size of this directory depends greatly on the usage of your system.

Note: There is a difference between the root directory, which is /, and a /root Note subdirectory. The / directory is the directory where everything branches out from. This is what we consider root. The /root subdirectory is the home folder for the root user.

Unless you are doing some configuring actions on your computer, you may never have to go into some of these directories; however, it is good to know what they are used for so that you don't accidentally do anything to them or the files they contain while you are working in the shell.

No comments: