Unix Tutorial


What is Unix?

Getting started

Hardware

Software

Basic Commands

vi Commands

 

Files

File Commands

Different types of file

File Redirection

Permissions

Pipelines / Filters

 

Directory

Directory Structure

Directory Command

Shell

Different types of shell

Compiling Program

Networking

Commands

Reference

Reference Commands

online help : Manpages

Useful links/Books

 

Search Engine

Unix File System Organization


Root ||Hidden files || Directories ||environment variable


Root

Top level of the Unix file structure file structure (/) is known as a root directory or slash directory, and it always has a certain set of subdirectories, including bin, dev, etc, lib, mnt, tmp, and usr.There can be a lot more, however.

You can obtain a listing of the files and directories in your top level directory by using the ls -C -F command.

%ls -C -F

AdobeFnt.lst kernel/ proc/
TT_DB/ lib@ sbin/
a/ lost+found tftpboot
b/ mnt/ tmp/
bin@ net/ tmp.devlink
cdrom/ nsmail/ tmp.devlinknew
dev/ nsr@

usr/

devices/ opt/

var/

etc/ ora01/ vol/
export/ platform/

home/

In this example,any filename that ends with slash (/) is a folder (Unix calls these directories).Any filename that ends with an asterisk (*) is a program.Anything ending with an at sign (@)is a symbolic link.


  • The bin Directory

    When the programs has been compiled,it is translated into what's called a Binary format.The bin directory is where all the executables binaries were kept in early Unix.Over time, as more and more executables were added to Unix, it became quite unmanageable to keep all the executables in one place and the bin directory split into multiple parts(/bin/sbin, /usr/bin)

  • The dev Directory

    Among the most important portions of any computer are its device drivers.Without them, you would not have any information on your screen. You would not be able to enter information (the information is read and given to the system by the keyboard device driver).
  • The etc Directory

    Unix adminstration can be quite a complex, invovling management of user accounts, the file system,security,device drivers and more.Unix designates the etc directory as the storage place for all the adminstrative files and information.

  • The lib Directory

    If programs want to include certain features,they can reference just the shared copy of that utility in the Unix library rather than having a new unique copy.Many of the recent Unix systems also support what's called Dynamic Linking, here library of functions are included on- the-fly as you start up the program.

  • The lost+found Directory

    When files are recovered after any sort of problem or failure,they are placed in the lost + found directory, if the kernel cannot ascertain the proper location in the system.

  • The mnt directory

    The mnt directory is an empty directory reserved for mounting removable filesystems like hard disks,removable cartridge drives, and so on.

  • The tmp Directory

    The tmp directory contains temporary files created by Unix system programs. The files are normally present when the corresponding program is running, but may also be left in the directory if the program is prematurely stopped. You can remove any temporary file that does not belong to a running program.

  • The usr Directory

    The usr directory consists of several subdirectories that contain additional Unix commands and data files. It is also the default location of user home directories.

    1. The /usr/bin directory contains more Unix commands. These commands are used less frequently or are considered nonessential to Unix system operation.
    2. The /usr/include directory contains header files for compiling C programs.
    3. The /usr/lib directory contains more libraries and data files used by various Unix commands.
    4. The /usr/spool directory contains various directories for storing files to be printed, mailed, or passed through networks.
    5. The /usr/tmp directory contains more temporary files.
    6. The /usr/adm directory contains data files associated with system administration and accounting. In particular, the /usr/adm/messages and /usr/adm/syslog files contain a record of system error messages, including those sent to the system console. These files are especially useful for locating system problems, including hardware problems. For example, an unusual number of disk errors on a drive indicates a defective or misaligned drive. Because messages in the file can accumulate rapidly, these files must be deleted periodically. See ``Checking and clearing system log files'' for more information.

     

top of the page


Hidden Files

A hidden file is any file with a dot as the first character of the filename.They are known as hidden files because they do not show up in a regular ls command and you do not get rid of them with a rm* command. It is common for Unix tools to create "dot" files for temporary files and to maintain control and history information.Users are also expected to create them as configuration files.

These are few files which are hidden :

.profile : this is a configuration file

.login : This is C shell termination file.

.cshrc : This is C shell configuration file.

.history : This is shell command history file.

.mailrc : This is mail configuration file

top of the page


The env Command

System remembers specifics about you using user enviornment.The user environment is a collection of specially named variables that have specific values.

To view your environment type

%env

top of the page