I have already earned $35 within month spending few minutes only

Wednesday, July 29, 2009






Celebrity Pictures Katy Perry Showing Her 'Josh Grobin' Chest Rihanna in A See-Through Shirt Audrina Patridge Smiles At Red Bull Toasted Rihanna Side Boob In Action Rihanna Is The Umbrella Girl Stacy Keibler in A Bikini At Mgm Grand Megan Fox At Comic Con Ashley Tisdale Leggy In Short Shorts Avril Lavigne Has Nice Cleavage Lisa Rinna Shows Of Nice Bikini Bod! Celebrity Pictures Links Platinum Celebs: Latest pictures, clips, news Source for celebs Celebrity News Car Pictures
Celebrities Games Celebrities in diamonds Celebrities In Magazine Britney Spears Carmen Electra Halle Berry Beyonce Knowles Ciara Katie Holmes Virgo: gossips and Pictures Lindsay Lohan Tara Reid Salma Hayek Pamela Anderson Hilary Duff Mary Kate Olsen Jennifer Garner Christina Aguilera Shakira Jennifer Lopez Ashlee Simpson Mariah Carey THE GHOSSHIP, All Celeb JUST LISTEN IT Dreaming AIBO TECHNOLOGY TODAY HOTMOVIES R.T.W.C THE EXOTIC JAVA MAKE US HOT HotOnlineNews AllAboutBritney PopBytes FatBackAndCollards Celebutaint The People We Love To Hate World Of Staci TMZ The Velvet Hot Tub Bricks And Stones Theblogyoulovetohate Yuleguan Rappy World Vipglamour Celebgossips Celebrity Pictures Archive Farandulista Stockings-Celebs Celebrity Pro Scandal Snappers Elegance Pixelfied Archivo Hose FlyLip Music Juice Celeb Dump Celebs Cosplay The Insider Right Celebrity Sexy Celebrity Pictures Celeb Gossip Crash Jeanette's Celebrity Corner Hollyweird Gazette Celebrity Skinned Feed Me Gossip Top Celebrity Headlines Britney Spears News, Britney Spears Picture, Britney Spears Crotch Shot Biggest Celebrity News Right Fielders Right Celebrity Talk Hot Music Beat Fundromeda MelodyPlant NY Blogger The Dishing Diva Gallery Celebrities Buzz Beyotch Right TV Right Bollywood Celeblog Celebrity Gossip Gossip Thug ChicBlogClub SeenON! All Celebz Celebrity Gossip Gallery-Celebrity Models Bikini Celebrity in Bikini 10Ment Celebrity News Polls Celebrity Pictures Celebrity News Hot Lady Body Celebrity Style Hollywood Gossip Total Celebrity Pictures Entertainment Gossip

Saturday, July 25, 2009

Wednesday, July 22, 2009

An Introduction to Red Hat Linux

An Introduction to Red Hat Linux


Course Contents of Red Hat Linux –

1. File and Directory Operations
2. User Information
3. File Permissions
4. Linux File System Essentials
5. X-Window System and GUI application (introduction)
6. Standard I/O Pipes
7. String Processing
8. Process
9. VI editor
10. Bash Shell and Shell Scripting
11. Basic Network Clients



Introduction

An operating system (OS) is software designed to act as an interface between the computer and the user. It performs various important functions such as ,

· An OS is a command interpreter. It translates the high level language to machine language and vice versa.
· An OS acts as process manager. There are various processes running simultaneously in a computer. The amount of time to be spent on a process by the CPU is decided by the OS.
· An OS is a memory manager. As said above, there are various processes running simultaneously in a computer which require memory from CPU. The amount of memory to be allocated on certain process is also decided by the OS.
· An OS acts as a hardware or peripheral manager. The task of accepting input producing the output and redirecting to different peripherals is done by the OS.

About Linux

Linux is one of the popular OS in the market today. It is developed form of UNIX. So, most of its features are UNIX-like. Most of the tools found in UNIX are supported in Linux.

UNIX was designed and developed in 1960s to provide an environment to create programs. It became popular and got spread to educational institutes, research labs and industries. Later a Finnish student Linus Torvalds developed LINUX from UNIX and made the source code available on the internet. Later more developers added additional functions to LINUX.

UNIX principles
· Everything is a file including hardware.
· Configuration data are stored in the text format.
· Small-single purpose programs are present.
· It has ability to chain programs.

Linux has many unique features.
· It has a kernel programming interface. Kernel is responsible for controlling the resource and scheduling user jobs. All the programs interact with the kernel through system calls.
· Linux is a multi-user OS. This allows many users to access all the system resource almost simultaneously.
· It is a multitasking OS. It can run up to 32768 processes at a time.
· Files are arranged under a directory.


Structure of Linux system
Linux system structure consists of Kernel, Shell, Tools and Applications.

User Applications
Hardware
Kernel
Shell and Utilities

Layer view of Linux Operating System

Kernel is the heart of the Linux OS. It is loaded in the memory when computer is booted. It interacts with the hardware. It manages the system resources, allocates time for different users and process, and sets process priorities.

Shell acts as the interface between user and the computer. There are different types of Shell available in Linux. Among them, bash shell is widely used.

Linux has its own applications for word-processing, spreadsheet, creating presentation, image processing etc.


Simple Commands

Linux has six virtual consoles and one GUI console.
1. To switch between the text consoles, press
Ctrl+Alt+F1
Ctrl+Alt+F2
Ctrl+Alt+F3
Ctrl+Alt+F4
Ctrl+Alt+F5
Ctrl+Alt+F6,
To switch to GUI console, press
Ctrl+Alt+F7

2. To shut down the system, type “halt” in the command line and press enter.

3. date: To view and change current date and time.
· date (<┘): to view current system date and time.
· date –s mm/dd/yy : to change date
· date –s hh:mm:ss : to change time
· date –s ‘mm/dd/yy hh:mm:ss’ : to change both
· cal (<┘) : to view calendar of the current month and year
· cal 2004 (<┘) : to view calendar of the year 2004
· cal 7 2003 (<┘) : to view calendar of July 2003

4. To pause
more
or
less

press (<┘) to scroll one line at a time.
press ‘spacebar’ to scroll one page at a time.

5. To quit
press q (<┘)

6. To cancel a command, press
ctrl+c (<┘)

7. To clear screen
clear (<┘)


Getting Help

· For quick help
--help (<┘)

· For detailed help
man (<┘)

· Help files are also available in the directory
/usr/share/doc/

· Or we may also check the site
http://www.tldp.org
for linux documentation project.


File and Directory Commands

Directory Commands

NOTE:
. : represents current directory
.. : represents parent directory
/ : represents root directory
~ : represents home directory

1. pwd (<┘)
Displays the full pathname for the current directory.

2. ls (<┘)
Displays the list of files in the current directory.

ls /directory name (<┘)
Displays the contents of the specified directory.

This command various options to use. Some of them are as follows:
ls –l
Lists file in long format. Filenames are displayed along with their mode, number of links, owner, size, modification date and time.
ls –t
Lists in order of last modification time
ls –a
Lists all entries along with hidden files
ls –u
Lists in order of last access time


3. mkdir (<┘)
This command is used to create a new directory of specified name.

4. cd (<┘)
This command is used to change from working directory to any other directory specified.


5. rmdir (<┘)
This command removes or deletes the specified directory. The specified directory must be empty.



File Commands

1. cat command
Lists the contents of the specified file. If we do not specify the name of the file , it takes input form the standard input.

Options of cat commands are as follows:
cat
Displays the contents of the specified file.
cat –s
Suppresses warning about non-existent files
cat >
Creates a new file with specified file name. Takes input from standard input file. We can type in our text and terminate with ctrl+d to take us back to prompt.
cat >>
Appends data to the specified file

Conventions of filename
· Filename can be of maximum 255 characters.
· Special chars can be protected with quotes.
· Filename are case sensitive.
· Filenames beginning with dot is hidden file.

2. head (<┘)
Displays the first ten lines (default) the text file.
head –n N (<┘)
Displays the first N lines of the text file.
tail command is just the complement of the head command.


