CSE2005 Lab Da1
CSE2005 Lab Da1
CSE2005 Lab Da1
19BCE2629
a) Shell Programming
1. Write a shell script to find the sum of first ‘N’ numbers in Fibonacci series (use for loop)
Output:
2. Write a shell script to print a given number in reverse order and sum of the individual digits.
Output:
3. Write a shell script to accept one integer argument and print its multiplication table.
4. Write a Shell Script that makes use of grep to isolate the line in /etc/passwd that contains your
login details.
Output:
5. Using shell script, display the contents of the present working directory. If it is an ordinary file
print its permission and change the permissions to r--r--r—
Output:
(b) Parent child process creation using fork( ) and exec() system call
#include<stdio.h>
int main(void)
printf("hello world\n");
fork( );
fork( );
Output:
#include<stdio.h>
#include<unistd.h>//contains fork prototype
int main(void)
int pid;
printf("hello world\n");
pid=fork();
if (pid==0){
else{
Output:
#include <stdio.h>
#include <sys/types.h>
int main()
fork();
fork();
fork();
printf("hello\n");
return 0;
Output:
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
void forkexample()
}
int main()
forkexample();
return 0;
Output:
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
void forkexample()
int x = 1;
if (fork() == 0)
else
int main()
forkexample();
return 0;
Output:
#include<stdio.h>
#include<unistd.h>
main(void){
printf("before forking\n");
fork();
fork();
Output:
(c) Process and Thread Management
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> //Header file for sleep(). man 3 sleep for details.
#include <pthread.h>
{
sleep(1);
return NULL;
int main()
pthread_t thread_id;
printf("Before Thread\n");
pthread_join(thread_id, NULL);
printf("After Thread\n");
exit(0);
Output:
Write a C program to kill a process by specifying its name rather than its PID.
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <error.h>
#include <signal.h>
#include <unistd.h>
#include <syslog.h>
int main()
FILE *getPIDS;
char line[130];
pid_t killpid;
kill(line,SIGKILL);
Output:
Soln:
Output:
Solution:
Output: