0% found this document useful (0 votes)
29 views2 pages

Program No 5 OS

Uploaded by

ankush8522109
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views2 pages

Program No 5 OS

Uploaded by

ankush8522109
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Ankush kumar

(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.: ……

You might also like