1

INDEX

S.No
1 2 3 4 5 6 6 7 8 Lab Objective

Contents

Page No.
2 3 5 7 10 20 22 35 55

Introduction About Lab Guidelines to Students List of Syllabus Programs (JNTU) Description about UNIX commands Discription about shells Solutions for Programs Viva Questions and Answers References

Dept. of CSE (JNTU) 10

UNIX & Shell Programming Lab 2009-

2

LAB OBJECTIVE
Upon successful completion of this Lab the student will be able to: 1. 2. 3. Demonstrate how to use the following Bourne Shell commands: cat, grep, ls, more, ps, chmod, finger, ftp, etc. Use the following Bourne Shell constructs: test, if then, if then else, if then elif, for, while, until, and case. Learn tracing mechanisms (for debugging), user variables, BourneShell variables, read-only variables, positional parameters, reading input to a BourneShell script, command substitution, comments, and exporting variables. In addition, test on numeric values, test on file type, and test on character strings are covered.
Copy, move, and delete files and directories

4.

5. 6. 7. 8. 9. 10.

Write moderately complex Shell scripts. Make a Shell script executable. Create a ".profile" script to customize the user environment. Use advanced features of File Transfer Protocol (FTP) Compile source code into object and executable modules. Execute programs written in c under UNIX environment

Dept. of CSE (JNTU) 10

UNIX & Shell Programming Lab 2009-

3

INTRODUCTION ABOUT LAB

There are 66 systems ( Compaq Presario ) installed in this Lab. Their configurations are as follows : Processor RAM Hard Disk Mouse : : : AMD Athelon ™ 1.67 GHz

256 MB : 40 GB

Optical Mouse : Present

Network Interface card

Software  All systems are configured in DUAL BOOT mode i.e, Students can boot from Windows XP or Linux as per their lab requirement. This is very useful for students because they are familiar with different Operating Systems so that they can execute their programs in different programming environments.  Each student has a separate login for database access Oracle 9i client version is installed in all systems. On the server, account for each student has been created. This is very useful because students can save their work ( scenarios’, pl/sql programs, data related projects ,etc) in their own accounts. Each student work is safe and secure from other students.  Latest Technologies like DOT NET and J2EE are installed in some systems. Before submitting their final project, they can start doing mini project from 2nd year onwards.

Dept. of CSE (JNTU) 10

UNIX & Shell Programming Lab 2009-

4  MASM ( Macro Assembler ) is installed in all the systems Students can execute their assembly language programs using MASM. MASM is very useful students because when they execute their programs they can see contents of Processor Registers and how each instruction is being executed in the CPU.  Rational Rose Software is installed in some systems Using this software, students can depict UML diagrams of their projects.  Softwares installed : C, C++, JDK1.5, MASM, OFFICE-XP, J2EE and DOT NET, Rational Rose.

 Systems are provided for students in the 1:1 ratio.

 Systems are assigned numbers and same system is allotted for students when they do the lab.

Dept. of CSE (JNTU) 10

UNIX & Shell Programming Lab 2009-

5

Guidelines to Students
How to Run Shell Scripts There are two ways you can execute your shell scripts. Once you have created a script file: Method 1 Pass the file as an argument to the shell that you want to interpret your script. Step 1 : create the script using vi, ex or ed For example, the script file show has the following lines echo Here is the date and time date Step 2 : To run the script, pass the filename as an argument to the sh (shell ) $ sh show Here is the date and time Sat jun 03 13:40:15 PST 2006

Method 2: Make your script executable using the chmod command. When we create a file, by default it is created with read and write permission turned on and execute permission turned off. A file can be made executable using chmod. Step 1 : create the script using vi, ex or ed For example, the script file show has the following lines echo Here is the date and time date Step 2 : Make the file executable $ chmod u+x script_file $ chmod u+x show Dept. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009-

the file show. just type the filename $ show Here is the date and time Sat jun 03 13:40:15 PST 2006 How to run C programs Step 1 : Use an editor.c contains the following lines : main() { printf(“ welcome to GNEC “). } Step 2 : Submit the file to CC ( the C Compiler ) $ cc show.6 Step 3 : To run the script. The name of the file containing the program should end in . type a. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . or ed to write the program.c.out $ a.out Step 3 : To run the program.c If the program is okay.out Welcome to GNEC Dept. such as vi. the compiled version is placed in a file called a. ex. For example.

86 c) use the cat command to display the file.7 List of Lab Exercises Syllabus Programs ( JNTU ) WEEK1 Session 1 1.27 6830 sita 36. 5. Call it mytable(same name) h) print the new file. Correct typing errors during creation Save the file Logout of the file Session 2 a) b) c) d) e) f) g) Log into the system Open the file created in session 1 Add some text Change some text delete some text Save the changes Logout of the system WEEK2 a) log into the system b) Use the cat command to create a file containing the following data. Call the sorted file my table(same name) f) print the file my table g) use the cut & paste commands to swap fields 2 and 3 my table.65 4320 ramu 26. 3. 4. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . my table e) use the sort command to sort the file my table according to the first field. my table i) logout of the system WEEK3 Dept. Log in to the system Use Vi editor to create a file called myfile.15 1450 raju 21.txt which contain some text. 2. my table d) use the vi command to correct any errors in the file. Call it mutable use tabs to separate the fields 1425 ravi 15.

a file.Use the more command to see the contents of myfile1.Use the more command to check the contents of myfile2. b) Develop an interactive grep script that asks for a word and a file name and then tells how many lines contain that word c) Repeat d) Part using awk WEEK5 a) Write A shell script that takes a command –line argument and reports on whether it is directry . WEEK7 a) Write a shell script that computes the gross salary of a employee according to the following 1) if basic salary is <1500 then HRA 10% of the basic and DA =90% of the basic 2) if basic salary is >1500 then HRA 500 and DA =98% of the basic The basic salary is entered interactively through the key board Dept.or something else b) Write a shell script that accepts one or more file name as a arguments and converts all of thenm to uppercase. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . Use the date and who commands in sequence ?(in one line) such that the output of date will display on the screen and the output of who will be redirected to a file called my file2.8 a) b) c) d) e) a) b) c) log in the system use the appropriate commands to determine ur login shell use the /etc/passwd file to verify the result of step b. write a sed command that deletes the first character in each line in a file write a sed command that deletes the character before the last character in each line in a file. Write a sed command that swaps the files and second words in each line in a file WEEK4 a) pipe ur /etc/passwd file to awk and print out the home directory of each user.provided they exits in the current directory c) Write a shell script that determines the period for which a specified user is working on the system WEEK6 a) write a shell script that accepts a file name starting and ending line numbers as arguments and displays all the lines between the given line numbers b) write a shell script that deletes all lines containing a specified word I one or more files supplied as arguments to it. use the who command redirect the result to a file called myfile1.

