Tuesday, 3 November 2015

Linux program to check access rights - Linux - C program

#include<errno.h>
#include<fcntl.h>
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/stat.h>

int main()
{

if(access("new",R_OK)==0)
printf("\nIt is readable");

if(access("new",W_OK)==0)
printf("\nIt is writable");
if(access("new",X_OK)==0)
printf("\nIt is executable");
return 0;
}


OUTPUT;
It is readable
It is writable

No comments:

Post a Comment