3. cp command
This command creates a copy of source file and gives the file name specified in destination file.
cp (<┘)

Options:
cp –i
Interactive
cp –r
Copies all the contents of dir1 to new directory dir2


4. touch …. (<┘)
Creates zero length (blank) files namely file1, file2, ….. fileN.

5. mv command
This command is used to rename and move ordinary and directory files.For this we need both execute and write permissions.
mv (<┘)

We can also use this command to rename files as follows:
mv (<┘)

6. rm command
This command removes the specified file.
The options available with this command are
rm -i
Prompts the user if he/she wants to delete the mentioned file.
rm -r
Recursively deletes the entire contents of the directory as well as the directory itself.
rm –ir
Interact with the rm command and deletes a directory.





Wild Card Characters
Group of files can be accessed using the wild card patterns.Various wild card patterns are as follows:
*
Match zero or more characters
?
Match any single character
[abx]
Matches any single character from given character
[a-e]
Matches by single character from given range
[^a-e]
Matches any single character except given range of character (^ stands for ‘not’)


User Information

The user information are stored in /etc/passwd. The file could be viewed by the root user.
The user information is stored and displayed in the following format.
username:x:user-id:GID:comment:/home-dir:/login shell

·Here, username specifies the name of the current user.
·x represents the shadow password. It is displayed instead of the actual password. The passwords are saved in /etc/shadow.
·User-id are the numbers. Zero (0) is for the root user by default Above zero till 499 specifies system users. While for the normal user it starts from 500.
·GID is the short form of Group ID. All the users are assosciates with a group in Linux OS. GID donates the user’s primary group number. User may be the member of more than one group. Primary GID is unique for all the users.
·Comments (finger information) are the information about the user. These are the common information which are not used in system.
·Home-dir is the home directory of the user. The user has the whole right in his/her home directory.
·Login shell


Some commands related to User Information

1. To create new user
useradd (<┘)

2. To assign password to new user
passwd (<┘)
Enter new password.

3. To change the user password
passwd (<┘) This command can be used by the user himself.
or
passwd (<┘) This command can be used by the root user.
Enter new password.
4. To change the comment of a user
chfn (<┘) chfn stands for “change finger”. This command can be used by the user himself.
chfn (<┘) This command can be used by the root user.

5. To view the finger information of any user
finger (<┘) This command can be used by the user himself.
finger (<┘) This command can be used by the root user.


6. To display the username of currently logged on users
· who (<┘)
Gives the details of the users who have logged in to the Linux system lately.


· whoami (<┘)
Gives details regarding login time and system’s name for the connection being used.
· w
Displays the users who are currently logged in.
· users
Displays the username of the users who have currently logged in. It displays only the usernames.

File Permission

Linux helps a very great deal in file security.
The Linux files can be classified into
- Directory files
- Ordinary files
- Special files
When a list of files is displayed using “ls –l” command, we can see the file-type and file permission specification in the first column (which is in the format drwxrwxrwx).

The first character represents the file type. Ordinary file starts with ‘-‘ and the directory files start with ‘d’.

The last nine charcters specifies the file permission.
The owner (one who created the file) of the file can perform any operation on the file. If the owner wants other people to access his/her files, then permission has to be granted by the owner.
Permission available are
r -> read (display, copy or compile a file)
w ->write (write, edit or delete a file)
x -> execute (execute a file)
The permissions are given from the second position onwards. The first three characters indicate the permissions of the owner of the file. The next three positions indicate the permissions of the group which consist of the owner and the last three indicates the permission for others.

To change the file access permission (FAP)

The mode of the file can be changed using ‘chmod’ command.
FAP can be changed for one user or for all the users. This can be done by specifying the name of the user before +/- sign.


‘u’ indicates the owner of the file.
‘g’ indicates the group which consists of the owner.
‘o’ indicates the others.
‘a’ indicates the all.

‘+’ is used to grant permission
‘-‘ is used to revoke permission
‘=’ is used for absolute assignment

syntax:
chmod user+/-permission characters (<┘)

For example,
chmod u+rwx file1 (<┘)
This command grants all the permissions to the owner.

chmod u-wx,g-wx,o-wx file1 (<┘)
This command revokes write and execute permissions from the entire user category.


Octadecimal Representation of FAP

FAP can be represented Octadecimally. The octadecimal values are as follows:
Numbers
Values
0
000
1
001
2
010
3
011
4
100
5
101
6
110
7
111

If a file has the permission set, then the value allotted is 1 else it is 0. If FAP is represented by 111, it means all the permissions are granted. The corresponding value for 111 is 7. So, the following command
chmod 777 file1 (<┘)
grants all the permissions for all the users.




Linux File System Essentials

Linux treats all the information as files. Directories and hard devices are also treated as files. They are stored in single rooted hierarchical order and grouped together which enables easier search of files. The supermost directory is called root directory and is represented by ‘/’. Only root doesn’t have a parent directory.

Linux file system can be shown as follows:

Root ‘/’ directory consists following subdirectories:

/bin
Consists of executable user programs
/usr
It is the home directory of the
/sbin
Contains system programs
/lib
Contains library files
/root
It is the home directory of the super user ie root user
/var
Location for variable files such as mail spools, print spools, log files etc
/mnt
Typical location for mount points mounted after system is booted
/etc
Consists of configuration files
/boot
Kernel and other files used during system startup
/lost+found
Used by file system check to place orphand files
/dev
Contains device files
/proc
It is the virtual file system containing system information used by other programs and kernel parameters
/home
Default location for user’s home directory
/opt
Installation directory for some third party programs such as star office
/tmp
Consists of temporary files

***----------------------------------------***
Remained to write about ext2/3 file systems
Filesystem metadata etc etc

Inode metadata

Stat command
***---------------------------------------***



Managing Devices

As has already been stated, Linux treat everything as a file. Even the hardware devices in which files are stored are treated as files. The special files that represent the hardware devices are kept in the directory /dev. Devices may be either Character Device or a Block Device.

The character device is a device in which we can read a sequence of characters. For instance, keyboard is a character device. They are also called sequentially accessed device.
While, a block device is the one in which we can read a block of data at once. Blocked devices have a fixed capacity and it allows accessing every part equally. Hence also called random access device. Floppy and Hard disks its examples.
The kernel identifies the type of the device by looking at the file mode, at the far left of the output of ls –l command.

Mounting Removable Media

The mount command can be used to mount blocked device (only) on the filesystem.
Syntax:
mount –t (<┘)

- fstype signifies the file system type to mount.
- device file represents a particular device to be mounted.
- mount point must be a directory and it need not be empty. When a filesystem is mounted in this directory, all files under the directory become inaccessible.

Floppy Disks
A floppy could be mounted with a filesystem such as msdos or vfat for FAT file system.
The device file corresponding to the floppy disks begin with the letters fd. /dev/fd0 represents the first floppy disk and /dev/fd1 for the second if exists. The device file /dev/fd0H1220 denotes a 1.44MB high density floppy.
CD-ROM Drive
A CD-ROM have a standard iso9660 filesystem.
The device name /dev/cdrom is used as a symbolic link to the actual device.
The audio CDs cannot be mounted.

In the above syntax, the fstype and deivce file are optional. Those details are retrieved from the /etc/fstab file. The mount point can be specified only if filesystem to mount is specified in /etc/fstab file.
Example of mount command :

mount /mnt/floppy (<┘)
mount /mnt/cdrom (<┘)
mount -t msdos /dev/fd0 /mnt/floppy (<┘)
mount -t iso9660 /dev/cdrom /mnt/cdrom (<┘)


To view the contents of the files in the media

cd /mnt/floppy (<┘) (for floppy disk)
ls (<┘)

cd /mnt/cdrom (<┘) (for cds)
ls (<┘)

After the use of the media, it is necessary to unmount it.

To unmount the media,
unmount (<┘)

Mounted CD-ROM cannot be ejected before unmounting. The following command first unmounts the CD Drive and then ejects it.

eject (<┘)


Links

There are two types of link available in Linux.
Hard Link and Soft or Symbolic Link.