removing . have the program ask the user for necessary information. If they are same then second file should be deleted. 1) To extract a sub string from a given string 2) To find the length of a given string WEEK 10 Write a C program that takes one or more file or directory names as command line input and reports the following information on the file.renaming or linking files.new name and so on. It should check whether the two file contents are same or not. WEEK 9 a) Write a shell script that displays a list of all files in the current directory to which the user has read write and execute permissions b) Develop an interactive script that asks for a word and file name and then tells how many times that word occurred in the file. such as the file name . Once the use has made a choice.9 b) Write a shell script that accepts two integers as its arguments and computes the value of first number raised to the power of the second number WEEK 8 a) Write an interactive file handling shell program. b) Write a shell script that takes a login name as command –line argument and reports when that person logs in c) Write a shell script which receives two files names as arguments. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . 1) file type 2) number of links 3) read. write and execute permissions 4) time of last access (Note: use /fstat system calls) WEEK 11 Write C program that simulate the following unix commands a) mv b) cp WEEK 12 Dept. Let it offer the user the choice of copying . c) Write a shell script to perform the following string operations.

It is simply used to report your current working directory. It displays your current position in the UNIX filesystem. of CSE (JNTU) 10 . Notice that some of the contents of this file may scroll off of your screen. view and concatenate files. ls ls [options] [names] UNIX & Shell Programming Lab 2009- Command Syntax Dept. cat file1 file2 file3 > file4 This command combines the contents of the first three files into the fourth file. cat /etc/profile This command displays the "/etc/profile" file on your screen.10 Write a c program that simulates ls command (Use system calls /directory API) Basic Unix commands Command Syntax Description Examples CAT cat [argument] [specific file] “cat" is short for concatenate. pwd There are no options (or arguments) with the "pwd" command. cat /etc/passwd This command displays the "/etc/passwd" file on your screen. This command is used to create. Command Syntax pwd pwd Description Examples "pwd" stands for print working directory.

and they are not shown. ls -a The -a option tells the ls command to report information about all files. ls -alR /usr | more This command lists long information about all files in the "/usr" directory. including hidden files. and all sub-directories of /usr. It is used to list information about files and directories. file size. with no options. Dept. ls This is the basic "ls" command. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . user and group ownership. ls -l The -l option tells the "ls" command to provide a long listing of information about the files and directories it reports.11 Description Examples "ls" stands for list. The -R option tells the ls command to provide a recursive listing of all files and sub-directories. This is probably the most used version of the ls command. ls -al This command provides a long listing of information about all files in the current directory. ls -al /usr This command lists long information about all files in the "/usr" directory. It combines the functionality of the -a and -l options. Filenames beginning with a decimal are considered hidden files. The long listing will provide important information about file permissions. It provides a very basic listing of the files in your current working directory. and creation date.

if dest exists. mv Chapter1 /tmp This command moves the file "Chapter1" into the directory named "/tmp". This is very useful when you want to check the permissions of the directory. rm rm [options] files Description Examples Command Syntax Dept. this example renames the directory tmp to the new name tmp.old Assuming in this case that tmp is a directory. mv Chapter1 Chapter1. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . mv tmp tmp. Command Syntax Options mv mv [options] sources target -b backup files that are about to be overwritten or removed -i interactive mode. and not the files the directory contains. this command lists information about the /usr directory itself (without generating a listing of the contents of /usr). mv Chapter1 garbage This command renames the file "Chapter1" to the new name "garbage".12 ls -ld /usr Rather than list the files contained in the /usr directory. you'll be asked whether to overwrite the file The "mv" command is used to move and rename files.old.bad This command renames the file "Chapter1" to the new name "Chapter1. "Chapter1" would be moved into that directory).bad". (Notice that if "garbage" is a directory.

--interactive prompt before any removal -r. never prompt -i. "Chapter2". and "Chapter3". rm *. --recursive remove the contents of directories recursively -v. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- .be very careful when removing files and directories!) rm Chapter1. --directory unlink FILE. --verbose explain what is being done Description Examples The "rm" command is used to remove files and directories.bad" (assuming you have permission to delete this file).13 Options -d.html This command deletes all files in the current directory whose filename ends with the characters ". rm Chapter1 Chapter2 Chapter3 This command deletes the files named "Chapter1". The -i option stands for inquire. You must answer y (for yes) for each file you really want to delete.bad This command deletes the file named "Chapter1.html". -R. This can be a safer way to delete files. rm index* This command deletes all files in the current directory whose Dept. (Warning . even if it is a non-empty directory (super-user only) -f. rm -i Chapter1 Chapter2 Chapter3 This command prompts you before deleting any of the three files specified. --force ignore nonexistent files.

profile. you'll be asked whether to overwrite the file -p preserves the original file's ownership. you must always specify both the source and destination of the file(s) to be copied.bak This command copies your ". Description Examples cp . cp /usr/fred/Chapter1 .profile. This command copies the file named "Chapter1" in the "/usr/fred" directory to the current directory. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . This directory. and all of its' contents.bak". This example assumes that you have write permission in the current directory.14 filename begins with the characters "index". and timestamp The "cp" command is used to copy files and directories. group. Note that when using the cp command. are erased from the disk. cp /usr/fred/Chapter1 /usr/mary Dept. including any sub-directories and files.profile . rm -r new-novel This command deletes the directory named "new-novel". if dest exists. Command Syntax cp cp [options] file1 file2 cp [options] files directory Options -b backup files that are about to be overwritten or removed -i interactive mode.profile" to a file named ". permissions.

Command Syntax grep grep [options] regular expression [files] Options match -i -n -v -w case-insensitive search show the line# along with the matched line invert match. because the letter "a" will be in the first column. grep '^fred' /etc/passwd This command searches for all occurrences of the text string 'fred' within the "/etc/passwd" file. It is used to search for text strings within one or more files. Using this moreadvanced search. Dept. grep 'fred' /etc/passwd This command searches for all occurrences of the text string 'fred' within the "/etc/passwd" file.15 This command copies the "Chapter1" file in "/usr/fred" to the directory named "/usr/mary". of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . It will find and print (on the screen) all of the lines in this file that contain the text string 'fred'. rather than substrings Description Examples Think of the "grep" command as a "search" command (most people wish it was named "search"). but also requires that the "f" in the name "fred" be in the first column of each record (that's what the caret character tells grep). including lines that contain usernames like "fred" . e.g. This example assumes that you have write permission in the "/usr/mary" directory. find all lines that do NOT match entire words. grep 'joe' * This command searches for all occurrences of the text string 'joe' within all files of the current directory. a user named "alfred" would not be matched.and also "alfred".

(This example assumes that you have the proper permissions to create a new directory in /usr/fred. Command Syntax Description Examples rmdir rmdir [options] directories The "rm" command is used to remove files and directories.) mkdir -p /home/joe/customer/acme This command creates a new directory named /home/joe/customer/acme. letters. mkdir /usr/fred/tmp This command creates a new directory named "tmp" in the directory "/usr/fred". "tmp" is now a sub-directory of "/usr/fred".) mkdir memos letters e-mail This command creates three new sub-directories (memos. (This example assumes that you have the proper permissions to create a new sub-directory in your current working directory. and the directory "acme" is created inside of customer. and creates any intermediate directories that are needed. If only /home/joe existed to begin with. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- .bad This command deletes the file named "Chapter1.bad" Dept. and e-mail) in the current directory.16 Command Syntax Description Examples mkdir mkdir [options] directory name The "mkdir" command is used to create new directories (sub-directories). (Warning . mkdir tmp This command creates a new directory named "tmp" in your current directory.be very careful when removing files and directories!) rm Chapter1. then the directory "customer" is created.

rm *. Command Syntax cd. "/usr" Dept. and all of its' contents. rm -i Chapter1 Chapter2 Chapter3 This command prompts you before deleting any of the three files specified. chdir cd [name of directory you want to move to] Description Examples "cd" stands for change directory. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . rm -r new-novel This command deletes the directory named "new-novel".17 (assuming you have permission to delete this file). rm Chapter1 Chapter2 Chapter3 This command deletes the files named "Chapter1". including any sub-directories and files. and "Chapter3". This directory. It is the primary command for moving around the filesystem. rm index* This command deletes all files in the current directory whose filename begins with the characters "index". are erased from the disk. The -i option stands for inquire.html This command deletes all files in the current directory whose filename ends with the characters ". You must answer y (for yes) for each file you really want to delete. cd /usr This command moves you to the "/usr" directory.html". "Chapter2". This can be a safer way to delete files.

This is very useful when you're in the middle of a project.if this is the only directory matching this wildcard pattern. and keep moving back-and-forth between two directories. this command moves you back to your previous working directory. Command Syntax Description kill kill [options] IDs kill ends one or more process IDs. UNIX & Shell Programming Lab 2009- Dept. In order to do this you must own the process or be designated a privileged user.18 becomes your current working directory. of CSE (JNTU) 10 . cd Issuing the "cd" command without any arguments moves you to your home directory. Examples Command Syntax Description ps ps [options] The "ps" command (process statistics) lets you check the status of processes that are running on your Unix system. To find the process ID of a certain job use ps. cd /u*/f* Moves you to the "/usr/fred" directory . cd Using the Korn shell. cd /usr/fred Moves you to the "/usr/fred" directory.

Dept. ps displays full information about the processes you are running. Without any arguments. In this example. this command will not show information about other processes running on the system. ps -f The -f argument tells ps to supply full information about the processes it displays. The more command lets you view one screenful of information at a time. the output of the ps -ef command is often piped into the more command. ps -ef The -e and -f arguments are normally combined like this to show full information about every process running on the system. ps -ef | more Because the output normally scrolls off the screen. ps -e The -e argument tells the ps command to show every process running on the system. This is probably the most often-used form of the ps command. ps -fu fred This command shows full information about the processes currently being run by the user named fred (the -u option lets you specify a username). of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- .19 Examples ps The ps command by itself shows minimal information about the processes you are running.

This is a shame because there are several compromises within the C Shell which makes using the language for serious work difficult (check the list of bugs at the end of Dept. Lastly. Also because its generally fast to get a script going. csh and ksh. to the different UNIX flavours in use on some platforms. as long as they have been written to a common standard. It also contains some powerful constructs built in. The Shell History: The basic shells come in three main language forms. C Shell: Next up was The C Shell (csh). Bourne Shell: Historically the sh language was the first to be created and goes under the name of The Bourne Shell. in the main. they are generally completely portable across the whole UNIX world. most of the scripts used to start and configure the operating system are written in the Bourne shell. Not forgetting the ease with which other scripters can read the code and understand what is happening. It has been around for so long that is it virtually bug free.20 Why Use Shells? Well. The different dialects are due. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . so called because of the similar syntactical structures to the C language. On UNIX systems. All script languages though have at their heart a common core which if used correctly will guarantee portability. These are (in order of creation) sh. The UNIX man pages contain almost twice as much information for the C Shell as the pages for the Bourne shell. Where these differences are known to cause difficulties I have made special notes within the text to highlight this fact. most likely because the are a simple way to string together a bunch of UNIX commands for execution at any time without the need for prior compilation. Be aware that there are several dialects of these script languages which tend to make them all slightly platform specific. leading most users to believe that it is twice as good. It has a very compact syntax which makes it obtuse for novice users but very efficient when used by experts. I have adopted the Bourne shell syntax as the defacto standard within this book.

with future UNIX releases only supporting sh and ksh. The real reason why the C Shell is so popular is that it is usually selected as the default login shell for most users. The features that guarantee its continued use in this arena are aliases. The point is do you really want to spend your time finding all the alternative ways of doing the same thing just to keep yourself out of trouble. There are rumours however. True. Differences between csh and sh syntax will be highlighted where appropriate. there are so many functions available within the C Shell that if one should fail another could be found. Dept. that C Shell is destined to be phased out.21 the man pages!). of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . and history lists.

This may change however by the time this book is published. Korne Shell does contain aliases and history lists aplenty but C Shell users are often put off by its dissimilar syntax. Any sh syntax element will work in the ksh without change. The Korne shell can be thought of as a superset of the Bourne shell as it contains the whole of the Bourne shell world within its own syntax rules. because not all platforms are yet supporting the Korne shell it is not fully portable as a scripting language at the time of writing. Dept. However.22 Korne Shell: Lastly we come to The Korne Shell (ksh) made famous by IBM's AIX flavour of UNIX. making it the obvious language of choice for real scripters. Persevere. The extensions over and above the Bourne shell exceed even the level of functionality available within the C Shell (but without any of the compromises!). it will pay off eventually. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- .

Type <Esc> : wq myfile $ Session 2 1. 4.23 SOLUTIONS: WEEK1 Session 1 1. Correct typing errors during creation Save the file Logout of the file . 2. 3. 4. Sol: $ login: <user name> $ password: ****** $ vi myfile ~ Unix is Case Sensitive ~ Never leave the Computer without logging out when you are working in a time sharing or network environments. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009Log into the system Open the file created in session 1 Add some text Change some text delete some text Save the changes Logout of the system Log in to the system Use Vi editor to create a file called myfile. Sol: $ login: <user name> $ password: ****** $ vi ~ Unix is Case Sensitive ~ Never leave the Computer without logging out when you are working in a time sharing or network environments.txt which contain some text. 3. 7. ~ Shell Programming : wq Dept. 6. 2. 5. 5.

65 <tab> 26. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . my table logout of the system Dept.27 <tab> 36. f.86 <tab> ravi ramu sita raju 15. e.24 WEEK2 Log into the system Use the cat command to create a file containing the following data. d.15 <tab> 21.86 use the cat command to display the file. Call the sorted file my table(same name) print the file my table use the cut & paste commands to swap fields 2 and 3 my table. Call it mutable use tabs to separate the fields 1425 4320 6830 1450 a. my table use the vi command to correct any errors in the file.27 36. c.15 21. b. Call it mytable(same name) print the new file. g. Sol: $ login: <user name> $ password:****** $ cat –c1-14 1425 <tab> ravi <tab> 4320 <tab> ramu <tab> 6830 <tab> sita <tab> 1450 <tab> raju <tab> $ cat myfile $who|more $ sort +0 -1 mytable 15. my table use the sort command to sort the file my table according to the first field.65 26.

Use the more command to see the contents of myfile1. g. log in the system use the appropriate commands to determine ur login shell use the /etc/passwd file to verify the result of step b. d. write a sed command that deletes the first character in each line in a file write a sed command that deletes the character before the last character in each line in a file. c.Use the more command to check the contents of myfile2.25 WEEK3 a. Use the date and who commands in sequence ?(in one line) such that the output of date will display on the screen and the output of who will be redirected to a file called my file2. Sol: $ login: <user name> $ password:****** $ echo $SHELL csh $ who >| myfile1 $ more myfile1 $ date|who >myfile2 $ more myfile2 Dept. e. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . Write a sed command that swaps the files and second words in each line in a file f. h. use the who command redirect the result to a file called myfile1. b.

26 WEEK4 pipe ur /etc/passwd file to awk and print out the home directory of each user. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- .dat I/P: 1 1 1 2 2 2 2 O/P: 2 Computers 1232 Clothing Computers Textbooks Clothing Computers Supplies Text books 3141 9161 21312 3252 1232 2242 15462 Dept. Develop an interactive grep script that asks for a word and a file name and then tells how many lines contain that word Repeat Part using awk (d) Sol: $ awk ‘$2 ==”Computers” && $3 >10000 {print}’Sales.

provided they exits in the current directory c) Write a shell script that determines the period for which a specified user is working on the system (a) Sol: echo "Enter a file name:" read f if [ -f $f ] then echo "File" elif [ -d $f ] then echo "Directory" else echo "Not" fi Output: Directory Dept.27 WEEK5 a) Write A shell script that takes a command –line argument and reports on whether it is directry .or something else b) Write a shell script that accepts one or more file name as a arguments and converts all of thenm to uppercase. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- .a file.

