Home> Linux> Understanding the directory structure

Understanding the directory structure

This article was posting on my old blog, I decided to bring him here too:)

A Linux system usually have a directory structure a bit complex. The files there willing, in principle, seem to be randomly thrown in various directories. But fortunately, there is a certain order and logic by making each system directory has a specific purpose. Before we understand the directories Precisamo take a stroke and some useful information that will be very useful in the near future and also helps to explain why the directories (if you're wanting to be a developer or one).

Filesystem

File System is the way the operating system uses to represent certain information in a storage space. It is the method of identifying and indexing information that is stored on any media: floppy disks, hard drives, in memory, CDs, etc..

When preparing for a hard to work through the process of physical format, it creates the magnetic media required to store the data. This process makes the preparation of a storage device so that it can receive a file system and eventually the User Data. A file system is therefore necessary to maintain standards, to control the size of the partitions, file permissions, file sizes and your organization, among many other functions. It will be seen first that the main types of file systems that exist and are created in a process of formatting:

ext: extended file system (extended filesystem). Is the file system widely used in Linux. There are ramifications (ext2 and ext3), and ext3 the most widely used by the Linux community today. It provides standards for regular files, directories, device files, symbolic links and transaction support (journalling), among other advanced features.

vfat: this is the file system (FAT volume) systems Windows9x and Windows NT.

ntfs: this is the file system of systems Windows2000, Windows XP and NT, and others.

nfs: file system network used to access directories on remote machines, which allows the sharing of data across the network.

reiserfs: file system with support for features such as better performance for very large directories and transaction support (journalling).

iso9660: File System CD-ROM.

hpfs: File System OS / 2 ®.]

continued ... ..

First thing you need to get used to is that Linux disks and partitions not necessarily appear as different units, such as C:, D:, E: Windows. It's all part of a single directory called root directory (root) or simply "/".
Within this directory we have not only all the files and disk partitions, but the CD-ROM, floppy drive and other devices, forming a structure that you see in the file manager.

/ bin - is the directory that contains the minimum necessary to operate and can be handled by the administrator. Will be necessary tools that are in other directories to which the machine is operational. Most of the programs has its executable file in this directory.

/ boot - contains information to boot the system. It is here that usually gets the file containing the kernel of the machine and information for the operating system loader.

/ cdrom - not really a directory, but a link to the directory / media / cdrom (mount point of the device CD / DVD machine;

/ dev - is where the references are stored on devices in the machine, to control these devices. This directory contains links to, for example, the floppy drive, the machine disks, virtual terminals, gateways serial and parallel, etc.. The drivers are automatically created during installation of the system and then can be created using the MAKEDEV command.

  • devfs - contains all files, devices, including devices that do not exist on your computer and will take up disk space.
  • udev - used from kernel 2.6.12, does not occupy disk space and contains only the files of the devices-devices in the dishwasher.

/ etc - is one of the most important directories of the machine. In it are most of the configuration files and manipulation of essential services to the system, most configuration files, network access and communication, configuration files of the X Window System, configuration files, system language, updates, Finally, many features of the machine.

/ home - contains the home directories of users and their settings (works like the My Documents in windows).

/ lib - is the directory where libraries are the basic system. They are shared by several programs, especially those who are in the root directory.

/ mnt - is the directory used for access to media devices such as diskettes and CD-ROM. It is used as a mount point for most of these devices.

/ proc - not really a directory. This is a virtual filesystem, full virtual file, which actually are just references the dynamic procedures (procedures) of the Linux Kernel, which are changing constantly while using the system, provides information about the kernel and on the processes that are currently running, plus information on the use of some devices. Some kernel parameters can be changed directly to these files, making the changes takes effect immediately. This directory does not occupy any space on disk and the information presented there, are generated only when requested.

/ root - This is the root directory of the system (you can call the administrator if you wish, but not near me, because I remember the term used by other sisteminha (semi-) proprietary operating which do not really like ;-)). The only system with User's permission to make any modification to the system. Then you ask me: "But gmazk, if a User folder, because it is inside / home?". I explain: as you will see in my next release (regarding planning the partitioning of the machine and system installation), it is desirable during installation of the system determines that the home directory is mounted on a separate partition on the primary partition (where are the other system directories). If he were in the root partition (under / home) and occur with this partition, which I call a "moment PUTZ ... screwed!" The folder / root would also be inaccessible, and as you know, certain things can only be made in the system User-root ... So you could not, for example, initialize the system to perform a recovery in that partition;

/ opt - If you check the contents of this directory, most likely it will be empty. The initial idea was to store directory of programs that were not part of GNU / Linux distribution installed on your system, however, this method of separation is barely used; It can be useful for reasons of space.