The hard link establishes an additional filename for the existing file. Any modification made in one is reflected in both of them. Creating hard link does not take additional memory. Although we see two files, the same hard drive space is used for both.

Symbolic links are different from hard links in the sense that a symbolic link is a pathname, or alias, to the original file. Nothing happens to the original file if you delete the symbolic link.



To create hard link,
ln (<┘)
For directories, hardlinks cannot be created.

To create symbolic link,
ln –s (<┘)


Searching Files
There are two commands in Linux to search files in a directory and subdirectory.

slocate: This command accesses the database containing filenames and location to
find a file.

syntax:
slocate (<┘)

find: This command scans the actual file system.
syntax:
find ≥ dir ≤ [options] [action]

- dir is the directory name where file is to be searched.
- There are various options available with the find command. They are as follows:
-atime +/-N
List files that were accessed more or less than N days ago
-mtime +/-N
List files that were accessed more or less than N days
-user username
List files owned by user in username
-size N[c]
List files containing N blocks or if c is specified N characters long
-type filetypechar
List files whose type is filetype character
File type characters :
d for directories
b for block device file
c for character device file
l for soft link
f for regular or normal file
-name pattern
List files whose name matches to the pattern
-iname pattern
Same as above but case sensitive

- action can be as follows
-exec command {} \;
or
-ok command {} \;
The exec action executes the specified command on the found files.
The ok action is similar to exec. The only difference is that, it is interactive in nature.

Compression Utilities

Compression utilities are used for saving disk space by compressing large, less often used files. The compression utilities in Linux are
- gzip , gunzip (By default, extension of the compressed file will be .gz )
- bzip , bunzip (By default, extension of the compressed file will be .bz2 )

To compress file
gzip (<┘)
The compressed file is created in the current
directory. The original file is deleted.
gzip -c > (<┘)
The original file is not deleted.
bzip2 (<┘)
bzip2 –c > (<┘)

To uncompress file
gunzip (<┘)
The uncompressed file is created in the current
directory. The original file is deleted.
gunzip -c > (<┘)
The original file is not deleted.
bunzip2 (<┘)
bunzip2 –c > (<┘)


Archive Files (Backups)

Taking regular backups is one of the most important tasks. Backup copies are essential when the system malfunctions and files are lost or when a user deletes a file accidentally. Backup files are usually kept on floppy or magnetic taps. Writable CDs are also used.
One of the Backup Utilities provided by Linux is “tar”. The tar (tape archive) utility is used to store and retrieve files from a tape archive. Compression utilities could also be used to compress the archive, thus saving space. The archive can be written into hard drive, a tape drive, or nearly any other Linux device.
syntax:
tar [options] (<┘) .

The following options are available for tar command:
-c
Creates a new archive
-v
Verbose
-f
Specifies filename
-x
Extracts file from archive
-t
Test (list files in archive)
-z
Use gzip compression utility
-j
Use bzip compression utility

Here, ‘-‘ is optional. –c and –x can’t be used together.

Tar always restores files in the current directory. To restore file,
tar [options] (<┘)


X-Window System and GUI Applications (introduction)

An X-Window System is an application to provide GUI Environment. It is designed to be a machine/OS independent networked client/server program. As a result, the system is broken up into two major components: the X-Window server that runs on the machine and interacts with the monitor, hardware and the various clients. Component displaying is done by X-Client.
X-Free86 Package is used in Linux for GUI environment.

There are different window managers available with the X-Window System under Linux, each with different features. They are
- gnome
- KDE
- TWM
All these allow us to perform the basic operations.
To switch between displays, we may use following command.
If we are in run level 3,
switchdesk (<┘)
If we are in run level 5, then
- click start
- run program
- switchdesk
- select the display


The various GUI applications available in Linux are as follows.

Text Editors
- xemacs
- gvim
- dedit
- kwrite
Web Browsers
- mozilla
- galleon
- conqueror
- lynx
- links
File Manager/Web Browser
- nautilus
Task Manager
- Gnome-system-monitor
FTP Client
- gftp (to upload and download files)
Graphics Manipulation Program
- gimp
IRC chat client
- xchat
Mail Clients
- kmail
- balsa
- evolution
- mozilla
Office application
- koffice
- Gnome
- OpenOffice
Audio Application
- xmms
- gnome-volume-control
- gnome-cd
- mplayer for video CDs
Develop Environment
- kdevelop
X-Configuration
- redhat-config-xfree86 (Could be run in GUI or Text terminal)


Input/Output Redirection

By default,
- the standard input device is keyboard
- the standard output device is terminal window and
- the standard error is also displayed in the terminal window.
However, input can be taken from other sources like file itself and output can be passed to sources like printers or files etc. Such a process of changing the default assignment of input and output devices is called redirection.

For output redirection, following command is used.

command > (<┘)
Redirects the output to the specified file in overwrite mode.
command >> (<┘)
Redirects the output to the specified file in append mode.
command 2> (<┘)
Redirects the error to the file in overwrite mode.
command 2>> (<┘)
Redirects the error to the specified file in append mode.

For input redirection,
command < (<┘)
Redirects the input from the specified file. If the file does not exist, the shell will issue an error and abort the operation.

For input and output redirection
command < > (<┘)
This command takes it’s input from the source and redirects the output to destination.


Standard Input/Output Pipes

Pipes help in performing multiple tasks in a single command line. A pipe takes output of a command as input to another command. The pipes are considered as temporary unnamed files stored in memory. This prevents the user from making temporary files using redirection.

syntax:
command1 command2 command3 (<┘)

Here, the output of command1 acts as the input for command2. And the output of command2 is used as input to command3. The final output will be displayed on the standard output if the output redirection is not done.

The ‘tee’ command
This command is used to store an output of a command in a file as well as send it to another command as an input.
For instance,
ls –l tee mylist lpr (<┘)
This command will store the output of ‘ls’ command in the file ‘mylist’ and also will send it the printer.


String Processing and Filters

The ‘wc’ command
The wc command is used to count the number of lines, words or characters in a specified file.
syntax:
wc [options] (<┘)

The options for the wc command are as follows:
-l
For line count
-w
For word count
-c
For character count


The ‘cut’ command
This command extracts one particular field from the specified file or output of any command.

syntax:
cut [options] (<┘)

The options are
-d
Represents the delimiter or the field separator
-f
Used to specify the list of fields that have to be displayed
-c
Used to extract single character


The ‘diff’ command
This command compares two files for differences. If found, it displays the lines which are different.
‘<’ refers to the contents of first file
‘>’ refers to the contents of second file.
syntax:
diff (<┘)


The ‘paste’ command
This command merges the contents of two or more files into a single file. It reads a line from each file in the file list specified and combines them column-wise into a single file.
The contents of the first file are displayed in first column.
The contents of the second file are displayed in second column and so on.
They are separated by tab by default. If we wish to change the delimiter, ‘-d’ option can be used as in cut command.

syntax:
paste (<┘)

Example:
paste > (<┘)
This command merges file1 and file2. The merged file will be saved as
newfile.

The ‘tr’ command
‘tr’ stands for translate. This command reads standard input and, for each input character, maps it to an alternate character, deletes the character, or leaves the character alone. The output is written to the standard output.
‘tr’ does not take a filename as a parameter. But redirection operation could be used.

syntax:
tr ‘’ ‘’ (<┘)


The ‘aspell’ command
This command is used to check spelling in a file.
syntax:
aspell check (<┘)


Filters
Filters are used to extract the lines, which contain specific pattern, to sort, to find and replace etc. Filters are also used to store the intermediate results of a long pipe.


The sort Filter
The sort filter arranges the input taken in the alphabetic order. The original file remains unchanged.
The options available with sort are
-r
Reverse alphabetic order
-n
Sorts according to the ascii value (numeric sort)
-u or uniq
Stands for unique. Removes duplicates. This is case sensitive.
-f
The case distinction is ignored.
-t x
Use x as a field separator. The default field separator for sort is blank space or tab.
-k pos
Sorts from the field pos.
syntax:
sort [option] (<┘)


