- Write a shell script to calculate the sum of digits of any number entered through keyboard.
- Write a program which displays the result of division of one integer by another and informs if the user tries
to divide an integer by zero.
- Write a shell program that takes a number from user and prints the reverse of the number.
- Write a shell script to check whether a given number is prime or not.
- Write a shell script to determine whether two numbers input through keyboard are prime to each other.
- Write a shell script to show the maximum of three numbers provided as command line arguments.
- Write a shell script to read date and temperature of last seven says and show the average temperature of
the last seven days.
- Ramesh’s basic salary (BASIC) is input through keyboard. His dearness allowance (DA) is 52% of BASIC.
House rent allowance (HRA) is 15% BASIC. Contributory provident fund is 12% of (BASIC + DA). Write a
shell script to calculate his gross salary and take home salary using the following formula:
Gross salary = BASIC + DA + HRA + (BASIC + DA) * 0.12
Take home salary = BASIC + DA + HRA - (BASIC + DA) * 0.12
- Write a shell script to calculate the grade of students from average marks, where the marks will be taken
from another file. Determine the grade as per the following rule:
90 – 100 O
80 – 89 E
70 – 79 A
60 – 69 B
50 – 59 C
49 – 40 F
- Write a shell script that produces a shell calculator to perform the following operations:
Addition
Subtraction
Multiplication
Division
- Write a shell script to sort a list of elements using bubble sort technique.
- Write a shell script to print the following pattern for any number of lines:
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
- Write a shell script which counts the number of consonants and vowels in a given sentence.
- Accept a string from the terminal and echo a suitable message if it doesn’t have at least ten characters.
- Write a shell script to drop the lines which are matched with a given word.
- How will you quickly move to the fifth word of a line and replace its four characters with something else.
- Write a shell script which deletes all lines containing the word UNIX in the files supplied as arguments to
this shell script.
- Write a sequence to display the list of users as well as the number of users connected to the system.
- Write the shell script to check the entered user is a valid user or not.
- Write a shell script to print last twenty commands issued by the user. The user name is supplied as a
command line argument to the script (use bash-history file).
- Write a shell script, which gets executed the moment a user logs in. It should display the message “GOOD
MORNING” or “GOOD AFTERNOON” or “GOOD EVENING” depending upon the time at which the user
logs in.
- Write a shell program, which displays the message ”welcome” and prints the date when you login to your
system.
- Write a shell script, which reports names and sizes of all files in a directory (directory should be supplied as
an argument to the shell script) which size exceeds 500 bytes. The filenames should be printed in
decreasing order of their sizes. The total number of such files should also be reported.
- Write a shell script, which displays a list of all files in the current directory to which you have read, write and
executes permissions.
- Write a shell command that accept a filename as argument and displays the last modification time, if the file
exists and a suitable message if it does not.
- Write a shell script which finds out the following:
a. the last modification time of a file
b. whether the command line input string is a valid user or not
- Write a shell script to display the files created or updated fourteen days before from the current date.
- Develop a shell script which displays all files with all attributes those have created or modified in the month
of November.
- Write a shell script that shows the names of all the non-directory files in the current directory and calculates
the sum of the size of them.
- Write a shell script to list the name of files under the current directory started with vowels.
- Write a shell script that accepts two directory names bar1 and bar2 as arguments and deletes those files in
bar2 which are identical to their names in bar1.
- Write a shell script which reads a directory name and compares the files in the current directory which has
more files and how much more files.
- Write a shell script to check the entered file is a blank file or not. If not found blank then display the contents
of the file.
- Write a shell script to find the total number of words, characters, lines in the given file (supplied as
command line argument) and check if it is a regular file or not.
- Write a shell script to concatenate two files and count the number of characters, number of words and
number of lines in the resultant concatenated file.
- Write a shell script to take the two filename as an input and if they are not duplicate file then concatenate
them otherwise delete the second one.
- Write a shell script, which will receive either the filename or the filename with its full path during execution.
This script should print information bout the file as giving by ls –l command and display it in an
informative manner.
- The file /etc/password contains information about all the users. However it is difficult to decipher the
information stored in it. Write a shell script which would receive the log name during execution, obtain
information about it from /etc/password and display this information on screen in easily understandable
format.
- Write a shell script to make a password based menu-driven program, which will give three chances to enter
the password in case of wrong password. If the given password is correct then the program will show the
a) Number of users currently logged in.
b) Calendar of current month.
c) Date in the format: dd / mm / yyyy.
d) Exit
- Device a menu-driven shell program which accepts values 1 to 4 and performs actions depending upon the
number keyed in:
- List of files
- Present date
- Users of the system
- Quit to UNIX.
Processes :
- Write a program to get the PID of parent and child process.
- Write a program to kill all processes whose PID is even.
- Implement an orphan process using fork.
- Implement a zombie process using fork.
- Write a program with a local variable and a global variable. Initialize both of them. The program should
fork a child process and the child should increment both the variables by one. After this operation, both
the parent and the child should print the values of the variables.
- Implement the assignment no. 47 using vfork for spawning the child.
- Write a program to create a process which will run as a background process for fifty seconds and at the
time of execution it will print the system information.
- Display the process in the system every thirty seconds but five times.
- Write a program for a process which cannot be killed by pressing Ctrl + c and again restore the default
status of it. (Print necessary messages where required).
- Write a program that creates two child processes. Each of the child process prints numbers from 1 to 10.
Each time a child prints a number it also prints its own PID and parent PID. The parent waits for both of its
child to finish execution and prints “Good Bye” before exiting.
- Write a program that creates three child processes. The first child process executes the command “who”,
the second child process executes the command “ls –l” and the third child process executes the
command “date”. The parent process waits for all the child processes to finish and prints the termination
status of the child.
- Write a program which takes a value of delay as command line argument and creates a child process. The
parent process waits for the child process to finish its job up to the supplied delay value. If the child
terminates within the delay the parent prints the termination status and PID of the child process. On not
receiving from the child it kills the child process forcefully.
- What is a signal? Show appropriate programs that demonstrate the following signals:
a. SIGINIT
b. SIGHUP
c. SIGCLD
- Write a program to create a child process and send a SIGCLD signal to the parent process.
- Write a program to print the default message of SIGINT signal and also print the user.
- Write a program to get an interrupt from machine and display that value of that signal.
- Process A and Process B normally sleep, except when process A receives signal SIGUSR1 and process B
receives signal SIGUSR2, when both the processes prints the message “I am awake”. Write a program to
incorporate it.
- Write a program which will supply your response to a signal created by you.
- Write three programs as per the following instructions:
(a). Initialize a semaphore named as 'semhitinit', using a semaphore key, a long integer used as an
identifier by which semaphore will be known to other processes.
(b). The other programs 'semhit1' and 'semhit2'. 'semhit2' can
(i). be initiated at anytime..... but will be forced to wait until
(ii). 'semhit1' is executed. Both can not be executed by the
(iii). Same user terminal
Threads
- Implement the multithread concept with a program
- Write a multi-threaded program where the main thread gets an integer number range from the user and
then creates two child threads; one thread calculates the sum of all numbers in the range and prints it, and
the second thread finds prime numbers in the range and prints them. The child thread must terminate by
returning a value. The parent thread must wait for the child threads to finish, and it must also print the return
values of the child threads.
- Write a program which creates two threads among which one ignores the request of canceling the thread
coming from the parent and other obeys the request as well. (Print necessary messages where required).
Interprocess Communication – Pipes
- Write a program to send a message through pipe.
- Write a program to communicate between two processes using pipes.
- Write a code in C to implement how a process communicates with another process using the pipe function.
- Write a code in C to implement how a process communicates with another process using the popen
function.
- Write a program that creates a one-way pipe between a parent and child process. The parent process gets
a string from standard input and sends the string to the child. The child prints the reverse of the string. Both
parent and child terminates when the string “quit” is input.
- Write a program that creates a two-way pipe between a parent and child process. The parent process gets
an integer from standard input and sends the integer and sends the result to the parent process, which then
prints it. Both the parent and child terminates when the number 0 is input.
- Write a program that creates one-way pipe between a parent and three child processes. The parent process
gets an integer number range from standard input and divides the entire range to three child processes.
Each of the child after receiving the sub-range, searches for prime numbers in that range and prints them.