/ sbin contains tools of interest to the root and which are generally used for basic machine. Are in that directory programs and those responsible for loading kernel modules, activation and interruption of network interfaces, maintenance of file systems and other activities.

/ srv - is a directory that has the same problem of neglect and loneliness that the opt directory, because it is never used ... The initial idea was to use it to store data that would be available for any server program that you used in the system, but was another idea that "it took";

/ sys - The name comes from sysfs (sys filesystem). It is the directory used by the Linux kernel to maintain current data on the hardware devices of the machine (do not confuse, it is not the same as / dev, since the / dev files are serving as liaison with the devices, but no information about them);

/ tmp serves as the repository for temporary files and is used for programs that are executed after activation of the system, ie, the directory serves as extra space for various programs and applications.

/ var - Contains files that are modified over the course of using the system (e-mail, temporary, print queues, manuals).

Within the / var find:

/ var / lib - Libraries that change while the system is running.
/ var / local - Variable files of programs that are running.
/ var / lock - locks to indicate that a program is using a particular device.
/ var / log - Log files of the system (errors, logins, etc. ..)
/ var / run - the important system files working until the next boot (and software kernel).
/ var / spool - Directory print queues, e-mail and other
/ var / tmp - temporary files of programs
/ var / catman - A cache for manuals that are formatted in hours of use.

The / usr

This is an interesting directory I need to explain better.the that has it? Contains files of tools and User Applications.

/ usr bin: Contains tools and applications of each usuário.Ao create a new User Account, the system automatically creates a folder / usr / bin
/ usr dict: directory that are stored dictionaries (dict the name derives from the English dictionary) and lists of terms of the User.
/ usr / doc: This directory contains the documentation system in use.
/ usr / info: In this directory we find the files for the GNU info system based on hypertext
/ usr / lib: Like the / bin directory of the root contains the libraries for implementing the tools, this time, however, these are the components of the tools, this time, however, these are the components of the tools that are in / usr / bin
/ usr / local: This folder contains local files, ie, unique to each system (or application), including documentation (/ usr / local / doc) and the program itself (/ usr / local / bin).
/ usr / man: directory that brings together the manuals that can be read with the command man.
/ usr / share: Contains files and components shared by several aplicativos.Nesse directory, we find several subdirectories with help files, icons, etc..
/ usr / src: This directory contains the source code (source) of the software available in the system. These sources can be viewed and modified freely.
/ usr / tmp: And the directory where are colocacos the temporary files generated User-active.

Commands File System

Here are the commands to deal with the file system (hard disks, drives and network partitions). For more information about the command use the

  $ man 

badblocks - Used to find physical defects in HD.
cfdisk - Similar to fdisk but with an improved interface.
df - Display free disk space.
dosfsck-Check and repair systems DOS FAT.
du - Shows the space it occupies a directory and the files inside.
dump - Used to back up an ext2 filesystem. The complement of this command is restore.
dumpe2fs - Backs up of blocks and groups.
e2fsck - Check an ext2 volume for errors.
e2label - Change the name of an ext2 partition.
fdisk - Used to create, edit and delete partitions on the HD.
fdformat - Format a floppy disk.
mount - Used to "mount" a file system. The complement of this command is umount.
restore - Used to restore a system ext2.
umount - Unmount the filesystem. The complement is the mount command.
cdrecord - CD Record
cdparanoia - Writes audio CDs.

Handling files and directories

cd - Change to a directory. If you do not specify anything it changes to your home directory.
chmod - Change permissions to access files and directories (Writing, Reading, etc. ..)
chown - Changes the Owners and crew of a file or directory.
chgrp - Change group of a file or directory.
cp - Copy files from one directory / folder to another directory / folder.
dir - Lists the contents of a directory (choose the command "ls").
find - Searches for files with certain characteristics in the directory tree.
ln - Creates a symbolic link to a file.
ls - List files in a directory.
mc - Midinght Commander. A complete file manager for the console.
mkdir - Creates a directory.
mv - Move or rename a file.
rm - Deletes files.
rmdir - Deletes an empty directory.
vdir - List the contents of a directory.
whereis - Locate the executable, source code and manual for a command.

References:
http://www.guiadohardware.net/dicas/linux-entendendo-arvore-diretorios.html
http://www.danbp.org/linuxcom.html
http://www.conectiva.com/doc/livros/online/10.0/servidor/pt_BR/ch02.html

Share:
  • Twitter
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • Rec6
  • Slashdot
  • FriendFeed
  • Digg
  • Print
  • PDF
  • email
  • Add to favorites
Tags: , , Categories: Linux Tags:
  1. No comments yet.
  1. No trackbacks yet.
Powered by SEO Platinum SEO from Techblissonline