The grep Filter
‘grep’ stands for “global search for regular expression”. It is used to search for a particular pattern from a file or standard input and display those lines on the standard output.
syntax:
grep (<┘)


The ‘sed’ Filter
‘sed’ stands for stream editor. This command searches a particular pattern and replaces it with the replace string. But the changes are not reflected in the original file.
syntax:
sed ‘s/search-string/replace-string/g’ (<┘)

The ‘g’ is used to replace all the search strings. If ‘g’ is not specified, the
command will replace only the first occurrence of the search string in a
line.


The ‘awk’
An ‘awk’ is a scripting language. ‘awk’ program can be entered in a number of ways on the command line. It is also used for pattern recognition. One of the methods of searching a pattern using awk code is as follows.

syntax:
awk ‘pattern {action}’ (<┘)
Example:
ls –l awk ‘$3==”user1” {sum+=$5} END {print sum}’
This command prints the total size of all the files under the ownership of
user1.



Process

A process is the basic context within which all user-requested activity is serviced within an O.S. In Linux, every process runs under another process (called Parent Process). So, every process is a child process. At a time there can be maximum 32768 numbers of running processes and consequently there can be 1 to 32768 processIds. All the processes created after login is controlled by terminal.

Init Process
It is the process that is executed during the booting process in Linux. Its processId is 1. It is the first process that is executed in Linux and is situated in the directory /sbin/init. Init process does not have any parent process because it is directly run by Kernel.

A process can be in following states:
R
Runnable
S
Sleeping
T
Stopped
D
Uninterruptible sleep (Not respondent task)
Z
Defunct (Zombie) process

When child process ask parent process to release its processed, parent process acknowledges releasing the process Id. But, due to some reason, if child process doesn't receive the acknowledgement, it is not released and the resulting state is said to be the zombie state.


Various commands related to the Process are as follows.

· Viewing process
ps command
‘ps’ stands for Process Status. It also displays the cumulative amount of time that the CPU has spent in the execution of the process.

The options of ps command are,
a
display all processes excluding the processes not controlled by terminal. It displays four columns for process Id, terminal, time, and command.

x
displays all processes including the processes not controlled by terminal
l
long listing; includes more information such as process owner's id UID.
u
displays the user name of process owner

· Running a process in the foreground
To run the process in the foreground, simply type the command and press enter.

· Running the process in the background
To run the command in the background following syntax is used.]
command & (<┘)

· Suspending (Stopping) a foreground process
To stop a foreground process, press
Ctrl + Z (<┘)

· Displaying the stopped and background process
To display the stopped processes and the background processes,
jobs (<┘)

· To display the process hierarchy, following command is used.
pstree (<┘)

· Terminating a process
We use KILL or TERM (default) commands to terminate a process.
syntax:
kill [ signal ] <>
TERM sends process the message as 'terminate yourself'
KILL forcefully free the resources using that process.

· Resuming the processes
To resume the jobs in foreground,
fg (<┘)
To resume the jobs in background
bg (<┘)


A process can have its priority form –20 to 19, -20 is the highest priority and 19 is the lowest priority. By default the priority of a process is 0.

· Running a process with specifies priority
syntax :
nice –n priority command (<┘)
Eg:
nice –n 10 find / -ml (<┘)

· Changing the priority of running program
syntax:
renice <-p PID -u username> (<┘)
The priority of the process having “PID” will be changed.
renice <-u username -u username> (<┘)
The priority of the processes under “username” will be changed.


Visual Editor(vi)
The editors help in creating and editing files. The editor in an OS has the same importance as the editor of the newspaper. Linux offers various tuypes of editors like vi, ex, sed, ed etc. Among them, the vi editor is the most powerful and widely used in Linux environment.

The vi editor functions in two different modes – the command mode, and the insert mode.
In the command mode, any key pressed by the user is assumed as commands by the editor. No text is displayed on the screen when any key is pressed.
The insert mode helps us to insert the text we want to.

To invoke the editor,
syntax :
vi (<┘)

To go to the insert mode from the command mode,
press i
To go to the command mode from the insert mode,
press escape key

In command mode the pressed character is the command.
The characters that works as command in the command mode:
i
Insert before the cursor
a
Insert after the cursor
o
Open a line below
I
Insert at beginning of line
A
Append to end of line
O
Open a line above

Saving and exiting from vi editor
:w (<┘)
save(write to disk)
:w (<┘)
if filename is not given
:q (<┘)
quit if saved
:wq (<┘) ] or :x (<┘) or :zz (<┘)
save and exit
:q! (<┘)
quit without saving
:e! (<┘)
abandon the changes and reload the last saved version


Cursor movement
The vi command involves alphabets and the shift and control keys.The cursor movement can be described as follows.

h
left
j
down
k
up
l
right
w
word ahead
b
word back
(
sentence back
)
sentence forward
{
paragraph back
}
paragraph forward

To Change, Delete (cut), Yank (copy) texts,

change
delete
yank
line
cc
dd
yy
letter
cl
dl
yl
word
cw
dw
yw
paragraph above
c{
d{
y{
paragraph below
c}
d}
y}
sentence back
c(
d(
y}
sentence foreward
c)
d(
y)

Paste
p
To paste after cursor/line
P
To paste before the cursor/ line

Undo
u
undo most recent changes
U
undo all changes to the current line since the cursor loaded on the line

Redo
Ctrl + r (<┘)

Searching the text
/searchtext (<┘)
searches the text in forward direction
?searchtext (<┘)
searches the text in backward direction
n
continue search in the same direction
N
continue search in the opposite direction


Search and replace
:s/search text/replacetext/g
searches and replaces on current line only
: 1,$s/searchtext/replacetext/g
searches and replace in entire file
: . , .+10s/searchtext/replacetext/g
searches and replaces on current line and 10 lines forward
:8, 12s/ searchtext/replacetext/g
searches and replaces on 8th lines through 12th lines.


Configuring vi
: set number[spelling] or nu
Displays the line numbers
: set nonunter or nonu
Removes line number
: set ignorecase (<┘)
Ignores case
:set noignorecase (<┘)
Considers case


Getting help
:help (<┘)
To come out of the help
:q (<┘)


Bash Shell and Shell Scripting
A Shell provides features that enable it to be used as a programming language. A set of commands can be grouped together under a single filename and executed. This is referred to as Shell Scripting in Linux. It offer varied of facilities for effective programming.

Various Shells in Linux are
o sh (Bourne shell): developed by Stevene Bourne at AT & T
o csh (C shell): developed by Bill Joy at Berkeley
o ksh (Korn shell): developed by David Korn at AT & T
o tesh (The Enhanced C shell): developed by community effort
o bash (Bourne Again Shell): by GNU, bash is the mostly used shell.

To know the currently using shell,
press ctrl-X, ctrl-V
It displays the current shell and its version.

Creation of Shell Scripts
A set of commands to be performed can be entered into a file by using any of the above editors or by using cat command.

Execution of Shell Script
A Shell Script can be executed using two methods. One is to type “sh ” at the command prompt.
The other method is to grant execute permission to the file and then type the file name at the prompt.



Variable
Variables can be
- shell variable
- environment variable
Shell variables are accessible within the shell only and environment variables are accessible within shell and its child shells as well.

The following commands display the list of variables
set (<┘) : Displays the list of shell variables as well as
environment variables.
env (<┘) : Displays the list of environment variables only.

The # symbol
The # symbol is used in the Shell scripts to insert comment lines. On execution, the comment line will be ignored.


//****
Eg. $a=5 (<┘)
It assigns the value 5 to the variable 'a'.
No space in front and back of '=' is required as the space in command line is taken as an argument.

'Echo' command
This command is used to display the definite value or string embedded in double quotation.
Eg. $echo "Hello" (<┘)
It displays the string “Hello”

Eg. $a=5
$echo $a
It displays the value of the variable 'a' as 5

If the user is in child shell then he cannot operate on shell variable, he has to return from child shell.

To create child shell we use the command 'bash'.
bash (<┘)

To return from the child shell 'exit' command is used.
exit (<┘)

