chmod(2) System Calls Manual chmod(2) chmod, fchmod, fchmodat - (libc -lc) #include int chmod(const char *path, mode_t mode); int fchmod(int fd, mode_t mode); #include /* AT_* */ #include int fchmodat(int dirfd, const char *path, mode_t mode, int flags); glibc ( feature_test_macros(7)): fchmod(): glibc 2.24: _POSIX_C_SOURCE >= 199309L glibc 2.19 glibc 2.23 _POSIX_C_SOURCE glibc 2.16 glibc 2.19: _BSD_SOURCE || _POSIX_C_SOURCE glibc 2.12 glibc 2.16: _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200809L glibc 2.11 : _BSD_SOURCE || _XOPEN_SOURCE >= 500 fchmodat(): glibc 2.10: _POSIX_C_SOURCE >= 200809L glibc 2.10: _ATFILE_SOURCE chmod() fchmod() . ( set-user-ID set-group-ID sticky.) : o chmod() path . o fchmod() fd. mode OR: S_ISUID (04000) set-user-ID ( execve(2)) S_ISGID (02000) set-group-ID ( execve(2); fcntl(2); chown(2) mkdir(2)) S_ISVTX (01000) ( unlink(2)) S_IRUSR (00400) S_IWUSR (00200) S_IXUSR (00100) / ( "" ) S_IRGRP (00040) S_IWGRP (00020) S_IXGRP (00010) / S_IROTH (00004) S_IWOTH (00002) S_IXOTH (00001) / UID (: CAP_FOWNER). (: CAP_FSETID) S_ISGID . set-user-ID set-group-ID . ( CAP_FSETID.) . set-user-ID set-group-ID inode(7). NFS . . fchmodat() fchmodat() chmod() . path dirfd ( chmod() ). path dirfd AT_FDCWD path ( chmod()). path dirfd. flags 0 : AT_EMPTY_PATH ( 6.6) path dirfd ( O_PATH open(2)). dirfd . dirfd AT_FDCWD . _GNU_SOURCE . AT_SYMLINK_NOFOLLOW path : . openat(2) fchmodat(). . -1 errno . . chmod() : EACCES . ( path_resolution(7).) EBADF (fchmod()) fd . EBADF (fchmodat()) path dirfd AT_FDCWD . EFAULT path . EINVAL (fchmodat()) flags. EIO /. ELOOP path. ENAMETOOLONG path . ENOENT . ENOMEM . ENOTDIR . ENOTDIR (fchmodat()) path dirfd . ENOTSUP (fchmodat()) flags AT_SYMLINK_NOFOLLOW . EPERM UID (: CAP_FOWNER). EPERM . ( FS_IOC_SETFLAGS(2const).) EROFS . C fchmodat() GNU C POSIX . flags. glibc fchmodat() glibc chmod(). path glibc /proc/self/fd dirfd. POSIX.1-2024. chmod() SVr4, POSIX.1-1988, 4.4BSD. fchmod() SVr4, 4.4BSD, SUSv1, POSIX.1-1996. fchmodat() POSIX.1-2008. 2.6.16 glibc 2.4. AT_SYMLINK_NOFOLLOW POSIX.1-2008 glibc 2.32 6.5. chmod(1) chown(2) execve(2) open(2) stat(2) inode(7) path_resolution(7) symlink(7) 3 . . : . 6.18 8 2026 chmod(2)