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
61       ENOTDIR
62              fd does not refer to a directory.
63

CONFORMING TO

65       POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD.
66

NOTES

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

SEE ALSO

76       chroot(2), getcwd(3), path_resolution(7)
77

COLOPHON

79       This  page  is  part of release 5.02 of the Linux man-pages project.  A
80       description of the project, information about reporting bugs,  and  the
81       latest     version     of     this    page,    can    be    found    at
82       https://www.kernel.org/doc/man-pages/.
83
84
85
86Linux                             2019-08-02                          CHDIR(2)
Impressum