Sunday, December 21, 2014

linux file structure

Linux File Structure:

In the Linux file structure files are grouped according to purpose. The Linux system contains thousand of files located within many directories. All directories are organized in a tree-structure like manner.

  • The 'trunk' of the tree is the root directory.
  • The root directory is simply identified as a "/".
  • All other directories 'branch' off from the trunk.



/bin/

This is where all your programs that are accessible to all users will be stored once installed.
If you search this directory, you will find that both ls and pwd reside here. The cd command is actually built into the shell we are using (bash), which is in this directory too.

/dev/

This is a virtual directory where your devices are 'stored.' Devfs allows Linux to list devices (hard drives, input devices, modems, sound cards, etc.) as 'files.'
For instance, for a device that represents a hard drive, like /dev/sda, you can mount it to the filesystem to access it. On the other hand, if you have a file that represents a line printer like /dev/lpr, you can write directly to it to send the information to the printer.

/etc/

This is where you'll find all your global settings. Daemons such as ssh, telnet, and smtp/pop3 mail servers find their configuration files here. Also in /etc/ is the system's password file, group lists, user skeletons, and cron jobs.

/home/

This is the default directory where non-root users' homes are created. When you add a user, the default home directory is created as /home/username. You can change this default in the proper file in /etc/.

/lib/

This is where shared libraries (perl, python, C, etc.) are stored. Also in /lib/ are your kernel modules.

/mnt/

This is the default location for mounting cdroms, floppy disk drives, USB memory sticks, etc. You can mount anything anywhere, but by default there is a /mnt/floppy (if you have a floppy drive) and /mnt/cdrom.

/proc/

This virtual folder contains information about your system. You can view processor statistics/specifications, PCI bus information, ISA bus information, and pretty much anything else you want to know about the hardware on your system.

/root/

This is the home directory of the administrative user (called "root"). It functions exactly like the normal home directories, but is housed here instead.

/sbin/

This is where system programs are installed. These include fdisk, tools to make partitions, certain network tools, and other things that normal users shouldn't have a need for.

/tmp/

This is the default location to place files for temporary use. When you install a program, it uses /tmp/ to put files during installation that won't be needed once the program is installed.

/usr/

This contains various programs, non-daemon program settings and program resources.

/var/

This is where your log files, system mail messages and database of installed programs are stored.


At the time a new file is created, it gets a free inode. In that inode is the following information:
·         Owner and group owner of the file.
·         File type (regular, directory, ...)
·         Permissions on the file 
·         Date and time of creation, last read and change.
·         Date and time this information has been changed in the inode.
·         Number of links to this file (see later in this chapter).
·         File size
·         An address defining the actual location of the file data.



# ls -l
total 80
-rw-rw-r--   1 root   root   31744 Feb 21 17:56 intro.doc
-rw-rw-r--   1 root   root   41472 Feb 21 17:56 Linux.doc
drwxrwxr-x   2 root   root    4096 Feb 25 11:50 course

File types in a long list:
    Symbol
   Meaning
   -
 Regular file
   d
 Directory
   l
 Link
   c
 Special file
   s
 Socket
   p
 Named pipe
   b
 Block device

No comments:

Post a Comment