28 WEEK6 (a) Write a shell script that accepts a file name starting and ending line numbers as arguments and displays all the lines between the given line numbers (b) Write a shell script that deletes all lines containing a specified word I one or more files supplied as arguments to it.dat I/P: line1 line2 line3 line4 line5 line1 line5 O/P: (b) Sol: i=1 while [ $i -le $# ] do grep -v Unix $i > $i done Dept. (a) Sol: $ awk ‘NR<2 || NR> 4 {print $0}’ 5 lines. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- .

$b) echo”$c” Dept. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- .29 WEEK7 a) Write a shell script that computes the gross salary of a employee according to the following 1) if basic salary is <1500 then HRA 10% of the basic and DA =90% of the basic 2) if basic salary is >1500 then HRA 500 and DA =98% of the basic The basic salary is entered interactively through the key board (b)Write a shell script that accepts two integers as its arguments and computes the value of first number raised to the power of the second number echo " Enter the Salary " read sal if [ $sal<1500] then da=`expr $sal*90/100` hra=`expr $sal*10/100` gsal=’expr $sal +$hra+$da echo “$gsal” elif [$sal>1500] hra=500 da=’expr $sal*98/100’ gsal=’expr $sal+$hra+$da gross=`expr $sa + $da + $hra` fi fi (b) a=$1 b=$2 c=pow($a.

Let it offer the user the choice of copying . (b) Write a shell script that takes a login name as command –line argument and reports when that person logs in (c) Write a shell script which receives two files names as arguments.30 WEEK 8 (a) Write an interactive file handling shell program. PROGRAM echo "Enter I File Name:" read f1 echo "Enter II File Name:" read f2 d=`cmp $f1 $f2` d1="" if [ $d -eq $d2 ] then echo "Two Files are similar and $f2 is deleted" rm $f2 else echo "Two Files differ each other" fi Dept. have the program ask the user for necessary information. If they are same then second file should be deleted.new name and so on. It should check whether the two file contents are same or not. Once the use has made a choice.removing .renaming or linking files. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . such as the file name .

then printf " Execute" fi printf "\n" done else printf "\n$dn not exists or not a directory" fi Dept.then printf " Write" fi if [ -x $dn/$fn ]. (c) Write a shell script to perform the following string operations.31 WEEK 9 (a) Write a shell script that displays a list of all files in the current directory to which the user has read write and execute permissions (b) Develop an interactive script that asks for a word and file name and then tells how many times that word occurred in the file. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- .sh #!/bin/bash read -p "Enter a directory name : " dn if [ -d $dn ]. 1) To extract a sub string from a given string 2) To find the length of a given string (a) PROGRAM # File Name : list. then printf " Read" fi if [ -w $dn/$fn ]. then printf "<$fn> Directory " elif [ -f $dn/$fn ] then printf "$fn File " fi if [ -r $dn/$fn ]. then printf "\nFiles in the directory $dn are :\n" for fn in `ls $dn` do if [ -d $dn/$fn ].

of Words : `wc -w $fn`" echo "No. of Line : `wc -l $fn`" echo "No. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- .sh #!/bin/bash read -p "Enter a file name : " fn if test -f $fn then echo "The contents of the file $fn is :" cat $fn echo "No.32 (b) PROGRAM # File Name : wcount.scr O/P: Enter the String: Now is the time The String length : 15 Dept. of Characters: `wc -c $fn`" else echo "$fn is not exists or not a file" fi (c) PROGRAM Print “Enter the String:\c” read strIn strlen=${# strIn} print the string length is : $strlen $ strlen.

exit(1). fclose(stream). } return(). stream=fopen(“test”. } Dept.”Error opening file(printed to standard error)\n”). of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . exit(1). 3.33 WEEK 10 Write a C program that takes one or more file or directory names as command line input and reports the following information on the file.(printed to standard error)\n). write and execute permissions time of last access (Note: use /fstat system calls) PROGRAM #include<stdio. 4. int buffer_character.”r”). 2.”Error closing stream. 1. file type number of links read.h> main() { FILE *stream. } } if(fclose(stream))==EOF) { fprintf(stderr. if(stream==(FILE*)0) { fprintf(stderr.

