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 2017-09-15 "Linux" "Linux Programmer's Manual"
35 chdir, fchdir \- change working directory
37 .B #include <unistd.h>
39 .BI "int chdir(const char *" path );
41 .BI "int fchdir(int " fd );
44 Feature Test Macro Requirements for glibc (see
45 .BR feature_test_macros (7)):
52 _XOPEN_SOURCE\ >=\ 500
53 .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
54 || /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200809L
55 || /* Glibc up to and including 2.19: */ _BSD_SOURCE
61 changes the current working directory of the calling process to the
62 directory specified in
68 the only difference is that the directory is given as an
71 On success, zero is returned.
72 On error, \-1 is returned, and
76 Depending on the filesystem, other errors can be returned.
83 Search permission is denied for one of the components of
86 .BR path_resolution (7).)
90 points outside your accessible address space.
93 An I/O error occurred.
96 Too many symbolic links were encountered in resolving
104 The directory specified in
109 Insufficient kernel memory was available.
116 The general errors for
121 Search permission was denied on the directory open on
126 is not a valid file descriptor.
128 POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD.
130 The current working directory is the starting point for interpreting
131 relative pathnames (those not starting with \(aq/\(aq).
133 A child process created via
135 inherits its parent's current working directory.
136 The current working directory is left unchanged by
141 .BR path_resolution (7)