1 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" Modified by Michael Haardt <michael@moria.de>
6 .\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
7 .\" Modified 1995-04-15 by Michael Chastain <mec@shell.portal.com>:
8 .\" Added 'fchdir'. Fixed bugs in error section.
9 .\" Modified 1996-10-21 by Eric S. Raymond <esr@thyrsus.com>
10 .\" Modified 1997-08-21 by Joseph S. Myers <jsm28@cam.ac.uk>
11 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
13 .TH chdir 2 (date) "Linux man-pages (unreleased)"
15 chdir, fchdir \- change working directory
18 .RI ( libc ", " \-lc )
21 .B #include <unistd.h>
23 .BI "int chdir(const char *" path );
24 .BI "int fchdir(int " fd );
28 Feature Test Macro Requirements for glibc (see
29 .BR feature_test_macros (7)):
35 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
36 || /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L
37 || /* Glibc up to and including 2.19: */ _BSD_SOURCE
41 changes the current working directory of the calling process to the
42 directory specified in
48 the only difference is that the directory is given as an
51 On success, zero is returned.
52 On error, \-1 is returned, and
54 is set to indicate the error.
56 Depending on the filesystem, other errors can be returned.
63 Search permission is denied for one of the components of
66 .BR path_resolution (7).)
70 points outside your accessible address space.
73 An I/O error occurred.
76 Too many symbolic links were encountered in resolving
84 The directory specified in
89 Insufficient kernel memory was available.
96 The general errors for
101 Search permission was denied on the directory open on
106 is not a valid file descriptor.
110 does not refer to a directory.
112 POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD.
114 The current working directory is the starting point for interpreting
115 relative pathnames (those not starting with \(aq/\(aq).
117 A child process created via
119 inherits its parent's current working directory.
120 The current working directory is left unchanged by
125 .BR path_resolution (7)