char ch."r").h> #include<unistd.c */ #include<fcntl. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . else { while(!feof(fp)) { ch=fgetc(fp).34 WEEK 11 Write C program that simulate the following unix commands (a) mv (b) cp /* File Name : bspace1.char *argv[]) { FILE *fp. printf("\n"). fclose(fp).h> #include<stdio. if(fp==NULL) printf("unable to open a file". int sc=0.sc). if(ch==' ') sc++.argv[1]). } } Dept.h> main(int argc. } printf("no of spaces %d". fp=fopen(argv[1].

ch[0]).1)>0) printf("%c". exit(0). while(read(fd.h> #include<stdlib. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- .O_RDONLY). if(fd==-1) printf("%s is not exist".char *argv[]) { int fd. else { printf("Contents of the file %s is : \n". } fd=open(argv[1].argv[1]).h> main(int argc. if (argc<2) { printf("Usage: mycat filename\n"). char ch[1].h> #include<fcntl. } Dept.35 WEEK 12 Write a c program that simulates ls command (Use system calls /directory API) PROGRAM: #include<stdio.i.argv[1]).ch. close(fd).

36 Viva Questions & Answers What is a Make file? Make file is a utility in Unix to help compile large programs. it’s responsible for controlling the computer’s resources and scheduling user jobs so that each one gets its fair share of resources. i.e. just a return prompt if you are from the Bourne shell. each process is allocated a u-area. It will return a undefined variable if you are from the C-Shell. of CSE (JNTU) 10 Description To create a new process To execute a new program in a process UNIX & Shell Programming Lab 2009- . and a 5 digit random numbers if you are from the Korn shell. This is local to the Process. You could also do a ps -l and look for the shell with […] What do you mean by u-area (user area) or u-block? This contains the private data that is manipulated only by the Kernel. How can you tell what shell you are running on UNIX system? You can do the Echo $RANDOM. What scheme does the Kernel in Unix System V follow while choosing a swap device among the multiple swap devices? Kernel follows Round Robin scheme choosing a swap device among the multiple swap devices in Unix System V. It helps by only compiling the portion of the program that has been changed Could you tell something about the Unix System Kernel? The kernel is the heart of the UNIX operating system. List the system calls used for process management: System calls fork() exec() wait() […] Dept.

read.[…] Explain the layered aspect of a UNIX system. It is responsible for implementing many of the facilities that users and user-level programs take for granted. The operating system kernel . The user-level programs The kernel hides the system’s hardware underneath an abstract.Compares two files byte by byte and displays the first mismatch diff . specified in the command line with appropriate option.37 How do you change File Access Permissions? Every file has following attributes: owner’s user ID ( 16 bit integer ) owner’s group ID ( 16 bit integer ) File access mode word ‘r w x -r w x. Example: To change mode of myfile to ‘rw-rw-r–’ (ie.r w x’ (user permission-group permission-others permission) r-read. The kernel assembles all of the following UNIX concepts from lower-level […] What is the use of ‘grep’ command? ‘grep’ is a pattern search command.mode). Syntax : grep Example : grep 99mx mcafile What difference between cmp and diff commands? cmp . x-execute To change the access mode.tells the changes to be made to make the files identical What is the significance of the “tee” command? Dept. w-write. It searches for the pattern. The hardware . of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . in a file(s). we use chmod(filename. write permission for user . high-level programming interface. What are the layers? What does it mean to say they are layers? A UNIX system has essentially three main layers: .

How to terminate a process which is running and the specialty on command kill 0? With the help of kill command we can terminate the process. it stands for ‘disk usage’. what is its use? Yes.kills all processes in your system except the login shell. Is ‘du’ a command? If so. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . With the help of this command you can find the disk capacity and free space of the disk.38 It reads the standard input and sends it to the standard output while redirecting a copy of what it has read to the file specified by the user. Syntax: kill pid Kill 0 . Dept.

when the bit is set? In situations like. HOME. ‘errno == ESRCH’ either no process exists with the given PID. In the above command the output from who becomes the std input to sort . How the Kernel handles the copy on write bit of a page. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . PS2 (Secondary Prompt). The trick is to use the special symbol “-“ (a hyphen) for those commands that recognize the hyphen as std input. the Kernel allocates new page and copies the content to the new page and the other processes retain their references to the old page.39 Explain kill() and its possible return values. and the system would allow you to send signals to it. After copying the Kernel updates the page […] Difference between the fork() and vfork() system call? Dept. where the copy on write bit of a page is set and that page is shared by more than one process. meanwhile sort opens the file […] What are shell variables? Shell variables are special variables. PS1 (Primary Prompt). It is system-dependent whether the process could be a zombie. The system asks for password and when valid entry is made the user gains super user (admin) privileges. or […] What does the command “ $who | sort –logfile > newfile” do? The input from a pipe can be combined with the input from a file . Is it possible to create new a file system in UNIX? Use ‘su’ command. Example: PATH. This implies that a process exists with the given PID. ‘kill()’ returns -1. a name-value pair created and maintained by the shell. There are four possible results from this call: ‘kill()’ returns 0. MAIL and TERM How many prompts are available in a UNIX system? Two prompts.

and pfdata table entries. makes the duplicate copy of the parent’s address space and attaches it to the child’s process. What are the requirements for a swapper to work? The swapper works on the highest scheduling priority. Firstly it will look for any sleeping process. while swapping.But the vfork() system call do not makes any copy of the parent’s address space. Then the address translation mapping is adjusted for the new virtual address space but the physical memory is not allocated. page table. if not found then it will look for the ready-to-run process for swapping. The child process as a result of the vfork() […] How the Kernel handles the fork() system call in traditional Unix and in the System V Unix. the Kernel performs Expansion swap. manipulates the region tables. the child process is created and if there is short of memory then the child process is sent to the read-to-run state in the swap device. so it is faster than the fork() system call. while swapping? Kernel in traditional Unix. But the major requirement for the swapper to work the ready-to-run process must be core-resident for at least 2 seconds before swapping out. To do this Kernel reserves enough space in the swap device. And for swapping […] What is Expansion swap? At the time when any process requires more memory than it is currently allocated. […] What are the entities that are swapped out of the main memory while swapping the process out of the main memory? Dept. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . by incrementing the reference count of the region table of shared regions. At last Kernel swaps the […] What is Fork swap? fork() is a system call to create a child process.40 During the fork() system call the Kernel makes a copy of the parent process’s address space and attaches it to the child process. and return to the user state without swapping the parent process. When the parent process calls fork() system call. Kernel in System V Unix.

41 All memory space occupied by the process. Kernel locks the other swapping process while […] What is major difference between the Historic Unix and the new BSD release of Unix System V in terms of Memory Management? Historic Unix uses Swapping – entire process is transferred to the main memory from the swap device. theoretically. Practically. if the process’s u-area contains the Address Translation Tables for the process then Kernel implementations do not swap the u-area. Process before swapping is residing in the primary memory in its original form. whereas the Unix System V uses Demand Paging – only the part of the process is moved to the main memory. there may be few empty slots in any of the regions and while swapping Kernel do not bother about the empty slots while swapping the process outAfter swapping […] What are the events done by the Kernel after a process is being swapped out from the main memory? When Kernel swaps the process out of the primary memory. Is the Process before and after the swap are the same? Give reason. &. process’s u-area. it performs the following: Kernel decrements the Reference Count of each region of the process. At the end of the command you add the special background symbol. If the reference count becomes zero. Historic Unix uses one Swap Device and Unix System V allow multiple Swap Devices What is an advantage of executing a process in background? The most common reason to put a process in the background is to allow you to do something else interactively without waiting for the process to complete. data and stack) may not be occupied fully by the process. The regions (text. swaps the region out of the main memory. This symbol tells your shell Dept. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . and Kernel stack are swapped out. Kernel allocates the space for the swapping process in the swap device.

* […] What Happens when you execute a program? When you execute a program on your UNIX system. This environment contains everything needed for the system to run the program as if no other program were running on the system. Waiting : The process is waiting for an event or for a resource. Unix processes have the following states: Running : The process is either running or it is ready to run . Each process has process context. the system creates a special environment for that program. which is everything that is unique about the state of […] What are the process states in Unix? As a process executes it changes state according to its circumstances. usually by receiving a signal. Zombie : The […] Dept. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . Stopped : The process has been stopped. Example: cp *.42 to execute the given command in the background.

The identification for the user is […] Brief about the initial process sequence while the system boots up. One of the most obvious is that the parent can get the exit status of the […] How can you get/set an environment variable from a program? Getting the value of an environment variable is done by using `getenv()’. Explain fork() system call. the kernel still keeps some of its information about the child in case the parent might need it . shared memory). the parent may need to check the child’s exit status. but […] What are various IDs associated with a process? Unix identifies each process with a unique integer called ProcessID. sockets. message queues.for example. Setting the value of an environment variable is done by using `putenv()’. The parent gets the child’s pid returned to him. Every process is associated with a particular user called the ‘owner’ who has privileges over the process. The new process is called the child process. We can tell which is which by checking the return value from `fork()’. and the existing process is called the parent. Dept. but also have some special ways to communicate that take advantage of their relationship as a parent and child. To be able to get this information. the parent calls `wait()‘. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . The process that executes the request for creation of a process is called the ‘parent process’ whose PID is ‘Parent Process ID’. In the […] How can a parent and child process communicate? A parent and child can communicate through any of the normal inter-process communication schemes (pipes. The `fork()’ used to create a new process from an existing process.43 What is a zombie? When a program forks and the child finishes before the parent.

of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . This is done by executing the file /etc/init.2 and 3 respectively.vhand and dbflush with IDs 1. special process called the ’swapper’ or ’scheduler’ is created with Process-ID 0. The swapper inturn creates 3 children: the process dispatcher. […] Dept.44 While booting. The swapper manages memory allocation for processes and influences CPU allocation. Process dispatcher gives birth to the shell.

For example: If the device is a disk. Links can be used to assign more than one name to a file. sets the file type to indicate that the file is a pipe. it makes the other entries like major.45 What is a shell? A shell is an interactive user interface to an operating system services that allows an user to enter commands as character strings or through a graphical user interface. The 12th address points to a two-level (double in-direction) index block. The 11th address points to a one-level index block. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . kernel assigns new inode. The first 10 are direct block addresses of the first 10 data blocks in the file. directory or special file. but cannot be used to assign a directory more than one name or link filenames on different computers. major […] What are links and symbolic links in UNIX file system? A link is a second name (not a file) for a file. System call results and other information from the OS […] How does the inode map to data block of a file? Inode has 13 block addresses. The first argument to […] How do you create special files like named pipes and device files? The system call mknod creates special files in the following sequence. 2. 3. 1. Dept. you are essentially splicing one directory tree onto a branch in another directory tree. the unmount system call detaches a file system. The shell converts them to system calls to the OS or forks off a process to execute the command. When you mount another file system on to your directory. minor device numbers. If it is a device file. This provides a very large maximum […] Discuss the mount and unmount system calls The privileged mount system call is used to attach a file system to a directory of another file system. The 13th address points to a three-level(triple in-direction)index block.

the kernel still keeps some of its information about the child in case the parent might need it . the parent calls `wait()‘.duplicate to a desired file descriptor fcntl(filedes.buffer.open file creat(pathname. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- .bytes) .close an open file read(filedes.position an open file dup(filedes) . In the […] How can a parent and child process communicate? Dept.Operation […] What are the Unix system calls for I/O? open(pathname. usually by receiving a signal.for example.from) .create file close(filedes) . Waiting : The process is waiting for an event or for a resource.arg) .duplicate an existing file descriptor dup2(oldfd. the system creates a special environment for that program.change the behaviour […] What Happens when you execute a program? When you execute a program on your UNIX system. which is everything that is unique about the state of […] What are the process states in Unix? As a process executes it changes state according to its circumstances.buffer.write data to an open file lseek(filedes.offset.cmd.read data from an open file write(filedes.46 Symbolic link ‘is’ a file that only contains the name of another file.arg) .mode) .newfd) .mode) . Stopped : The process has been stopped.request.bytes) . the parent may need to check the child’s exit status. Each process has process context. Unix processes have the following states: Running : The process is either running or it is ready to run . To be able to get this information. This environment contains everything needed for the system to run the program as if no other program were running on the system.change properties of an open file ioctl(filedes. Zombie : The […] What is a zombie? When a program forks and the child finishes before the parent.flag.

2 and 3 respectively.47 A parent and child can communicate through any of the normal inter-process communication schemes (pipes. While booting. […] What is a shell? Dept. Setting the value of an environment variable is done by using `putenv()’. The `fork()’ used to create a new process from an existing process. but also have some special ways to communicate that take advantage of their relationship as a parent and child. The process that executes the request for creation of a process is called the ‘parent process’ whose PID is ‘Parent Process ID’. but […] What are various IDs associated with a process? Unix identifies each process with a unique integer called ProcessID. shared memory). We can tell which is which by checking the return value from `fork()’. The parent gets the child’s pid returned to him. The identification for the user is […] Brief about the initial process sequence while the system boots up. Every process is associated with a particular user called the ‘owner’ who has privileges over the process. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . and the existing process is called the parent. This is done by executing the file /etc/init. The swapper manages memory allocation for processes and influences CPU allocation. One of the most obvious is that the parent can get the exit status of the […] How can you get/set an environment variable from a program? Getting the value of an environment variable is done by using `getenv()’. Process dispatcher gives birth to the shell. sockets. The new process is called the child process. special process called the ’swapper’ or ’scheduler’ is created with Process-ID 0. The swapper inturn creates 3 children: the process dispatcher. Explain fork() system call. message queues.vhand and dbflush with IDs 1.

System call results and other information from the OS […] How does the inode map to data block of a file? Inode has 13 block addresses. The first 10 are direct block addresses of the first 10 data blocks in the file. you are essentially splicing one directory tree onto a branch in another directory tree. It is used in interprocess communication where a process writes to one end of […] Dept. 2. The 12th address points to a two-level (double in-direction) index block. The shell converts them to system calls to the OS or forks off a process to execute the command. the unmount system call detaches a file system. kernel assigns new inode. directory or special file. it cannot be read again. Also. For example: If the device is a disk. The 11th address points to a one-level index block. sets the file type to indicate that the file is a pipe. Once data is read from named pipe. minor device numbers. it makes the other entries like major. major […] What is a FIFO? FIFO are otherwise called as ‘named pipes’. data can be read only in the order written. The 13th address points to a three-level(triple in-direction)index block. The first argument to […] How do you create special files like named pipes and device files? The system call mknod creates special files in the following sequence. 3. 1. This provides a very large maximum […] Discuss the mount and unmount system calls The privileged mount system call is used to attach a file system to a directory of another file system. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . FIFO (first-in-firstout) is a special file which is said to be data transient. If it is a device file.48 A shell is an interactive user interface to an operating system services that allows an user to enter commands as character strings or through a graphical user interface. When you mount another file system on to your directory.

kernel makes two entries […] What is ‘inode’? All UNIX files have its description stored in a structure called ‘inode’.arg) .buffer.position an open file dup(filedes) .buffer.arg) .change properties of an open file ioctl(filedes.duplicate to a desired file descriptor fcntl(filedes.bytes) . time of last modification. Links can be used to assign more than one name to a file. The inode contains info about the file-size. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . Symbolic link ‘is’ a file that only contains the name of another file. the inode contains pointers […] Dept. but cannot be used to assign a directory more than one name or link filenames on different computers. The contents of a directory are a list of filename and inode number pairs. permission and so on.read data from an open file write(filedes.mode) .from) . time of last access. When new directories are created. its location.Operation […] What are the Unix system calls for I/O? open(pathname.49 What are links and symbolic links in UNIX file system? A link is a second name (not a file) for a file.cmd.close an open file read(filedes. A directory is a special file that the kernel maintains. Only kernel modifies directories. Directories are also represented as files and have an associated inode.flag.offset.bytes) .newfd) . but processes can read directories.duplicate an existing file descriptor dup2(oldfd.open file creat(pathname.mode) .change the behaviour […] Brief about the directory representation in UNIX s a file containing a correspondence between filenames and inodes.request.create file close(filedes) .write data to an open file lseek(filedes. In addition to descriptions about the file.

Dept. When new directories are created. Only kernel modifies directories. A ‘regular file’ is just an ordinary data file in the disk. kernel makes two entries […] What is ‘inode’? All UNIX files have its description stored in a structure called ‘inode’. its location. A ‘block special file’ represents a device with characteristics similar to a disk (data transfer […] How is the command “$cat file2 “ different from “$cat >file2 Answer The Commond $cat file in unix is used to display the content of the file and where as commond $cat >> file is to append the text to the end of the file without overwritting the information of the file. time of last modification. Directories are also represented as files and have an associated inode. The inode contains info about the file-size. device files and other files are named and accessed in the same way. A ‘block special file’ represents a device with characteristics similar to a disk (data transfer […] Brief about the directory representation in UNIX A Unix directory is a file containing a correspondence between filenames and inodes. In addition to descriptions about the file. A directory is a special file that the kernel maintains. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . A ‘regular file’ is just an ordinary data file in the disk. Thus. time of last access. Thus. permission and so on. the inode contains pointers […] How are devices represented in UNIX? All devices are represented by files called special files that are located in/dev directory. Incase if the file does not exist in the directory the commond will create a newfile in file system. device files and other files are named and accessed in the same way. The contents of a directory are a list of filename and inode number pairs.50 How are devices represented in UNIX? All devices are represented by files called special files that are located in/dev directory. but processes can read directories.

ravi Date: 7/13/2007 cat > file it means creating file for file cat file it means used to display the file content Explain the steps that a shell follows while processing a command. When processing a command the searchs for the utility for the command in the directories specified in the PATH varible and it in invokes that utility. That utility will execute the command with help of kernel and the output is given to shell. And then the displays out put to the user.51 $cat >file means to create a new file $cat file means to open an existing file. Answered By: selva. That utility will execute the command with help of kernel and the output is given to shell. When processing a command the searchs for the utility for the command in the directories specified in the PATH varible and it in invokes that utility. Answer Explain the steps that a shell follows while processing a command. And then the displays out put to the user. Answer Which command is used to delete all files in the current directory and all its subdirectories? #rm -fr <Directory name> # rm -rf * Answer Answered By: Amit Shiknis Date: 12/25/2007 rm -r * Dept. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- .

The system asks for password and when valid entry is made the user gains super user (admin) privileges. MAIL the output of the shell variable we can see by typing the command Dept. How does the kernel differentiate device files and ordinary files? Device filles are of 2 types --. It stands for listing the files Chapter with suffix 1 to 5 but it will display the files in columns as with-x option.block device file c--.SHELL. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- .character device file How to switch to a super user status to gain privileges? Answer Use ‘su’ command.They include TERM. What are shell variables? Answer Shell variables are system environment variables.52 What is the use of the command "ls -x chapter[1-5]" Answer Yes you are correct.charcater device file and block device file type field in the file's inode structure Answer b--.

kills all processes in your system except the login shell. What is redirection? Redirection is a feature in Unix where the data from the standard out put or a file.out put redirectin(appending at the last) < -. How to sfind free space in unix/linux Dept.53 $>echo $TERM ansi at the prompt.out put redirection >> -. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . Syntax: kill pid Kill 0 . Answer > -.can be redirected i. How to terminate a process which is running and the specialty on command kill 0? Answer With the help of kill command we can terminate the process.e divert to a file or a program and vice versa.so on.kills all processes in your system except the login shell.input redirection How to terminate a process which is running and the specialty on command kill 0? Answer With the help of kill command we can terminate the process. Syntax: kill pid Kill 0 .

of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . to concatenate (attach) two strings? For concatenating two string we use cat command. Answer Soft Links(Symbolic Links) : 1.Removing any link . 2. ls -l command shows all links with second column value 1 and the link points to original file. 3.Links have different inode numbers.the link becomes "dangling" link which points to nonexistant file. What is the difference between soft link and hard link in unix operating system ? Hard Links : 1. 4.ls -l command shows all the links with the link column(Second) shows No.cat str1 str2 Explain the UNIX Kernel. but doesn't affect other links. 2.54 Answer Df and du commands are used for checking free space on disk . Link has the path for original file and not the contents.Removing soft link doesn't affect anything but removing original file . of links.just reduces the link count . 3. Answer Ex:. df -h or df -Humanreadable gives human readable format of free space. Links have actual file contents 4. Dept. All Links have same inode number.

2)Unix concepts and applications. M. UNIX kernal is loaded first when UNIX system is booted. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . How many prompts are available in a UNIX system? Unix/ Linux Supports four Prompts PS1. memory from that ponint on. PS2. Pearson Education.$.% are 4 prompts REFERENCES: Books: 1)Introduction to UNIX & SHELL programming. PS3. TMH. It handles allocation of devices. Dept. Venkatesh Murthy.@. Sumitabha Das. PS4 Answer #. Fourth Edition.55 Answer UNIX Kernel is heart of the operating system.G. cpu.

56 3)Unix for programmers and users. Dept. 4)Unix and shell Programming –A text book. pearson education. B. Gaham Glass & K. Forouzan & R.India. 3rd edition. Giberg.A. Foster – Johnson & other. Thomson. Ables.F. E. of CSE (JNTU) 10 UNIX & Shell Programming Lab 2009- . 5)Beginning shell scripting. Wile Y.

Sign up to vote on this title
UsefulNot useful