Free Essay

Linux

In:

Submitted By shantanu1
Words 6867
Pages 28
LINUX PROGRAMMING FINAL NOTES UNIT 1ST
THESE NOTES ARE AS PER SYLLABUS & WILL HELP YOU TO ACHIEVE SUCCESS IN FINAL EXAM OF MCA 5TH SEMESTER.
LETS START: UNIT 1ST

Linux – The Operating System: Linux is one of popular version of UNIX operating System. It is open source as its source code is freely available. It is free to use. Linux was designed considering UNIX compatibility. It's functionality list is quite similar to that of UNIX. Linux is a free distributed implementation of a Unix-like Kernel Developed by Linus Torvalds at the University of Helsinki with the help of programmers across the Internet.
Linux history: *

Linux features:
Following are some of the important features of Linux Operating System. * Portable - Portability means softwares can works on different types of hardwares in same way.Linux kernel and application programs supports their installation on any kind of hardware platform. * Open Source - Linux source code is freely available and it is community based development project. Multiple teams works in collaboration to enhance the capability of Linux operating system and it is continuously evolving. * Multi-User - Linux is a multiuser system means multiple users can access system resources like memory/ ram/ application programs at same time. * Multiprogramming - Linux is a multiprogramming system means multiple applications can run at same time. * Hierarchical File System - Linux provides a standard file structure in which system files/ user files are arranged. * Shell - Linux provides a special interpreter program which can be used to execute commands of the operating system. It can be used to do various types of operations, call application programs etc. * Security - Linux provides user security using authentication features like password protection/ controlled access to specific files/ encryption of data.

Linux distributions: 1. .Ubuntu, a popular desktop and server distribution derived from Debian, maintained by Canonical Ltd..
2.Kubuntu, the KDE version of Ubuntu.
3.Linux Mint, a distribution based on and compatible with Ubuntu.
4.Xubuntu, is the Xfceversion of the popular desktop distroUbuntu.
Commonly used by Linux users that wish to have the function of a bigger distrosuch as Ubuntu or openSusewith the speed of a smaller distro. 5.Fedora,a community distribution sponsored by Red Hat
6.CentOS, a distribution derived from the same sources used by Red Hat, maintained by a dedicated volunteer community of developers.
7.Mandriva, a Red Hat derivative popular in France and Brazil, today maintained by the French company of the same name.
8.PCLinuxOS, a derivative of Mandriva, grew from a group of packages into a community-spawned desktop distribution.
Linux’s relationship to Unix:
What is the difference between Linux and UNIX operating systems?
UNIX is copyrighted name only big companies are allowed to use the UNIX copyright and name, so IBM AIX and Sun Solaris and HP-UX all are UNIX operating systems. The Open Group holds the UNIX trademark in trust for the industry, and manages the UNIX trademark licensing program.
Most UNIX systems are commercial in nature.
Linux is a UNIX Clone:
But if you consider Portable Operating System Interface (POSIX) standards then Linux can be considered as UNIX. To quote from Official Linux kernel README file:
Linux is a Unix clone written from scratch by Linus Torvalds with assistance from a loosely-knit team of hackers across the Net. It aims towards POSIX compliance.
However, "Open Group" do not approve of the construction "Unix-like", and consider it misuse of their UNIX trademark. Linux is just a kernel. All Linux distributions includes GUI system + GNU utilities (such as cp, mv, ls,date, bash etc) + installation & management tools + GNU c/c++ Compilers + Editors (vi) + and various applications (such as Open Office, Firefox). However, most UNIX operating systems are considered as a complete operating system as everything come from a single source or vendor.
As I said earlier Linux is just a kernel and Linux distribution makes it complete usable operating systems by adding various applications. Most UNIX operating systems comes with A-Z programs such as editor, compilers etc. For example HP-UX or Solaris comes with A-Z programs.
Overview of Linux architecture:

Linux System Architecture is consists of following layers * Hardware layer - Hardware consists of all peripheral devices (RAM/ HDD/ CPU etc). * Kernel - Core component of Operating System, interacts directly with hardware, provides low level services to upper layer components. - Kernel is the core part of Linux. It is responsible for all major activities of this operating system. It is consists of various modules and it interacts directly with the underlying hardware. Kernel provides the required abstraction to hide low level hardware details to system or application programs * Shell - An interface to kernel, hiding complexity of kernel's functions from users. Takes commands from user and executes kernel's functions. * Utilities - Utility programs giving user most of the functionalities of an operating systems

Installation: Installation is a practicle work please do it yourself.
Start up scripts:
System Lifecycle: Ups & Downs: * Booting * Kernel Initialization * init: Process Number One * Shutdown * Advanced Boot Concepts * Power Management start_kernel Power on Power off Boot
Kernel
Init
OS
Init
RUN!
Shut down init shutdown LILO sleep? (hlt)

The following are the 6 high level stages of a typical Linux boot process.

* MBR: MBR stands for Master Boot Record. * It is located in the 1st sector of the bootable disk. Typically /dev/hda, or /dev/sda * MBR is less than 512 bytes in size. This has three components 1) primary boot loader info in 1st 446 bytes 2) partition table info in next 64 bytes 3) mbr validation check in last 2 bytes. * It contains information about GRUB (or LILO in old systems).
So, in simple terms MBR loads and executes the GRUB boot loader
GRUB: Grand Unified Bootloader: * GRUB is an operating system independent boot loader * A multiboot software packet from GNU * Flexible command line interface * File system access * Support multiple executable format * Support diskless system
Download OS from network
LILO: LInux Loader: * Not depend on a specific file system * Can boot from harddisk and floppy * Up to 16 different images * Must change LILO when kernel image file or config file is changed

* Kernel Initializtion: Linux Kernel is is itself a program, and the first bootstraping task is to get this program into memory so that it is executed. * The kernel is the central part in most computer operating systems because of its task, which is the management of the system's resources and the communication between hardware and software components * Kernel is always store on memory until computer is turn off * Kernel image is not an executable kernel, but a compress kernel image * zImage size less than 512 KB * bzImage size greater than 512 KB