Export command
To transfer the shell variable to environment variable 'export' command is used.
export a (<┘)
The variable 'a' is shell variable.
$ps
If there is more than one bash then you are in child shell.

Eg: $a=10
$bash
$export a
$echo $a
10 is assigned to the variable 'a'. Child shell is created the shell variable is transferred to the environment variable and the value of 'a' is displayed.
$a=10
$bash
$echo $a
It doesn't displays the value of a. You need to return from child shell.
$a=10
$bash
$exit
$echo $a
$export b=6 is equvalent to $b=6
$export b

ps1 is predefined environment variable.
$echo $ps1 defines command prompt with some predefined value as [\u@\h \W]\$
where \u ->user name
\h -> Host name
\H -> Full Host name
\W -> directory
\$ -> normal user ****/


History Command
'history' command is used to display the latest commands those were used by the user. By default, it displays latest thousand commands. It is user specific command and can be viewed only after logout. The history file is saved in the directory ~/. bash_history.
( ~ is home directory of the user.path = /home/user1/. bash_history)
So, we can also read or edit the content of the file using the following command,
vi .bash_history (<┘)

!! (<┘)
executes last used command
!x (<┘)
repeats last used command started with 'x'
!n (<┘)
repeats a command by its number in history output
!-n (<┘)
repeats a command entered n commands back


/************
Command line expansion
Shell function; shell scripting
************/

Programming Structures

Operators:
1. String operators:
· –z string : Returns true, if zero length string
· –n string : Returns true, if length of string is non-zero
· string1 op string2 : Here op may be ‘=’ or ‘!=’
2. Integer operators
· Integer1 op Integer2
Here op may be as follows:
-eq : equal to
-ne : not equal to
-lt : less htan
-le : less or equal to
-gt : greater than
-ge : greater or equal to
3. File operators
-e filename : Returns true if file exists
-f filename : Returns true if regular (normal) file
-d filename : Returns true if directory
-b filename : Returns true if block device file
-c filename : Returns true if character device file
-r filename : Returns true if file has read permission
-w filename : Returns true if file has write permission
-x filename : Returns true if file has execute permission
4. Logical operator:
-a : AND
-o : OR

Condition
Syntax : test expression
or
[ expression ]

Control Statements
1. if statement
The if condition statements may be used in the following four ways.
· if condition
then
statement
fi

· if condition
then
statement
else
statement
fi

· if condition
then
statement
elif condition
then
statement
elif condition
then
statement
else
statement
fi

· if condition
then
if condition
then
statement
else
statement
fi
else
statement
fi


2. Case Statements
The case statement executes a shell script based on a choice.
syntax:
case variable in
value 1)
statements
;;
value 2)
statements
;;
*)
statements
;;
esac

3. Loops
The following sorts of loops are available for shell scripting in Linux.

· for Loop
It is used ot perform the same set of operations on a list of values.
Syntax:
for variable in list_of_values
do
statements
done

· while Loop
The commands within it are executed repeatedly as long as the condition remains true.
syntax:
while condition
do
statements
done
· until Loop
Here, the statements are executed until the condition is false.
syntax:
until condition
do
statements
done


Positional Parameters
Linux accepts commands in the command line. A shell script can be made to accept arguments form the command line. Since the arguments represent their position, they are called positional parameters.

The variables defined for the positional parameters are
$#
Count of arguments
$*
List containing arguments
$0
Filename of the shell script
$1
First argument
$x
xth argument (where 0 &ge x<10)


Printing and Mailing

Printing
The various commands related to “printing” in Linux are as follows:
· lpr (<┘) : prints a named file.
· lpr –P printer (<┘) : configures printer and prints the specified file.
· lpq (<┘) : displays the queued print jobs.
· lprm (<┘) : removes the queued print jobs.

The various utilities related to printing are,
· enscript : Converts text file into PostScript file
· a2ps : Converts text file into PostScript file
· ps2pdf : Converts PostScript file to PDF file
· pdf2ps : Converts PDF file to PostScript file
· ggv : It is used in GUI terminal to view PDF and PostScript files. Could be compared to Adobe Acrobat Reader.

Mailing
There are various mail programs that can be used in Linux to send and receive mails.
In the text terminal, the following can be used.
· mail
· pine
· mutt
While in the GUI, the following applications can be used.
· Kmail
· balsa
· evolution
· mozilla

To send mail using “mail”
mail (<┘)
subject: (<┘)

(<┘)

. (<┘) //This signifies the end of the text.
cc: (<┘)


To check mail
mail (<┘)


Basic Networking

ping Command
This command is used to check if there is a connection between any two computers.

This command is also useful for verifying that your ISP’s IP addresses are valid and for testing the response times of your ISP’s host servers. Ping sends test packets of data and measures the time it takes for the host to send back the information.

Syntax:
ping (<┘)
Example:
ping 192.168.1.X where X is a machine-id

By default, ping will continue to send and receive information until we quit with
the following command:
Ctrl+C (<┘)

traceroute Command
This command is used if there is a network to network connection.

Example:
traceroute www.redhat.com (<┘)

white paper of linux, case study of linux, example of linux command, linux command
Hanessa Hudgens wallpaper of hanessa hudgens hot pictures of hanessa hudgens sexy pictures of hanessa hudgens



Tuesday, July 21, 2009

MIME AND ITS TYPE

MIME Overview
by Mark Grand
Internet e-mail allows mail messages to be exchanged between users of computers around
the world and occasionally beyond… to space shuttles. One of the main reasons that
Internet e-mail has achieved such wide use is because it provides a standard mechanism
for messages to be exchanged between over 1,000,000 computers connected to the
Internet.
The standards that are the basis for Internet e-mail were established in 1982. Though they
were state of the art in 1982, in the intervening years they have begun to show their age.

