Just a code snippet to demonstrate the access() call.
Compiles clean (or should) with: gcc -o access access.c -Wall
#include <unistd.h> #include <stdio.h> int main(int argc, char **argv) { char * const filename = argv[1]; if (!filename) { printf("%s: Needs a filename parameter.\n", argv[0]); return -1; } printf("%s %s as a normal file.\n", filename, (0 != access(filename, F_OK)) ? "does not exist" : "exists" ); printf("%s %s a readable file.\n", filename, (0 != access(filename, R_OK)) ? "is not" : "is" ); printf("%s %s a writeable file.\n", filename, (0 != access(filename, W_OK)) ? "is not" : "is" ); printf("%s %s an executable file.\n", filename, (0 != access(filename, X_OK)) ? "is not" : "is" ); return 0; }