Advanced Unix Syllabus
Advanced Unix Syllabus
Organization of Unix. User interface, Programmer interface. The environment of Unix process System calls. Process control, File related system calls. Process related system calls. Signals programming using system calls. Advanced I/O multiplexing. Memory mapped I/O. Inter process communication: Pipes, shared memory, semaphores, messages. Advanced inter-process communications. Streams, Pipes, Open server
File System
All the stored information on a Unix computer is kept in a file system. Anytime you interact with the Unix shell, the shell considers you to be located somewhere within a file system. Although it may seem strange to be located somewhere in computers file system, the concept is not so different with memory location. The place where you are located is called the current working directory
CONCEPT
The Unix file system is hierarchical (resembling a tree structure). The tree is anchored at a place called the root, designated by a /. Every time in the UNIX file system tree is either a file or a directory. A directory is like a file folder. A directory can contain files, and other directories. A directory contained within another is called child of the other.
Concept continued
A directory in the file system tree may have many children, but it can only have one parent. A file can hold information , but cannot contain other files or directories. To describe a specific location in the file system hierarchy, you must specify a path". The path to a location can be defined as an absolute path from the root anchor point or as a relative path starting from the current location.
When specifying a path you simply trace a route through the file system tree, listing the sequence of directories you pass through as you go from one point to another. Each directory listed in the sequence is separated by a slash.
Exercise: specify the absolute path to the directory named jon at the bottom of the tree diagram. Explanation: since the absolute path must always begin at the root (/) directory,the path would be :
/users/admin/jon
Exercise: specify the relative path from the directory named student in the tree diagram Explanation: starting from the student directory, we would first have to move up the file system tree (using the .. notation) to the directory called users before we could descend to the directory called jon. The path would be:
../admin/jon
Read Permission
For a file, having read permission allows you to view the contents of a file. For a directory, having read permission allows you to list the directory contents
Write Permission
For a file write permission allows you to modify the contents of the file. For a directory write permission allows you to alter the contents of the directory i.e. to add or delete files.
Execute Permission
For a file execute permission allows you to run the file, if it is an executable program or script. Note that file execute permission is irrelevant for non executable files. For a directory execute permission allows you to go to the directory and make it your current working directory
Viewing Permission
To see the permissions on a file use the ls command with the -1 option Execute the command ls -1/etc/passwd To view the information on the system password database. The output should look similar to this: -rw-r--r-- 1 root sys 41002 May 9 12:35/etc/passwd
continued
The first 10 characters describe the access permissions. The first dash indicates the type of file(d for directory ,s for special file, - for a regular file). The next three characters(rw-) describe the permissions of the owner of the file: read and write, but no execute. The next three characters (r--) describe the permissions for those in the same group as the owner: read, no write, no execute. The next three characters describe the permissions for all others: read, no write, no execute.
Setting Permission
Unix allow you to set the permissions on files that you own. The command to change the file permission mode is chmod. Chmod requires you to specify the new permissions you want,and specify the file or directory you want the changes applied to. To define the kind of change you want to make to the permission, the minus sign (-) to remove a permission and the equal sign(=) to set a permission directly.
example
Type the command chmod g = rw-~/.shrc To change the file permissions on the file .shrc in your home directory. Specifically you are specifying group read access and write access, with no execute access.
exercise
Change the permissions on the .shrc file in your home directory so that group and others have read permissions only. Ans. Typing command Chmod go = r-- ~/.shrc Would accomplish the task.
Changing directories
In Unix your location in the file system heirarchy is known as your current working directory. When you log in, you are automatically placed in your home directory. To see where you are, type the command Pwd which stands for print working directory. To change your location in the file system hierarchy use the cd command followed by an argument defining where you want to go.the argument can be either an absolute path to the destination or a relative path.
example
Type the command cd/tmp To go to the /tmp directory. You can type pwd to confirm that you are actually there. If you type the cd command without an argument ,the shell will place you in your home directory.
Exercise
Type the command
pwd And note the result. then type cd.. To the shell. Then type pwd again. Explanation:- the cd .. command should have moved you up one level in the directory tree, because .. is Unix shorthand for the parent directory. The result of the second pwd command should be the same as first, with the last directory in the path omitted.