The 1982 standards allow for mail messages that contain a single human readable message
with the restrictions that:
• the message contains only ASCII characters.
• the message contains no lines longer than 1000 characters.
• the message does not exceed a certain length
The 1982 standards do not allow EDI to be transmitted through Internet mail, since EDI
messages can violate all of these restrictions. There are a number of other types of
messages and services that have are supported by other mail standards that have been
designed more recently. In June of 1992 a new Internet mail standard was approved. This
new standard is called MIME.
MIME is an acronym for Multipurpose Internet Mail Extensions. It builds on the older
standard by standardizing additional fields for mail message headers that describe new
types of content and organization for messages.
MIME allows mail messages to contain:
• Multiple objects in a single message.
• Text having unlimited line length or overall length.
• Character sets other than ASCII.
• Multi-font messages.
• Binary or application specific files.
• Images, Audio, Video and multi-media messages.
MIME defines the following new header fields:
1. A MIME-Version header field, which uses a version number to declare that a
message conforms to the MIME standard.
2. A Content-Type header field, which can be used to specify the type and subtype
of data in the body of a message and to fully specify the encoding of such data.
2.a. A Text Content-Type value, which can be used to represent textual
information in a number of character sets and formatted text description
languages in a standardized manner.
2.b. A Multipart Content-Type value, which can be used to combine several
body parts, possibly of differing types of data, into a single message.
2.c. An Application Content-Type value, which can be used to transmit
application data or binary data.
2.d. A Message Content-Type value, for encapsulating a mail message.
2.e. An Image Content-Type value, for transmitting still image (picture) data.
2.f. An Audio Content-Type value, for transmitting audio or voice data.
2.g. A Video Content-Type value, for transmitting video or moving image
data, possibly with audio as part of the composite video data format.
3. A Content-Transfer-Encoding header field, that specifies how the data is
encoded to allow it to pass through mail transports having data or character set
limitations.
4. Two optional header fields that can be used to further describe the data in a
message body, the Content-ID and Content-Description header fields.
MIME is an extensible mechanism. It is expected that the set of content-type/subtype pairs
and their associated parameters will grow with time. Several other MIME fields, such as
character set names, are likely to have new values defined over time. To ensure that the
set of such values develops in an orderly, and public manner, MIME defines a registration
process which uses the Internet Assigned Numbers Authority (IANA) as a central registry
for such values.
To promote interoperability between implementations, the MIME standard document
specifies a minimal subset of the above mechanisms that are required for an
implementation to claim to conform to the MIME standard.
2
MIME Technical Summary
MIME is defined by an Internet standard document called RFC 1341. This document
summarizes the contents of RFC 1341. Sufficient detail is presented here to understand
the capabilities of MIME. For sufficient detail to implement MIME please read RFC 1341.
MIME allows messages to contain multiple objects. When multiple objects are in a MIME
message, they are represented in a form called a body part. A body part has a header and
a body, so it makes sense to speak about the body of a body part. Also, body parts can be
nested in bodies that contain one or multiple body parts.
The Content-Type values, subtypes, and parameter names defined in the MIME standard
are not case insensitive. However, many parameter values are case sensitive
The MIME standard is written to allow MIME to be extended in certain ways, without
having to revise the standard. MIME specifies sets of values that are allowed for various
fields and parameters. The provides a procedure for extending these sets of values by
registering them with an entity called the Internet Assigned Numbers Authority (IANA).
The MIME-Version Header Field
MIME is designed to be compatible with older Internet mail standards. In particular, it is
compatible with RFC 822. If a mail reading program receives a message that is a MIME
message then it will likely perform additional processing for the MIME message that it
would not perform for non-MIME messages. In order to allow mail reading programs to
recognize MIME messages, MIME messages are required to contain a MIME-Version
header field. The MIME-Version header field specifies the version of the MIME standard
that the message conforms to.
As of this writing there is only version (1.0) of the MIME standard. Messages that comply
with the standard must include a header field, with the following verbatim text:
MIME-Version: 1.0
The MIME-Version header field is required at the top level of a message. It is not required
for each body part of a multipart entity. It is required for the embedded headers of a body
of type "message" if and only if the embedded message is claimed to be MIME-compliant.
The Content-Type Header Field
The Content-Type field describes the data contained in the body fully enough that the
mail reader can pick an appropriate mechanism to present the data to the user, or
otherwise deal with the data in an appropriate manner.
The Content-Type header field is used to specify the nature of data in the body or body
part, by giving type and subtype identifiers, and by providing parameters that may be
3
needed for certain types. After the type and subtype names, the remainder of the header
field is a set of parameters, specified in an attribute/value notation. The set of meaningful
parameters differs for different types. The order of parameters is not significant.
Comments are allowed (in accordance with RFC 822 rules) in structured header fields by
placing them in parentheses.
The top-level Content-Type is used to declare the general type of data, while the subtype
specifies a specific format for that type of data. Thus, a Content-Type of Image/xyz is
enough to tell a mail reader that the data is an image, even if the mail reader has no
knowledge of the specific image format xyz. Such information can be used, to decide
whether or not to show a user the raw data from an unrecognized subtype — such an
action might be reasonable for unrecognized subtypes of Text, but not for unrecognized
subtypes of Image or Audio. For this reason, registered subtypes of Audio, Image, Text,
and Video, should not contain embedded information that is really of a different type.
Such compound types are usually represented using the Multipart or Application
types.
Parameters are modifiers of the content-subtype. Although most parameters make sense
only with certain content-types, others are “global” in the sense that they might apply to
any subtype. For example, the Boundary parameter, which is used to indicate how body
parts are separated from each other, makes sense only for the Multipart content-type.
The Charset parameter might make sense with several content-types.
The MIME standard defines seven content-types. The authors of the MIME standard state
that the set of seven types is “substantially complete”. They expect additional supported
types to be accommodated by creating new subtypes of the seven initial top-level types.
The MIME standard, functioning as a constitution for the MIME community, states that
new standard content types can be defined only by revising the standard (as opposed to
the registration procedure for other types of extensions). However, MIME does provide
for the use of non-standard content types. Non-standard content-types can be used, but
must be given names starting with X-. Future standard content type names will not begin
with X-.

The syntax for the content type header field is
Content-Type := type "/" subtype [";" parameter]…
The defined content types are:
Application
indicates data that does not fit into any of the other categories, such as
uninterpreted binary data or information to be processed by a mail-based
application. In addition to the following subtypes, it is likely that additional
subtypes will be defined for applications such as mail-based scheduling
systems, spreadsheets and EDI.
4
Application/Octet-Stream
indicates uninterpreted binary data, which a mail reading program
may simply offer to write the information into a file. Possible
parameters for Application/Octet-Stream include:
Name
a suggested name for the binary data if stored as a file.
Type
the general type or category of binary data. This is intended for
human recipients rather than for automated processing.
Conversions
the operations that performed on the data before putting it the
body. Note that the standard defines no conversion values.
Any conversion values that do not begin with X- must be
preceded by a published specification and by registration with
IANA.
Padding
the number of bits of padding that were appended to the
bitstream comprising the actual contents to produce the
enclosed byte-oriented data. This is useful for enclosing a
bitstream in a body when the total number of bits is not a
multiple of the byte size.
Application/ODA
indicates a body containing information encoded according to the
Office Document Architecture (ODA) standards, using the ODIF
representation format. For Application/ODA, the Content-Type
line should also specify an attribute/value pair that indicates the
document application profile (DAP), using a Profile parameter.
Thus an appropriate header field might look like this:
Content-Type: application/oda;
profile=Q112
Consult the ODA standard for further information.
Application/PostScript
indicates a body containing a postscript document.
Audio
Indicates audio data. Audio requires an audio output device (such as a
speaker or a telephone) to “display” the contents.
Audio/Basic
The content of the Audio/Basic subtype is audio encoded using 8-
bit ISDN u-law. When this subtype is present, a sample rate of 8000
Hz and a single channel is assumed.
5
Image
Image data. Image requires a display device (such as a graphical display, a
printer, or a FAX machine) to view the information.
Image/Jpeg
indicates an image in JPEG format.
Image/Gif
indicates an image in GIF format.
Message
indicates an encapsulated message.
Message/Rfc822
indicates that the body contains an encapsulated message, with the
syntax of an RFC 822 message.
Message/Partial
indicates a partial message, allowing fragmented transmission of
bodies too large to be passed through mail transport facilities.
Message/Partial indicates that the body contains a fragment of a
larger message.
Three parameters are required in a Content-Type field of type
Message/Partial: The first, Id, is a unique identifier, as close to
world-unique as possible, used to match the parts together. The
second, Number, an integer, is the part number indicating where this
part fits into the sequence of fragments. The third, Total, another
integer, is the total number of parts. Total is required on the final
part, and optional on earlier parts.
Message/External-Body
indicates that the actual body data are not included, but merely
referenced. In this case, the parameters describe a mechanism for
accessing the external data.
When a body or body part is of type Message/External-Body, it
consists of a header, a blank line, and the message header for the
encapsulated message. If another blank line appears, this ends the
message header for the encapsulated message. However, since the
encapsulated message's body is itself external, it does not appear in
the area that follows. For example, consider this message:
Content-type: message/external-body;
access-type=local-file;
name=/u/nsb/Me.gif
Content-type: image/gif
THIS IS NOT REALLY THE BODY!
6