Init process: * The first thing the kernel does is to execute init program * Init is the root/parent of all processes executing on Linux * The first processes that init starts is a script /etc/rc.d/rc.sysinit * Based on the appropriate run-level, scripts are executed to start various processes to run the system and make it functional Runlevel * A runlevel is a software configuration of the system which allows only a selected group of processes to exist * The processes spawned by init for each of these runlevels are defined in the /etc/inittab file * Init can be in one of eight runlevels: 0-6

To Summarize: Boot sequence: * Load hardware information from BIOS * Read MBR’s Kernel Loader (master boot record) * For Linux, goto boot (kernel with /boot/vmlinuz-xxxx * For DOS, goto boot.ini * Load Linux kernel * Execute init program (/sbin/init)to get run-level details (contains in /etc/inittab) * There are 6 levels * init execute /etc/rc.d/rc.sysinit * Start kernel external model (/etc/modules.conf) * init execute run-level’s scripts files * init execute /etc/rc.d/rc.local files; * execute /bin/login program; * After successful login, shell take over the machine Linux Security: * Administering Passwords: Attacks from your own system users.
Precautions to secure Linux System: * Learn how to implement safety measures & take a proactive approach. * Know how to fix the system and clean-up after a suspected break-in. * Be able to prevent any future security breaches.
Keeping Users in Check: Creating and keeping the passwords up to date. * Aging Measures After a certain period of time, users need to issue the system a new password. * Encrypt Password Files Using gpasman program
Securing Shell with ssh:
An encrypted connection from one machine to another that prevents a mediocre cracker from gaining too much information from the connection. * The ssh utility runs as a background daemon and should be started upon bootup. * The daemon files are located in /usr/local/ sbin

The Ext2 and Ext3 File systems:
The ext2 or second extended filesystem is a file system for the Linux kernel.
 It was initially designed by Rémy Cardas a replacement for the extended file system (ext).
 Theext3 or third extended file system is a journaled file system that is commonly used by the Linux kernel.
 It is the default file system for many popular Linux distributions.
 Stephen Tweedie first revealed that he was working on extending ext2 in Journaling the Linux .
The space in ext2 is split up into blocks. These blocks are grouped into block groups, analogous to cylinder groups in the Unix File System. There are typically thousands of blocks on a large file system. Data for any given file is typically contained within a single block group where possible. This is done to minimize the number of disk seeks when reading large amounts of contiguous data.
Each block group contains a copy of the superblock and block group descriptor table, and all block groups contain a block bitmap, an inode bitmap, an inode table and finally the actual data blocks. Thesuperblock contains important information that is crucial to the booting of the operating system. Thus backup copies are made in multiple block groups in the file system. However, typically only the first copy of it, which is found at the first block of the file system, is used in the booting.

Ext3 Filesystem: Ext3, or third extended file system, is a journaled file system that is commonly used by the Linux kernel. • It is the default file system for many popular Linux distributions, including Debian. • Its main advantage over ext2 is journaling, which improves reliability and eliminates the need to check the file system after an unclean shutdown. –A log of file system actions is maintained –In case a crash occurs, the actions recorded in a journal file are replayed to restore the system to a stable state –Avoids lengthy file system checks Journal (lowest risk) Both metadata and file contents are written to the Journal before being committed to the main file system. Because the journal is relatively continuous on disk, this can improve performance, if the journal has enough space. In other cases, performance gets worse, because the data must be written twice— once to the journal, and once to the main part of the filesystem. Linux file System:

* / * This is referred to as the root directory. It's the baseline for the directory structure, which is important when navigating from one directory tree to another. *
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.'

/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 default home directory for the user root.

/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. File Permission: ls -l file mode (permissions): Quoting from the unix ls command man page -the file mode printed under the -l option consists of the entry type and the permissions. The entry type character describes the type of file, as follows: -Regular file. • b Block special file. • c Character special file. • d Directory l Symbolic link. • p FIFO. • s Socket. • w Whiteout. Files are owned by both a user and a group and other • Each file has 3 sets of permissions –Permissions for the user who owns it (user permissions) –Permissions for the group that owns it (group permissions) –Permissions for everyone else (‘other’ or ‘world’ permissions) • There are 3 types of permissions –Read--controls ability to read a file –Write--controls ability to write or change a file –Executable--controls whether or not a file can be executed as a program Symbolic Codes: Examples chmod u+x filename • chmod u+x, g+w filename • chmod ug+x filename • chmod a-w filename • chmod u=rw filename • Chmod 777 a.c • Chmod 700 a.c • Chmod 421 a.c User Management: The command can be used in order to –Create a new user –Set the default set of attributes for new user –Get the default set of attributes for new user –While adding a user, the values in • /etc/login.defs • Default settings made by useradd itself are used for deciding attributes of a new user –New values provided on command line override the Defaults Add a user: Options: • -dhome directory • -sstarting program (shell) • -ppassword • -g(primary group assigned to the users) • -G(Other groups the user belongs to) • -m(Create the user's home directory Modify a user: usermod -Modifying existing user options: • -dhome directory • -sstarting program (shell) • -ppassword • -g(primary group assigned to the users) • -G(Other groups the user belongs to) : Delete a user: Options: • -r(remove home directory) Example: To remove the user 'roger' and his home directory userdel -r roger Add a user through GUI: Use user drakecommand in run.

UNIT 2ND
Resource Management in Linux: file and directory management;
-------------------------------------------------
Linux Directory Hierarchy:
-------------------------------------------------
The Linux operating system, like all versions of UNIX, uses an hierarchical file system, in which files and directories are arranged logically in an inverted tree structure. The root directory generally contains the following sub-directories, although some may be specific only to the University of Calgary's IT Linux system
-------------------------------------------------

-------------------------------------------------

-------------------------------------------------
Linux Directory and File Naming Conventions
Linux adheres to the following rules for file and directory names: * A file or directory name can have from 1 to 256 characters in length. * Linux is case sensitive -- uppercase characters are different from lowercase characters. * File or directory names can include letters, numbers, and the following special characters: period ( . ), underscore ( _ ), and dash ( - ). * The special characters comma ( , ), quotes ( ' , " , or ` ), slash ( / ), backslash ( \ ) and space can be used in file or directory names, but are highly advised against. * The directory you are working in at any given point is called your current or working directory. To print the name of your working directory, try the following on your Linux prompt: * type: pwd
You should see something similar to: /lu101/username * When you first log in, your working directory is your home directory, and usually takes a form similar to the above example, where username is your IT username. The text displayed by the pwd command is the pathname of your working directory, and in this example specifies a directory named username, contained in the directory /lu101, which itself is in the root directory. This pathname, beginning from the root directory ( / ), is an absolute pathname. A relative pathname is specified relative to some other directory in the file system, depending on the characters at the beginning of the supplied pathname:

-------------------------------------------------
Working with Linux Directories: change to a different working directory, type: cd directory_name where directory_name is the pathname of the directory you want to switch to. The syntax of directory_name can take several forms. Examine the following examples to see how to change directories: cd /lu101/username | Absolute pathname. In this example specifying the sub-directory username in thelu101 directory from the root ( / ) | Cd | Return to the home directory (/lu101/username in this example) | cd text | Relative pathname specifying the subdirectory text (/lu101/username/text) | cd .. | The home directory (/lu101/username) | cd ../.. | The root directory (/) | cd ~/text | Absolute pathname specifying the subdirectory text in the home directory (/lu101/username/text) |

To create a new directory, type: mkdir directory_name where directory_name is the absolute or relative pathname of the new directory. You must have write permission on the first directory. If you do not have the required permission, you will get the following error message: mkdir: The file access permissions do not allow the specified action.
The new directory will be created, giving you read, write, and execute permission, and no permissions for anyone else. Refer to Controlling Linux File and Directory Access for a detailed discussion of Linux file and directory permissions.
To move a directory to a new location in the directory hierarchy, type: mv directory_name new_location where directory_name andnew_location can be either absolute or relative pathnames. You must have write and execute permission for new_location and the directory containing directory_name.

To delete a directory, type: rmdir directory_name where directory_name must be an empty directory. If you try to delete a directory that contains files or other directories, you will get the following error message: rmdir: Directory directory_name is not empty.
-------------------------------------------------

-------------------------------------------------
Managing Linux Files:
-------------------------------------------------

Directories are not very useful without files to put in them. To list the names of the files and sub-directories in a directory, type ls . The contents of your working directory will be listed in several columns, like this: file.txt | file01.txt | file50.txt | untitled.txt | file01.data | file02.txt | text | |

To list all the files and directories, type ls -a . . | .bash_profile | file01.txt | text | .. | file.txt | file02.txt | untitled.txt | .bash_history | file01.data | text50.txt | |
This listing includes files and directories whose names begin with a period ( . ). Files and directories which start with a period usually contain information relating to the functioning of Linux itself, rather than your work, and can often be ignored.

You can also display text files within Linux. Here are four commands, each processing the output in a different way: * To display the file contents on your screen, with no page breaks or scrolling control, type cat filename * To display the file on your screen, with page breaks, but no scrolling control, type pr filename * To display the file on your screen, one screenful at a time, type more filename * To display the file on your screen, one screenful at a time but with scrolling control, type less filename

more can also be used to display the text from the other commands one screenful at a time. To display the file on your screen, with page breaks and scrolling control, type: pr filename | more . This sends the output of the pr command to the more command, which displays it one screen at a time.

To move a file to another directory or to a file with a different name (renaming a file), use the mv command: mv old_file new_file . For example, to rename the file chapter_1.txt to introduction.txt, type: mv chapter_1.txt introduction.txt . To move the file abstract.ps from your working directory to the subdirectory named thesis, type: mv abstract.ps thesis/abstract.ps . Since the same filename is used for the new file, you can shorten the command to: mv abstract.ps thesis/ .
The mv command deletes the original file, so if you want to make a copy of a file, use the cp (for copy) command. The copy of the file must have a different name or be in a different directoy. For example, to copy the file named motd from its system location to a file namedmessage.txt in your working directory, type: cp /usr/local/motd/motd message.txt.
-------------------------------------------------

-------------------------------------------------

system calls for files:
The functions which change the execution mode of the program from user mode to kernel mode are known as system calls. These calls are required in case some services are required by the program from kernel. For example, if we want to change the date and time of the system or if we want to create a network socket then these services can only be provided by kernel and hence these cases require system calls.
For example, socket() is a system call.
Interaction between components:

System calls acts as entry point to OS kernel:
There are certain tasks that can only be done if a process is running in kernel mode. Examples of these tasks can be interacting with hardware etc. So if a process wants to do such kind of task then it would require itself to be running in kernel mode which is made possible by system calls. • There are library functions that do not make any system call. For example, the string manipulation functions like strlen() etc fall under this category. • Also, there are library functions that further make system calls, for example the fopen() function which a standard library function but internally uses the open() sytemcall.
Process:
• A running instance of a program is called a process.
• Each process in a Linux system is identified by its unique process ID,sometimes referred to as pid.
• Process IDs are 16-bit numbers that are assigned sequentially by Linux as new processes are created.
• Every process also has a parent process (except the special init process).
• The parent process ID, or ppid, is simply the process ID of the process’s parent.
• When referring to process IDs in a C or C++ program, always use the pid_t typedef, which is defined in <sys/types.h>.
Printing the Process ID:
#include <stdio.h>
#include <unistd.h> int main ()
{
printf(“The process ID is %d\n”, (int) getpid()); printf(“The parent process ID is %d\n”, (int) getppid()); return 0; }
Fork() system call: >The system call fork() is used to create new processes. >It does not take any arguments and returns a process ID. >The purpose of fork() is to create a new process, which becomes the child process of the caller (which is called the parent). >After a new child process is created, both processes will execute the next instruction following the fork() system call. We can distinguish the parent from the child by testing the returned value of fork() >Therefore, the parent and child processes will have separate address spaces. Both processes start their execution right after the system call fork(). * If fork() returns a negative value, the creation of a child process was unsuccessful. * A call to fork() returns a zero to the newly created child process and the same call to fork() returns a positive value (the process ID of the child process) to the parent. * The returned process ID is of type pid_t defined in sys/types.h. Normally, the process ID is an integer. * When a process wants to duplicate itself so that the parent and child can each execute different sections of code at the same time. This is common for network servers-the parent waits for a service request from a client. When the request arrives, The parent calls fork and lets the child handle the request. The parent goes back for the next service request to arrive. * When a process wants to execute a different program. This is common for shells. In this case,child does an exec right after the fork * Some OS combine the operations into a single opertaion called a spawn. * Unix separates the two
Using the exec Family:
The exec functions replace the program running in a process with another program. When a program calls an exec function, that process immediately ceases executing that program and begins executing a new program from the beginning, assuming that the exec call doesn’t encounter an error. exec will replace the contents of the currently running process with the information from a program binary.
Signals:
Signals are mechanisms for communicating with and manipulating processes in Linux.
• A signal is a special message sent to a process. Signals are asynchronous; when a process receives a signal, it processes the signal immediately, without finishing the current function or even the current line of code.
• Each signal type is specified by its signal number, but in programs, you usually refer to a signal by its name.
• In Linux, these are defined in /usr/include/bits/signum.h. (You shouldn’t include this header file directly in your programs; instead, use <signal.h>.)
• A process may also send a signal to another process. One common use of thismechanism is to end another process by sending it a SIGTERMor SIGKILLsignal.
IPC:
Interprocess communication (IPC) is the transfer of data among processes. For example,
A Web browser may request a Web page from a Web server, which then sends HTML data. This transfer of data usually uses sockets in a telephone-like connection.
In another example, you may want to print the filenames in a directory using a command such as ls | lpr.
Types of Interprocess Communication:
1,Shared memor ypermits processes to communicate by simply reading and writing to a specified memory location.
2. Mapped memory is similar to shared memory, except that it is associated with a file in the filesystem.
3. Pipes permit sequential communication from one process to a related process.
4. FIFO sare similar to pipes, except that unrelated processes can communicate because the pipe is given a name in the filesystem.
5. Sockets support communication between unrelated processes even on different computers.
Explanation:
Signals
Signals are one of the oldest inter-process communication methods used by Unix TM systems. They are used to signal asynchronous events to one or more processes. A signal could be generated by a keyboard interrupt or an error condition such as the process attempting to access a non-existent location in its virtual memory. Signals are also used by the shells to signal job control commands to their child processes.
There are a set of defined signals that the kernel can generate or that can be generated by other processes in the system, provided that they have the correct privileges. You can list a system's set of signals using the killcommand (kill -l)
Pipes
A pipe is a communication device that permits unidirectional communication.
• Data written to the “write end” of the pipe is read back from the “read end.”
• Pipes are serial devices; the data is always read from the pipe in the same order it was written.
• Typically, a pipe is used to communicate between two threads in a single process or between parent and child processes. #include <unistd.h> int pipe(int filedes[2]);

The common Linux shells all allow redirection. For example $ ls | pr | lpr pipes the output from the ls command listing the directory's files into the standard input of the pr command which paginates them. Finally the standard output from the pr command is piped into the standard input of the lprcommand which prints the results on the default printer. Pipes then are unidirectional byte streams which connect the standard output from one process into the standard input of another process. Neither process is aware of this redirection and behaves just as it would normally. It is the shell which sets up these temporary pipes between the processes.
Named pipe (FIFO): For communication between related or unrelated processes on a system.

A first-in, first-out (FIFO) file is a pipe that has a name in the filesystem. Any process can open or close the FIFO; the processes on either end of the pipe need not be related to each other. FIFOs are also called named pipes. You can make a FIFO using the mkfifocommand. Specify the path to the FIFO on the command line. For example, create a FIFO in /tmp/fifo by invoking this:
% mkfifo /tmp/fifo
% ls -l /tmp/fifo prw-rw-rw-1 samuel users 0 Jan 16 14:04 /tmp/fifo
System V IPC Mechanisms
Linux supports three types of interprocess communication mechanisms that first appeared in Unix TM System V (1983). These are message queues, semaphores and shared memory. These System V IPC mechanisms all share common authentication methods. Processes may access these resources only by passing a unique reference identifier to the kernel via system calls. Access to these System V IPC objects is checked using access permissions, much like accesses to files are checked. The access rights to the System V IPC object is set by the creator of the object via system calls. The object's reference identifier is used by each mechanism as an index into a table of resources. It is not a straight forward index but requires some manipulation to generate the index.
All Linux data structures representing System V IPC objects in the system include an ipc_perm

Message Queues
Message queues allow one or more processes to write messages, which will be read by one or more reading processes. Linux maintains a list of message queues, the msgque vector; each element of which points to amsqid_ds data structure that fully describes the message queue. When message queues are created a new msqid_ds data structure is allocated from system memory and inserted into the vector.
Semaphores
In its simplest form a semaphore is a location in memory whose value can be tested and set by more than one process. The test and set operation is, so far as each process is concerned, uninterruptible or atomic; once started nothing can stop it. The result of the test and set operation is the addition of the current value of the semaphore and the set value, which can be positive or negative. Depending on the result of the test and set operation one process may have to sleep until the semphore's value is changed by another process. Semaphores can be used to implement critical regions, areas of critical code that only one process at a time should be executing.
Shared Memory
Shared memory allows one or more processes to communicate via memory that appears in all of their virtual address spaces. The pages of the virtual memory is referenced by page table entries in each of the sharing processes' page tables. It does not have to be at the same address in all of the processes' virtual memory. As with all System V IPC objects, access to shared memory areas is controlled via keys and access rights checking. Once the memory is being shared, there are no checks on how the processes are using it. They must rely on other mechanisms, for example System V semaphores, to synchronize access to the memory.

system calls for processes: fork() function call returned different values for each process. For the parent, fork() returned the PID of the child; for the child, fork() returned 0. If the fork() fails, then -1 is returned in the parent process (the only one running since the fork failed)
2) exec family replace currently executing code with called code Note that when we run the execdemo example, we do not see the line “Did it work?”. This is because the execvp() function call replaced the code being executed in the current process with the program “ls –l”. Once the program “ls –l” is done, our program is done, because that is the code it is now executing. You can think of the process as a container that is running some code (any code). When we call an exec() function, we replace the existing code with new code of our choice.
3) wait() – parent process suspends, waiting for child process to finish In addition to waiting for the child to finish, the wait() function returns information about the child process. The return value for wait() is the child’s PID. The single parameter passed back is the address of an int (32 bits), portions of which provide the exit()/return() value of the child process, whether or not it dumped core, and the signal ID if a signal was used to terminate the child process. system() – pause calling program until called program complete
Memory Management:
Memory management is the heart of operating systems; it is crucial for both programming and system administration. In the next few posts I’ll cover memory with an eye towards practical aspects, but without shying away from internals. While the concepts are generic, examples are mostly from Linux and Windows on 32-bit x86. This first post describes how programs are laid out in memory. Each process in a multi-tasking OS runs in its own memory sandbox. This sandbox is the virtual address space, which in 32-bit mode is always a 4GB block of memory addresses.

UNIT 3RD
Shell Programming: * Shell is a user level program .It is an command language interpreter that executes commands read from the standard input device (keyboard) or from a file. * It is not part of system kernel, but uses the system kernel to execute programs, create files etc. * In MS-DOS, Shell name is COMMAND.COM which is also used for same purpose, but it's not as powerful as Linux Shells are! Common Shells:

BASH SHELL * Bash is the shell, or command language interpreter, for the GNU operating system. The name is an acronym for the `Bourne-Again SHell', a pun on Stephen Bourne, the author of the direct ancestor of the current Unix shell /bin/sh, which appeared in the Seventh Edition Bell Labs Research version of Unix. * Bash is largely compatible with sh and incorporates useful features from the Korn shell ksh and the C shell csh. It is intended to be a conformant implementation of the IEEE POSIX Shell and Tools specification (IEEE Working Group 1003.2). It offers functional improvements over sh for both interactive and programming use.

Shell: Responsibilities: * Command Interpretation * Providing a scripting language * A process that provides runtime environment. Control the environment provided by the shell Set via any of the following activities * During the time when boot sequence is executing * After user logs in through login scripts * As a result of scripts executed after login * Interactively by user Also known as Environment / System variables Each shell variable is used for a specific purpose A shell variable is typically entered in uppercase To get its value, you precede the shell variable name with a $, as in $PATH The set command shows the complete list Examples of shell variables: * PWD – the most recent working directory set with the cd command * OLDPWD – the previous working directory set with the cd command * BASH – the full path of the bash shell * RANDOM – generates a random number between 0 and 32,767 * HOSTNAME – the current hostname of a Linux system * IFS – Internal Field Separator, which is used as a separator between shell words * PATH – contains the list of directories used to search for commands when executing them * HOME – each user’s home directory, typically /home/username, where username is a user’s login name Shell Scripts: Normally shells are interactive i.e. shell accept command from you (via keyboard) and execute them. But if required a set of related commands can be run by storing them to text file and telling the shell to execute this text file. This is known as shell script. Definition: * "Shell Script is series of command written in plain text file. Shell script is just like batch file is MS-DOS but have more power than the MS-DOS batch file." * Shell script can take input from user, file and output them on screen. * Useful to create our own commands. * Multiple commands can be bound by means of control constructs to define a logical flow of control. * Used in order to automate some task of day to day life or carry out System Administration activities. Filters: * One class of programs you can use with pipes is called filters. * Filters take standard input and perform an operation upon it and send the results to standard output. In this way they can be used to process information in powerful ways. Here are some of the common programs that can act as filters

* Where does the name come from? * :g/RE/p * globally regular expression print * How it works? * grep looks inside file(s) and returns any line that contains the string or expression * prints lines matching a pattern to STDOUT grep examples: * grep Pattern * grep Pattern filename * Ex. grep ‘permission’ thisFile * grep pattern file1 file2 * Ex. grep ‘permission’ file1 file2 * file1: * file2: * If grep cannot find a line in any of the specified files that contain the requested pattern, no output is produced. * $? is set to 0 * if grep finds something * $? is set to 1 * if grep finds nothing * $? is set to 2 * if one of the input file cannot be found. * * The general format: * grep [options] PATTERN [FILE…] grep Options: * i: ignore case * grep –i unix filename * -n: list line numbers along with the matching line * [File:]lineNumber:theLine * -v: invert match * grep –v ‘#’ /etc/hosts * Produces a list of all the lines in /etc/hosts that do not contain the # character. * ps –ef | grep tborrelli | grep –v grep sed: string replacement: * Line-oriented tool for pattern matching and replacement (stream editor) * Not really a programming language (cf. awk) * E.g., apply same change to lots of source files * Filter, i.e., does not modify input file * pattern a text add to output * address s /regex/replacement/ * address d delete line * delete lines 1-10: sed -e '1,10d‘ * delete comments: sed -e '/^#/d‘ * print only matching: sed -n -e '/regexp/p * convert Unix to DOS: sed -e 's/$/\r/' myunix.txt > mydos.txt awk: * Special-purpose language for line-oriented pattern processing * pattern {action} * action = * if (conditional) statement else statement * while (conditional) statement * break * continue * variable=expression * print expression-list awk examples: * Add up first column, print sum and average
{s += $1 }
END {print “sum is”, s, “average is”, s/NR} * Print all lines between start/stop words: /start/,/stop/ * Print all lines whose first field differs from previous one: $1 != prev {print; prev = $1}

UNIT 4TH
Networking in LINUX:
What are sockets? * An end-point for a network connection * used for interprocess communication * Server and Client exchange messages over the network through a common Socket API * Language and protocol independent * To the kernel, a socket is an endpoint of communication * To an application, a socket is a file descriptor that lets the application read/write from/to the network * Clients and servers communicate with each by reading from and writing to socket descriptors. • Remember: All Unix I/O devices, including networks, are modeled as files socket() FUNCTION: int socket(int family,int type,int proto); * Family is * AF_INET (for IPv4) * AF_INET6 (for IPv6) * PF_INET (for TCP/IP) * Type specifies the type of service * SOCK_STREAM (for TCP) * SOCK_DGRAM (for UDP) * Protocol specifies the specific protocol * usually 0, which means the default * The socket() system call returns a socket descriptor (small integer) or -1 on error * socket() allocates resources needed for a communication endpoint - but it does not deal with endpoint addressing

Two types of sockets:

Client Server Connection using Socket:

System calls for establishing a connection:
Elementary TCP Sockets: bind(): * The bind() system call is used to assign an address to an existing socket * bind() returns 0 if successful or -1 on error * sockfd is socket descriptor from socket() * myaddr is a pointer to address struct with port number and IP address addrlen is length of structure listen(): int listen(int sockfd, int backlog); * listen() accepts a connection request * sockfd is socket descriptor from socket() * backlog is maximum number of incomplete connections accept() int accept(int sockfd,struct sockaddr cliaddr,socklen_t *addrlen); * Accepts a connection on a socket * sockfd is socket descriptor from socket() * cliaddr and addrlen return protocol address from client connect() int connect(int sockfd, const struct sockaddr *servaddr, socklen_t addrlen); * Used to connect to a server * sockfd is socket descriptor from socket() * servaddr is a pointer to a structure with port number and IP address * addrlen is length of structure * returns socket descriptor if ok, -1 on error close() int close(int sockfd); * Close socket for use

TCP Client server Example
Socket programming with TCP :

Similar Documents

Free Essay

Linux

...University of Sunderland School of Computing and Technology File Management System in Linux CUI Interface A Project Dissertation submitted in partial fulfillment of the Regulations governing the award of the degree of BA in Computer Studies, University of Sunderland 2006 I. Abstract This dissertation details a project to design and produce a prototype Linux character environment file manipulation assisting application. The application is offering a friendly menu driven interface to handle the jobs that non-programmers keep finding cumbersome to master when it comes to working in a Unix/Linux interface, resulting in serious mistakes and much loss of productive time. The Linux File Management System is a basic program for every user at a Unix/Linux terminal. Advantages here include the fact that the support team does not have to be burdened with solving simple file based queries by the employees. The areas of Designing GUI interfaces in Linux and Windows versus Linux Security were researched and a prototype has been designed, developed and tested. An evaluation of the overall success of the project has been conducted and recommendations for future work are also given. Words II. Table of Contents 1) Introduction.................................................................................................................................4 1.1 Overview.................................

Words: 17681 - Pages: 71

Premium Essay

Linux

...Carlos Espiritu 12/10/11 Week 1 homework Page 19 1. What is free software? List three characteristics of free software. Free software includes GNU/Linux, Apache, and some examples of free applications are: KDE, OpenOffice.org. all these application can be used for router/mobile phones..Etc. Linux is free and price plays a roll but not so crucial as other OS. Also source code is available, and software can be used for any purpose, also can be studied and changed. Linux software can be distributed and changed versions as well. 2. What are multiuser sytems? Why are they successful? A multiuser system allows each user at their work terminals to be connected to the computer. The operating system of computer assigns each user a portion of RAM and drives the computer’s time among various users; it is also called time sharing system. In other words, a multiuser system allows many users to simultaneously access the facilities of the host computer. This type of system is capable of having 100’s of users use this computer at once. The commonly used multiuser systems are: 1. LOCAL AREA NETWORK 2. WIDE AREA NETWORK 3. METROPOLITAN AREA NETWORK. 3. In what language is linux written? What does the language have to do with the success of linux? Linux is written in the C programming language and because it is written in the C language the language can be imbedded in all type of devices from TV’s, to PDA’s, cell phones, cable boxes for the reason of this language being so portable...

Words: 796 - Pages: 4

Free Essay

Linux

...Linux CIS 155 Victor Gaines Dr. Weidman December 19, 2012 An operating system is, in the most basic of terms, the back bone of any modern day personal computer. They allow for users to start applications, manipulate the system, and, in general, use the computer effectively and efficiently. There are many different operating systems, all of which are used by different people for different reasons. The Apple OS operating system is the sole property of the Apple Company and is used in all of their computers and technology that they create. Then you have Windows, which is quite possibly the most widely recognizable operating system on the market today. Then there is Linux. Linux is seen as the operating system for “people who know computers”. Linux is not as user friendly as the Apple OS or Windows but it is seen as one of the most flexible operating systems around. Linux was born from the brain trust of a small group of friends lead by a Finn computer science student, Linus Torvalds. Linus built the kernel, which is the core of the Linux operating system, though the kernel itself does not fully constitute an operating system. Richard Stallman’s GNU tools were used to fully flesh out the Linux operating system. Torvald matched these two together to make these two parts one whole working body. Linux is still in its infancy but has gathered a tremendous following since its inception in 1991. Linux is greatly favored by amongst developers, being used in everything from computers...

Words: 1046 - Pages: 5

Free Essay

Linux

...NT1430 Linux Networking: Study Guide Wed 21-November-2012 Linux Commands: Know these commands and what they do: • Directory and list commands o ls, ls –l o pwd o cd / o cd and cd~ (hint: both take you to your home directory) o cd .. (takes you up one directory • Know what cp and mv do and how to use them • File viewing commands: o cat o less and more (one page at atime) o vi and view o tail (shows the last 10 lines of a file) o head (shows the top 10 lines) • chmod for changing permissions on files and directories • know the differences in read write and execute for owner group and all • > to redirect output to a file (overwrites if file exists) • >> appends to a file • & puts a process in the background while fg brings it to the foreground. • ps –ef | grep programname locates a running process for you • grep is a program that searches for a string within a directory or command output • The pipe symbol ( | ) sends output from one command to the input of another. • Know what a Linux shell script is. Direcories and file systems • / is the root of the entire file system • /usr stores program files • /home stores user home directories • /etc stores Linux configuration files • /var stores various miscellaneous files • /proc is a virtual directory that stores system performance metrics...

Words: 1137 - Pages: 5

Free Essay

Linux

...1) Describe some reasons why Linux is installed on only a very small fraction of desktop computers. Are there particular categories of products or users who might see Linux as more appealing than conventional operating systems? Do you think Linux's share of the desktop market will increase? Why or why not? Linux is used proportionally due to the fact that we live in a Windows world. All of the name brand software applications like Office, Peachtree and QuickBooks are Windows based. I couldn’t imagine playing Call of Duty on Linux. Not saying it couldn’t happen. Without being said there is a huge demand to make Windows applications. The overall installation process for Linux is different. I won’t say difficult but different. Linux overall doesn’t have the virus issues that Windows tends to obtain. I know there are a ton of LIVE CD’s out there that is used for forensics, firewalls, backup and recovery. I have used a few of them in the past to recover partitions on hard drives unattainable by windows. I see windows becoming more and more of an online service in the future. If Microsoft goes this route, I can see users adapting to Linux just to avoid a big brother conspiracy. One thing that could also increase the usage of Linux might be those entities that are trying to implement technology with a tight budget. 2) What are some of the benefits of cloud computing? What are some of the drawbacks? Find an article about cloud computing online. Summarize and critique the article...

Words: 663 - Pages: 3

Free Essay

Linux

...Unit 2 Discussion 1: Identifying Layers of Access Control in Linux One of the most vital security tasks is to maintain control over incoming network connections. As system administrator, there are many layers of control over these connections. At the lowest level unplug network cables, but this is rarely necessary unless your computer has been badly cracked beyond all trust. More realistically, you have the following levels of control in software, from general to service-specific: Network interface - The interface can be brought entirely down and up. Firewall - By setting firewall rules in the Linux kernel, you control the handling of incoming (and outgoing and forwarded) packets. This topic is covered in Chapter 2. A superdaemon or Internet services daemon- A superdaemon controls the invocation of specific network services. Suppose the system receives an incoming request for a Telnet connection. The superdaemon could accept or reject it based on the source address, the time of day, the count of other Telnet connections open... or it could simply forbid all Telnet access. Superdaemons typically have a set of configuration files for controlling your many services conveniently in one place. Individual network services - Any network service, such as sshd or ftpd, may have built-in access control facilities of its own. For example, sshd has its AllowUsers configuration keyword, ftpd has /etc/ftpaccess, and various services require user authentication. ...

Words: 324 - Pages: 2

Premium Essay

Linux

...to 10 optional extra credit points each Part that you submit in this project, but you have to begin the first week. You can always drop out later if you don’t have time…it’s optional! The project will help you select and install a Linux OS on an old computer. It will be easy XC points for those who have already done so, and a great learning experience for everyone. Part 1—Find an old computer you can install Linux on, and determine its hardware Note: If you do not do Part 1, you are not eligible to do any of the following parts! A. Old computers which are too slow for Windows often make great *nix boxes. B. Find one in your garage, from a neighbor or family member, or at a garage sale. C. You will need system unit, keyboard, mouse, monitor & [optional—network card] D. If it used to run Windows, it should be fine E. Determine what hardware it has, including a. CPU speed, # of cores, etc. b. Memory c. Hard drive space and interface (SATA, PATA, SCSI) d. Network card—ethernet? 100Mbps? Gbps? F. If you have trouble determining what hardware you have, hit the discussion board. G. Submit brand & specs in the link under the weekly Content folder for credit Part 2—Select a Linux, UNIX, or BSD OS and verify that your hardware will support it A. This is strictly research. Find a *nix flavor with which you are unfamiliar! B. Look up the hardware compatibility specs to verify that your system will support...

Words: 478 - Pages: 2

Premium Essay

Linux

...Chapter 18 Exercises 1.What is the difference between the scp and sftp utilities? copies file to and from a remote system SFTP is the same but is secure 2.How can you use ssh to find out who is logged in on a remote system? Assuming you have the same username on both systems, the following command might prompt you for your password on the remote system; it displays the output of who run on host: $ ssh host who 3.How would you use scp to copy your ~/.bashrc file from the system named plum to the local system? $ scp ~/.bashrc zack@plum: 4.How would you use ssh to run xterm on plum and show the display on the local system? Assuming you have the same username on both systems and an X11 server running locally, the following command runs xterm on plum and presents the display on the local system: $ ssh plum xterm You need to use the –Y option if trusted X11 forwarding is not enabled. 5.What problem can enabling compression present when you are using ssh to run remote X applications on a local display? When using compression latency is increased and the outcome is always undesirable slower speeds, and data interruption. 6.When you try to connect to a remote system using an OpenSSH client and you see a message warning you that the remote host identification has changed, what has happened?What should you do? This message indicates that the fingerprint of the remote system is not the same as the local system remembers it. Check with the remote system’s...

Words: 1325 - Pages: 6

Free Essay

Linux

...After researching some popular commercial windows applications, I have found a few good open-source alternatives for Linux users. The four Windows applications I researched were Adobe Acrobat, Adobe Photoshop, Internet Explorer, and Norton Anti-Virus. The most user friendly Adobe Acrobat alternative I found was PDFMod. This a very user friendly platform with a nice GUI interface that allows you to reorder, rotate, and remove pages, export images from a document, edit the title, subject, author, and keywords, and combine documents via drag and drop. This program is very simple and easy to use to modify PDF documents. Adobe Photoshop was a little harder to find a good alternative, but I think that GIMP 2.6 answers that call. GIMP is a very simple yet complex application that can be used as a simple paint program, an expert quality photo retouching program, an online batch processing system, a mass production image renderer, an image format converter, etc. You can expand GIMP with the use of plug-ins and extensions to do just about anything. Gimp also has an advanced scripting interface allows everything from the simplest task to the most complex image manipulation procedures to be easily scripted. An obvious choice for me as a replacement for Internet Explorer(due to the fact that I already use it) is Mozilla Firefox. Firefox is, in my opinion, a superior browser with better security, performance, personalization, etc. With Firefox you can sync your desktop browser with your...

Words: 446 - Pages: 2

Free Essay

Linux

...the creation of the Linux kernel by Linus Torvalds in 1991, many versions of Linux have been created. Due to the open source of the kernel, this gives advanced users the option to alter the kernel to their liking. This, in turn, has yielded a near endless amount of distributions and versions available out there. In my research, I have found the main versions of Linux have derived from Debian Linux, Slackware Linux, or RedHat Linux. However, the first distribution meant for the masses was Yggdrasil Linux (Citation). First, there were versions such as MCC Interim Linux developed by University of Manchester and TAMU developed by Texas A&M, however these were in-house developments not really meant to be widely distributed. Yggdrasil, one of the first widely distributed version of Linux, was described as a Plug and play Linux. Its’ initial release took place in December of 1992, but in the form of an alpha release. The beta version was released in 1993, and the official release the next year in 1994. It was the first Linux operating system distributed via a live CD-ROM. It included an automatic configuration of the software installation, much like we see today, making it very easy for even a novice user to set it up. Yggdrasil was not free, however, the company charged $39.95 per copy (Yggdrasil Computing). After conducting research of the number of distribution of Linux, the exact number could not be pinpointed. There are so many developers tweaking the Linux kernel and submitting...

Words: 1003 - Pages: 5

Premium Essay

Linux

...What is free software? List three characteristics of free software. 1- Distribution 2- Development 3- Collaboration. 2. Why is Linux popular? Why is it popular in academia? Because of it portability and it is free as Free Expression easy to manipulate and transport. Because of its portability and easy to manipulate. 3. What are multiuser systems? Why are they successful? Multi-user are the several individual user that can access one system that being physical machine or VM. They are popular because it help to centralize resources and energies and minimize security concerns. 4. What is the Free Software Foundation/GNU? What is Linux? Which parts of the Linux operating system did each provide? Who else has helped build and refine this operating system? The Free Software Foundation (www.fsf.org) is the principal organizational sponsor of the GNU Project. GNU developed many of the tools, including the C compiler, that are part of the NU/Linux Operating System. Linux is the name of an operating system kernel developed by Linus Torvalds and expanded and improved by thousands of people on the Internet. Torvalds’s kernel and GNU’s tools work Together as the GNU/Linux Operating System. 5. In which language is Linux written? What does the language have to do with the success of Linux? Linux was written in C language. C can be used to write machine-independent programs. A programmer who designs a program to be portable can easily move...

Words: 699 - Pages: 3

Free Essay

Linux

...operating system kernel, Linux version 0.01. Linux evolved into a fully functioning Operating System (OS) with one of its first distributions created by the Manchester Computing Center, MCC Interim Linux, using a combined boot/root disk (Hayward, 2012). Linux luminaries, Slackware, RedHat and Debian began to rise between 1992 and 1994 as well as the Linux kernel growing to version 0.95, becoming the first kernel to run the X Windows System. The Big Three, Slackware, Debian and Red Hat were instrumental in the anticipated launching of Linux version 1.0.0 in 1994 with 176,250 lines of code. Over the next five years the big three released some of the greatest Linux distributions, including the Jurix Linux, which is allegedly the first distribution to include a scriptable installer; the installer allows an administrator install across similar machines. The Juris Linux distribution is mostly noted in Linux history because it was used as a base system for SUSE Linux which is still in operation today (Hayward, 2012). Launched in 1996, Linux 2.0 had 41 releases in the series; inclusion of critical operating system features and rapid releases helped to make the Linux operating system the OS of choice for IT professionals. Another notable moment in Linux history was the release of Version 2.4 which contained support for USB, PC Cards, ISA Plug and Play and Bluetooth, just to name a few; these features demonstrated the versatility and the advancement of the Linux kernel since the early...

Words: 745 - Pages: 3

Free Essay

Linux Paper

...Linux Features of Red Hat Red hat has many different features, I will cover a few of the main features in this section, and Red Hat contains more than 1,200 components covering a broad range of functionality. Red Hat Enterprise Linux provides CIOs and IT managers with the means to reduce costs while improving operational flexibility throughout their computing infrastructure. The following list provides a brief summary of the more important features: * Virtualization is provided in all Red Hat Enterprise Linux server products and is optionally available for desktop products. * Storage and extended server virtualization are provided with Red Hat Enterprise Linux Advanced Platform. * Red Hat Network supports virtualized guest operating systems * Virtual-manager, other management tools are available for single system or scripted virtualization management. * Integration with Red Hat Enterprise Virtualization is available for enterprise virtualization management. Networking & interoperability * Network storage enhancements include Autofs, FS-Cache, and iSCSI support * IPv6 support and conformance enhancements * Improved Microsoft® file/print and Active Directory integration, including support for Windows Security Features * SE Linux enhancements include Multi-Level Security and targeted policies for all services * SE troubleshooter GUI simplifies SE Linux management * Integrated directory and security capabilities * IPSEC enhancements...

Words: 769 - Pages: 4

Free Essay

Linux

...security enhancement to Linux which allows users and administrators more control over access control. Access can be constrained on such variables as which users and applications can access which resources. These resources may take the form of files. Standard Linux access controls, such as file modes (-rwxr-xr-x) are modifiable by the user and the applications which the user runs. Conversely, SELinux access controls are determined by a policy loaded on the system which may not be changed by careless users or misbehaving applications. The United States National Security Agency, the original primary developer of SELinux, released the first version to the open source development community under the GNU GPL on December 22, 2000. The software merged into the mainline Linux kernel 2.6.0-test3, released on 8 August 2003. Other significant contributors include Network Associates, Secure Computing Corporation, Trusted Computer Solutions, and Tresys Technology. Experimental ports of the FLASK/TE implementation have been made available via the TrustedBSD Project for the FreeBSD and Darwin operating systems. SELinux also adds finer granularity to access controls. Instead of only being able to specify who can read, write or execute a file, for example, SELinux lets you specify who can unlink, append only, move a file and so on. SELinux allows you to specify access to many resources other than files as well, such as network resources and interprocess communication. A Linux kernel integrating...

Words: 1252 - Pages: 6

Free Essay

Outline Linux

...Benson Medley-Childs Outline SERVERS 1. The 1st vendor is IBM which uses power servers that runs both Red Hat and SUSE Linux server operating systems, offering a scalable alternative for your open source application. a. Red Hat has big business support and its easy to find certified technicians, administrators and engineers who know their way around Red Hat. Its also supported on a wide variety of hardware whether your running x86 servers on racks, blade servers, IBM power systems, or mainframes then Red Hat is your best choice b. Ubuntu is a great linux server that offers free upgrades and support. It provides windows integration and a cloud system. Provides an easy to use GUI to many manage many machines at once, group machines that match your needs. Workstations 1. Penguin computing Linux workstations they offer three different workstation models a. Tempest 4201: The Tempest 4201 is based on the latest generation of AMD Opteron processors. The 4201 is the right server for real power users with demanding I/O intensive applications. The Platinum power supply makes this system extremely power efficient and best of all. b. Tempest 4400: With up to 64 processor cores and 512GB of RAM the Tempest 4400 delivers the performance of a small cluster in a desktop form factor with server-grade RAS options. c. Niveus 5200: The Niveus is an expert workstation that features Intel's latest CPU and IO technologies. It is ideal for demanding...

Words: 364 - Pages: 2