Program No 5 OS
Program No 5 OS
(8522109)
Program No. 5
Objective: Program for changing the file permission.
Description: To change file and directory permissions, use the command
chmod (change mode). The owner of a file can change the permissions for
user(u), group(g),or others(0) by adding(+) or subtracting(-) the read , write,
and execute permissions.
Source code:
#include<stdio.h>
#include<stdlib.h>
int main()
{
char fileName[16] ="file.txt";
char cmd[32];
int ret=0;
sprintf(cmd,"chmod 666 %s",fileName);
ret = system(cmd);
if(ret==0)
printf("permissions of file changed successfully\n");
else
printf("Unable to change the permissions of file\n");
getch();
return 0;
}
Page no.: ……
Ankush kumar
(8522109)
Output:
Page no.: ……