The area at the end, which constitutes a phantom body, is ignored
for most external-body messages. However, it may be used to
contain auxiliary information for a “mail-server”.
The only parameter of Message/External-Body that is always
mandatory is Access-Type. Its other parameters are mandatory or
optional depending on the value of Access-Type. The values
defined for the Access-Type parameter are FTP, ANON-FTP, TFTP,
AFS, LOCAL-FILE, and MAIL-SERVER. Except for values beginning
with X-, other values must be registered with IANA.
The standard also specifies additional parameters that are to be
used in conjunction with the various access types.
In addition to access-type specific parameters, the standard defines
the following parameters which are optional for all access types:
• The Expiration parameter is used to specify a date after
which the existence of the external data is not guaranteed.
• The Size parameter is used to specify the size of the data.
Multipart
indicates data consisting of multiple body parts; each having its own data
type. It is possible to tell where each body part begins and ends because
each body part is preceded by a special string called an encapsulation
boundary; the last body part is followed by a closing boundary.
The boundary strings used are specified by a mandatory parameter called
Boundary. The encapsulation boundary is an end of line followed by two
hyphens followed by the boundary parameter value of the Content-Type
header field. The closing boundary is the same as the encapsulation
boundary with the addition of two hyphens at the end of the line.
The encapsulation boundary must not appear inside any of the
encapsulated parts. It is crucial that the composing user agent be able to
choose and specify the unique boundary that will separate the body parts.
Encapsulation boundaries may be no longer than 70 characters, not
counting the blank line and leading hyphens.
Thus, a typical multipart Content-Type header field might look like:
Content-Type: multipart/mixed; boundary=gc0y0pkb9ex
This indicates a body consisting of several body parts, each having a
structure syntactically identical to an RFC 822 message, except that the
header area may be completely empty, and each part is preceded by the line
--gc0y0pkb9ex
The closing boundary following the last body part indicates that no further
body parts will follow. It is identical to the preceding encapsulation
boundaries, with the addition of two more hyphens at the end of the line:
7
--gc0y0pkb9ex--
There is room for additional information prior to the first encapsulation
boundary and following the final boundary. These areas are often blank.
Anything appearing before the first or after the last boundary is ignored.
As a simple example, the following multipart message has two parts, both
plain text, one explicitly typed and one implicitly typed:
From: Nathaniel Borenstein
To: Ned Freed
Subject: Sample message
MIME-Version: 1.0
Content-type: multipart/mixed;
boundary="simple boundary"
This is the preamble. It is to be ignored, though it is
a handy place for mail composers to include an
explanatory note to non-MIME compliant readers.
--simple boundary
This is implicitly typed plain ASCII text.
--simple boundary
Content-type: text/plain; charset=us-ascii
This is explicitly typed plain ASCII text.
It DOES end with a line break.
--simple boundary--
This is the epilogue. It is also to be ignored.
The use of a Content-Type of multipart in a body part within another
multipart entity is explicitly allowed. In such cases, care must be taken to
ensure that each nested multipart entity uses a different boundary delimiter.
The use of the multipart Content-Type with only a single body part may
be useful in certain contexts, and is explicitly permitted.
Multipart/Mixed
indicates multiple independent body parts to be viewed serially.
Multipart/Alternative
is syntactically identical to Multipart/Mixed. Each part is an
“alternative” version of the same information. Mail readers should
recognize that the content of the parts are interchangeable. The
mail reader should either choose the “best” type based on the user's
environment and preferences, or offer the user the available
alternatives. Generally, choosing the best type means displaying
only the last part that can be displayed. This may be used, for
example, to send mail in a fancy text format in such a way that it
can easily be displayed anywhere:
From: Nathaniel Borenstein
To: Ned Freed
Subject: Formatted text mail
8
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary=boundary42
--boundary42
Content-Type: text/plain; charset=us-ascii
...plain text version of message goes here....
--boundary42
Content-Type: text/richtext
.... richtext version of same message goes here ...
--boundary42
Content-Type: text/x-whatever
.... fanciest formatted version of same message
goes here
...
--boundary42--
In this example, users whose mail system understood the
text/x-whatever format would see only the fancy version, while
other users would see only the richtext or plain text version,
depending on the capabilities of their system.
Some mail reading programs that recognize more than one of the
formats will offer the user a choice of which format to view. This
makes sense, for example, if mail includes both a nicely formatted
image version and an easily edited text version. The point is that
multiple versions of the same data are not automatically shown.
Either the user is shown the last recognized version or explicitly
given the choice.
Multipart/Parallel
is syntactically identical to Multipart/Mixed. However, in a
parallel body, all of the body parts are intended to be presented
simultaneously on hardware and software that are capable of doing
so. Composing agents should be aware that many mail readers will
lack this capability and will show the parts serially in any event.
Multipart/Parallel will likely be used for multimedia messages
that combine such message types as text, audio and/or video.
Multipart/Digest
Indicates that each of the body parts is an RFC 822 mail message.
Multipart/Digest is syntactically identical to Multipart/Mixed,
except that the default Content-Type value for a body part is
changed from Text/Plain to Message/Rfc822.
Text
The text Content-Type is for sending material that is principally textual
in form. It is the default Content-Type. A Charset parameter may be
9
used to indicate the character set of the text. The default Content-Type
for Internet mail is text/plain; Charset=US-ASCII.
The value of the Charset parameter is not case sensitive. Allowable
values are US-ASCII, ISO-8859-1, ISO-8859-2, … and ISO-8859-9. The
default value for Charset is US-ASCII.
Text/Plain
indicates plain (unformatted) text. No special software is required
to get the full meaning of the text, aside from support for the
indicated character set. Other subtypes should be used for enriched
text in forms where application software may enhance the
appearance of the text, but such software must not be required in
order to get the general idea of the content. Possible future
subtypes include any readable word processor format.
Text/Richtext
indicates a simple portable word processing format that is defined
by the MIME standard. It is a very small subset of SGML. Mail
readers that implement Richtext may implement only a subset of
it.
When a mail composing program is given a file in a word
processing format to send and there is no standardized subtype for
that format, then the message composing program may reformat the
file into richtext format which will preserve more of the original
formatting information than reformatting the file to plain ASCII.
Video
indicates that the body contains a time-varying-picture image, possibly with
color and coordinated sound. The term Video is used very generically and
does not refer to any particular technology or format. It is not meant to
preclude subtypes such as animated drawings encoded compactly.
Video/Mpeg
indicates video coded according to the MPEG standard.
X-TypeName
This is any type name that begins with X-. A Content-Type value
beginning with X- is a private value, to be used by consenting mail systems
by mutual agreement. The standard specifies no subtypes.
No type may be specified without a subtype.
The standard allows the use of additional sub-types without having to change the
standard. However, it is important to insure that sub-types used by different user
communities of MIME do not conflict. It would be confusing if Content-Type:
application/foobar meant two different things. The standard specifies two
mechanisms for defining new Content-Type subtypes:
10
1. Private values (starting with X-) may be defined between cooperating mail
composing and reading programs without outside registration. Use of this
mechanism requires knowing that the reader of the message will not mistake the
content type for something other than originally intended.
2. New standard values must be registered with IANA. Where intended for public
use, the formats they refer to must also be defined by a published specification.
Messages that do not have a Content-Type field in their header are displayed by user
agents as if Content-Type: Text/plain; Charset=US-ASCII had been specified.
When a mail reader encounters mail with an unknown Content-Type value, it will
generally treat it as equivalent to application/octet-stream.
The Content-Transfer-Encoding Header Field
Many Content-Types which could usefully be transported via e-mail are represented, in
their “natural” format, as 8-bit character or binary data. Such data cannot be transmitted
over some transport protocols. For example, SMTP (Simple Mail Transfer Protocol is an
Internet standard for transporting e-mail defined by a document called RFC 821) restricts
mail messages to 7-bit ASCII data with lines no longer than 1000 characters.
MIME provides two mechanisms for re-encoding such data into a 7-bit short-line format.
The Content-Transfer-Encoding header field indicates the mechanism used to perform
such an encoding. The Content-Transfer-Encoding field indicates the transformation
that has been used to represent the body in an acceptable manner for transport.
The possible values for the Content-Transfer-Encoding field are:
BASE64
QUOTED-PRINTABLE
8BIT
7BIT
BINARY
x-EncodingName
These values are not case sensitive. That is, Base64, BASE64 and bAsE64 are all
equivalent. An encoding type of 7BIT requires that the body is already in a 7-bit mailready
representation. That is the default value: Content-Transfer-Encoding: 7BIT is
assumed if the Content-Transfer-Encoding header field is not present.
Both BASE64 and the QUOTED-PRINTABLE imply an encoding that consists of lines no
longer than 76 ASCII characters. In other respects the two encoding schemes are very
different.
The encoding scheme implied by QUOTED-PRINTABLE is most appropriate for data that
consists primarily of printable ASCII characters. Using this encoding method, printable
ASCII character are represented as themselves. The equals sign (=) serves as an escape
character. Any character that is not a printable or white space ASCII character is
11
represented as an equals sign followed by two hexadecimal digits. An equals sign in the
message is also represented in this way. Lines that are longer than 76 characters are cut
off after the 75th character and the line ends with a equals sign.
The advantages of using the QUOTED-PRINTABLE encoding for message that are mostly
printable ASCII characters are that few additional characters are required and the message
can be read by human beings who to not have a MIME aware mail reading program. As an
example, here is an EDI interchange in QUOTED-PRINTABLE encoding:
ISA*00* *00* *01*987654321 *12*8005551234 *910=
607*0111*U*00200*110000777*0*T*>
GS*PO*987654321*8005551234*920501*2032*7721*X*002003
ST*850*000000001
BEG*00*NE*MS1112**920501**CONTRACT#
REF*IT*8128827763
N1*ST*MAVERICK SYSTEMS
N3*3312 NEW HAMPSHIRE STREET
N4*SAN JOSE*CA*94811
PO1*1*25*EA***VC*TP8MM*CB*TAPE8MM
PO1*2*30*EA***VC*TP1/4*CB*TAPE1/4INCH
PO1*3*125*EA***VC*DSK31/2*CB*DISK35
CTT*3
SE*11*000000001
GE*1*7721
IEA*1*110000777
Except for the ISA segment having been wrapped onto two lines, the QUOTED-PRINTABLE
encoding of the interchange is identical to its 7BIT representation.
The BASE64 encoding mechanism is well suited for representing binary files. It represents
any sequence of three bytes as four printable ASCII characters. The same interchange as
shown above but using the BASE64 encoding would look like:
SVNBKjAwKiAgICAgICAgICAqMDAqICAgICAgICAgICowMSo5ODc2NTQzMjEgICAgICAqMTIq
ODAwNTU1MTIzNCAgICAgKjkxMDYwNyowMTExKlUqMDAyMDAqMTEwMDAwNzc3KjAqVCo+CkdT
KlBPKjk4NzY1NDMyMSo4MDA1NTUxMjM0KjkyMDUwMSoyMDMyKjc3MjEqWCowMDIwMDMKU1Qq
ODUwKjAwMDAwMDAwMQpCRUcqMDAqTkUqTVMxMTEyKio5MjA1MDEqKkNPTlRSQUNUIwpSRUYq
SVQqODEyODgyNzc2MwpOMSpTVCpNQVZFUklDSyBTWVNURU1TCk4zKjMzMTIgTkVXIEhBTVBT
SElSRSBTVFJFRVQKTjQqU0FOIEpPU0UqQ0EqOTQ4MTEKUE8xKjEqMjUqRUEqKipWQypUUDhN
TSpDQipUQVBFOE1NClBPMSoyKjMwKkVBKioqVkMqVFAxLzQqQ0IqVEFQRTEvNElOQ0gKUE8x
KjMqMTI1KkVBKioqVkMqRFNLMzEvMipDQipESVNLMzUKQ1RUKjMKU0UqMTEqMDAwMDAwMDAx
CkdFKjEqNzcyMQpJRUEqMSoxMTAwMDA3NzcK
BASE64 bears some resemblance to uuencode in both appearance and function. However,
uuencode uses characters that may not be processed properly by an EBCDIC gateway.
The values 8bit, 7bit, and binary all imply that no encoding has been performed.
However, they are useful to indicate of the kind of data contained in the object, and
therefore of the kind of encoding that might need to be performed for transmission in a
given transport system. 7bit means that the data is all represented as short lines of ASCII
data. 8bit means that the lines are short, but there may be non-ASCII characters. Binary
means that not only may non-ASCII characters be present, but also that the lines are not
necessarily short enough for SMTP transport.
12
The difference between 8bit and binary is that binary does not require adherence to
any limits on line length. 8bit and binary are intended for compatibility with future
Internet e-mail transport standards and with gateways to non-Internet environments. As
of this writing there are no standardized Internet e-mail transports for which it is legitimate
to include unencoded 8-bit or binary data in mail bodies.
Note that the five values defined for the Content-Transfer-Encoding field imply
nothing about the Content-Type other than the algorithm by which it was encoded or the
transport system requirements if unencoded.
Some implementations may support additional Content-Transfer-Encoding values (it is
permitted but strongly discouraged by the standard). Any such additional values must
have names that begin with X- to indicate its non-standard status For example:
Content-Transfer-Encoding: x-my-new-encoding.
If a Content-Transfer-Encoding header field appears as part of a message header, it
applies to the entire body of that message. If a Content-Transfer-Encoding header
field appears as part of a body part's headers, it applies only to the body of that body part.
If a message or body part is of type Multipart or Message, the
Content-Transfer-Encoding must be 7bit, 8bit or Binary.
The encoding mechanisms defined here explicitly encode all data in ASCII. Thus, for
example, suppose a message or body part has header fields such as:
Content-Type: text/plain; charset=ISO-8859-1
Content-transfer-encoding: base64
This should be interpreted to mean that the body is a Base64 ASCII encoding of data that
was originally in ISO-8859-1, and will be in that character set again after decoding.
Optional Content-ID Header Field
It may be desirable to allow one body to reference another. Accordingly, bodies may be
labeled using the Content-ID header field, which is syntactically identical to the RFC 822
Message-ID header field: Content-ID values should be be as unique as possible.
Optional Content-Description Header Field
The ability to associate descriptive information with a body is often desirable. For
example, it may be useful to mark an Image body as “a picture of the Space Shuttle
Endeavor.” Such text may be placed in the Content-Description header field.
13
Summary
Using MIME-Version, Content-Type, and Content-Transfer-Encoding header fields,
it is possible to include arbitrary types of data objects in RFC 822 conformant mail
messages. No restrictions imposed by RFC 821 or RFC 822 are violated. MIME has been
designed to avoid problems caused by additional restrictions imposed by some Internet
mail transport mechanisms. The Multipart and Message content types allow mixing and
hierarchical structuring of objects of different types in a single message. Further content
types provide a mechanism for tagging messages or body parts as audio, image, or other
kinds of data. A parameter syntax allows further specification of data format details,
particularly the specification of alternate character sets. Additional optional header fields
provide mechanisms for certain extensions deemed desirable by many implementors.
Finally, a number of useful content types are defined for general use by consenting user
agents, notably Text/Richtext, Message/Partial, and Message/External-Body.
To promote interoperability between user agents, the MIME standard specifies a minimal
subset of MIME features a user agent must support to be considered MIME conformant.
A Complex Multipart Example
The outline of a complex multipart message follows. This message has five parts to be
displayed serially: two introductory plain text parts, an embedded multipart message, a
richtext part, and a closing encapsulated text message in a non-ASCII character set. The
embedded multipart message has two parts to be displayed in parallel, a picture and an
audio fragment.
MIME-Version: 1.0
From: Nathaniel Borenstein
Subject: A multipart example
Content-Type: multipart/mixed;
boundary=unique-boundary-1
This is the preamble area of a multipart message. Mail readers that
understand multipart format should ignore this preamble.
If you are reading this text, you might want to consider changing to
a mail reader that understands how to properly display multipart
messages.
--unique-boundary-1
Some text appears here...
[Note that the preceding blank line means
no header fields were given and this is text,
with charset US ASCII. It could have been
done with explicit typing as in the next part.]
--unique-boundary-1
Content-type: text/plain; charset=US-ASCII
This could have been part of the previous part, but illustrates
explicit versus implicit typing of body parts.
14
--unique-boundary-1
Content-Type: multipart/parallel; boundary=unique-boundary-2
--unique-boundary-2
Content-Type: audio/basic
Content-Transfer-Encoding: base64
… base64-encoded 8000 Hz single-channel
u-law-format audio data goes here …
--unique-boundary-2
Content-Type: image/gif
Content-Transfer-Encoding: Base64
… base64-encoded image data goes here…
--unique-boundary-2--
--unique-boundary-1
Content-type: text/richtext
This is richtext.Isn't it
cool?
--unique-boundary-1
Content-Type: message/rfc822
From: (name in US-ASCII)
Subject: (subject in US-ASCII)
Content-Type: Text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: Quoted-printable
… Additional text in ISO-8859-1 goes here …
--unique-boundary-1--
15