Seth Woolley's Man Viewer

Manual for access - man access

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

ACCESS(2)                  Linux Programmer's Manual                 ACCESS(2)

       access(2,5) - check user's permissions for a file(1,n)

       #include <unistd.h>

       int access(2,5)(const char *pathname, int mode);

       access(2,5)  checks  whether  the process would be allowed to read(2,n,1 builtins), write(1,2) or
       test for existence of the file(1,n) (or other file(1,n) system object) whose name
       is  pathname.   If  pathname is a symbolic link(1,2) permissions of the file(1,n)
       referred to by this symbolic link(1,2) are tested.

       mode is a mask consisting of one or more of R_OK, W_OK, X_OK and  F_OK.

       R_OK,  W_OK  and  X_OK request checking whether the file(1,n) exists and has
       read(2,n,1 builtins), write(1,2) and execute permissions, respectively.  F_OK just  requests
       checking for the existence of the file.

       The tests depend on the permissions of the directories occurring in(1,8) the
       path to the file(1,n), as given in(1,8)  pathname,  and  on  the  permissions  of
       directories  and files referred to by symbolic links encountered on the

       The check is done with the process's real UID and GID, rather than with
       the  effective  IDs  as  is done when actually attempting an operation.
       This is to allow set-UID programs  to  easily  determine  the  invoking
       user's authority.

       Only  access(2,5)  bits  are checked, not the file(1,n) type or contents.  There-
       fore, if(3,n) a directory is found to be "writable," it probably means  that
       files  can  be created in(1,8) the directory, and not that the directory can
       be written as a file.  Similarly, a DOS file(1,n) may be found to  be  "exe-
       cutable," but the execve(2) call will still fail.

       If  the process has appropriate privileges, an implementation may indi-
       cate success for X_OK even if(3,n) none of the execute file(1,n) permission  bits
       are set.

       On  success  (all requested permissions granted), zero is returned.  On
       error(8,n) (at least one bit in(1,8) mode asked for a permission that is  denied,
       or  some other error(8,n) occurred), -1 is returned, and errno is set(7,n,1 builtins) appro-

       access(2,5) shall fail if:

       EACCES The requested access(2,5) would be denied to the file(1,n) or search  per-
              mission  is denied for one of the directories in(1,8) the path prefix
              of pathname.  (See also path_resolution(2).)

       ELOOP  Too many symbolic links were encountered in(1,8) resolving  pathname.

              pathname is too long.

       ENOENT A directory component in(1,8) pathname would have been accessible but
              does not exist or was a dangling symbolic link.

              A component used as a directory in(1,8) pathname is not, in(1,8)  fact,  a

       EROFS  Write  permission  was  requested  for  a  file(1,n)  on  a read-only

       access(2,5) may fail if:

       EFAULT pathname points outside your accessible address space.

       EINVAL mode was incorrectly specified.

       EIO    An I/O error(8,n) occurred.

       ENOMEM Insufficient kernel memory was available.

              Write access(2,5) was requested to an executable which is being  exe-

       access(2,5)  returns  an  error(8,n)  if(3,n) any of the access(2,5) types in(1,8) the requested
       call fails, even if(3,n) other types might be successful.

       access(2,5) may not work correctly on NFS  file(1,n)  systems  with  UID  mapping
       enabled,  because UID mapping is done on the server and hidden from the
       client, which checks permissions.

       Using access(2,5) to check if(3,n) a user is  authorized  to  e.g.  open(2,3,n)  a  file(1,n)
       before actually doing so using open(2,3,n)(2) creates a security hole, because
       the user might exploit the short time(1,2,n)  interval  between  checking  and
       opening the file(1,n) to manipulate it.

       SVID, AT&T, POSIX, X/OPEN, BSD 4.3

       chmod(1,2)(2),  chown(1,2)(2), open(2,3,n)(2), path_resolution(2), setgid(2), setuid(2),

Linux                             2004-06-23                         ACCESS(2)

References for this manual (incoming links)