1CHDIR(2)                   Linux Programmer's Manual                  CHDIR(2)
2
3
4

NAME

6       chdir, fchdir - change working directory
7

SYNOPSIS

9       #include <unistd.h>
10
11       int chdir(const char *path);
12       int fchdir(int fd);
13
14   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
15
16       fchdir():
17           _XOPEN_SOURCE >= 500
18               || /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L
19               || /* Glibc up to and including 2.19: */ _BSD_SOURCE
20

DESCRIPTION

22       chdir() changes the current working directory of the calling process to
23       the directory specified in path.
24
25       fchdir() is identical to chdir();  the  only  difference  is  that  the
26       directory is given as an open file descriptor.
27

RETURN VALUE

29       On  success,  zero is returned.  On error, -1 is returned, and errno is
30       set appropriately.
31

ERRORS

33       Depending on the filesystem, other errors can be  returned.   The  more
34       general errors for chdir() are listed below:
35
36       EACCES Search  permission  is denied for one of the components of path.
37              (See also path_resolution(7).)
38
39       EFAULT path points outside your accessible address space.
40
41       EIO    An I/O error occurred.
42
43       ELOOP  Too many symbolic links were encountered in resolving path.
44
45       ENAMETOOLONG
46              path is too long.
47
48       ENOENT The directory specified in path does not exist.
49
50       ENOMEM Insufficient kernel memory was available.
51
52       ENOTDIR
53              A component of path is not a directory.
54
55       The general errors for fchdir() are listed below:
56
57       EACCES Search permission was denied on the directory open on fd.
58
59       EBADF  fd is not a valid file descriptor.
60

CONFORMING TO

62       POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD.
63

NOTES

65       The current working directory is the starting  point  for  interpreting
66       relative pathnames (those not starting with '/').
67
68       A child process created via fork(2) inherits its parent's current work‐
69       ing directory.  The current working  directory  is  left  unchanged  by
70       execve(2).
71

SEE ALSO

73       chroot(2), getcwd(3), path_resolution(7)
74

COLOPHON

76       This  page  is  part of release 4.15 of the Linux man-pages project.  A
77       description of the project, information about reporting bugs,  and  the
78       latest     version     of     this    page,    can    be    found    at
79       https://www.kernel.org/doc/man-pages/.
80
81
82
83Linux                             2017-09-15                          CHDIR(2)
Impressum