1 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified by Michael Haardt <michael@moria.de>
26 .\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified 1995-04-15 by Michael Chastain <mec@shell.portal.com>:
28 .\" Added 'fchdir'. Fixed bugs in error section.
29 .\" Modified 1996-10-21 by Eric S. Raymond <esr@thyrsus.com>
30 .\" Modified 1997-08-21 by Joseph S. Myers <jsm28@cam.ac.uk>
31 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
33 .TH CHDIR 2 2021-03-22 "Linux" "Linux Programmer's Manual"
35 chdir, fchdir \- change working directory
38 .B #include <unistd.h>
40 .BI "int chdir(const char *" path );
41 .BI "int fchdir(int " fd );
45 Feature Test Macro Requirements for glibc (see
46 .BR feature_test_macros (7)):
52 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
53 || /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L
54 || /* Glibc up to and including 2.19: */ _BSD_SOURCE
58 changes the current working directory of the calling process to the
59 directory specified in
65 the only difference is that the directory is given as an
68 On success, zero is returned.
69 On error, \-1 is returned, and
71 is set to indicate the error.
73 Depending on the filesystem, other errors can be returned.
80 Search permission is denied for one of the components of
83 .BR path_resolution (7).)
87 points outside your accessible address space.
90 An I/O error occurred.
93 Too many symbolic links were encountered in resolving
101 The directory specified in
106 Insufficient kernel memory was available.
113 The general errors for
118 Search permission was denied on the directory open on
123 is not a valid file descriptor.
127 does not refer to a directory.
129 POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD.
131 The current working directory is the starting point for interpreting
132 relative pathnames (those not starting with \(aq/\(aq).
134 A child process created via
136 inherits its parent's current working directory.
137 The current working directory is left unchanged by
142 .BR path_resolution (7)