access, eaccess -- determine accessibility of a file


cc . . . -lc

#include <unistd.h>

int access (path, amode) char *path; int amode;

int eaccess (path, amode) char *path; int amode;


The access function checks the file named by path for accessibility according to the bit pattern contained in amode, using the real user ID in place of the effective user ID and the real group ID in place of the effective group ID. access should only be used by set-UID and set-GID programs; access is not equivalent to eaccess even when the program is not being used by set-UID and set-GID.

eaccess is similar to access except that the effective user ID and group ID are used.

The value of amode is either the bitwise inclusive OR of the access permissions to be checked or the existence test as follows:

Name Description  
R_OK test for read permission  
W_OK test for write permission  
X_OK test for execute (search) permission  
F_OK test for existence of file  

 |Name | Description                          |            |
 |R_OK | test for read permission             |            |
 |W_OK | test for write permission            |            |
 |X_OK | test for execute (search) permission |            |
 |F_OK | test for existence of file           |            |
These values are defined in the unistd.h header file.

If any access permissions are to be checked, each is checked individually.

Access to the file is denied if one or more of the following is true:

Search permission is denied on a component of the path prefix, or permission bits of the file mode do not permit the requested access.

A signal was caught during the access system call.

The value of amode is invalid.

Components of path require hopping to multiple remote machines.

The length of the path argument exceeds PATH_MAX or a pathname component is longer than NAME_MAX while _POSIX_NO_TRUNC is in effect.

The path argument points to the name of a file that does not exist or the path points to an empty string.

path points to a remote machine and the link to that machine is no longer active.

A component of the path prefix is not a directory.

Write access is requested for a file on a read-only file system.

Write access is requested for a pure procedure (shared text) file that is being executed.

The owner of a file has permission checked with respect to the ``owner'' read, write, and execute mode bits. Members of the file's group other than the owner have permissions checked with respect to the ``group'' mode bits, and all others have permissions checked with respect to the ``other'' mode bits.

See also

chmod(S), stat(S)


If the requested access is permitted, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.

Standards conformance

access is conformant with:

X/Open Portability Guide, Issue 3, 1989 ;
Intel386 Binary Compatibility Specification, Edition 2 (iBCSe2) ;
IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1) ;
and NIST FIPS 151-1 .

eaccess is not part of any currently supported standard; it is an extension of AT&T System V provided by The Santa Cruz Operation.

© 2003 System Services (S)
SCO OpenServer Release 5.0.7 -- 11 February 2003