commit: f861f060e0d1643732f31db73474fa7a54a2fafd
parent 7d05d01660d1ac0990e2b9888cbcd5e12913ca6c
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 12 Mar 2024 14:04:41 +0100
cmd/chmod: Add manpage
Diffstat:
2 files changed, 92 insertions(+), 1 deletion(-)
diff --git a/cmd/chmod.1 b/cmd/chmod.1
@@ -0,0 +1,91 @@
+.\" utils-std: Collection of commonly available Unix tools
+.\" Copyright 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+.\" SPDX-License-Identifier: MPL-2.0
+.Dd 2024-03-12
+.Dt CHMOD 1
+.Os
+.Sh NAME
+.Nm chmod
+.Nd Change files modes
+.Sh SYNOPSIS
+.Nm
+.Op Fl cRv
+.Ar mode
+.Ar file ...
+.Sh DESCRIPTION
+.Nm
+sets the permissions bits given by
+.Ar mode
+on each given
+.Ar file .
+.Pp
+.Ar mode
+can be either an octal natural number between 0 and 7777 (ie. 0644 for rw-r--r--), or a symbolic operation, like
+.Ql +r or
+.Ql g=o-x ,
+see
+.Sx SYMBOLIC OPERATIONS
+section for more information.
+.Sh OPTIONS
+.Bl -tag -width Ds
+.It Fl c
+Print mode changes
+.It Fl R
+Recurse into directories passed to
+.It Fl v
+Verbose, print both changes and retained modes
+.Ar file
+.El
+.Sh SYMBOLIC OPERATIONS
+Roughly corresponds to the following regex:
+.Ql ((^|,)[ugoa]*([+-=][ugo]|[+-=][rwxXst]+)+)+
+.Bl -tag -width Ds
+.It ,
+Separator between each operation,
+.Ql g+r,o=g
+sets read for group and copies to other the resulting permissions of group.
+.It [ugoa]
+who: Sets who to assign permissions to.
+.It [+-=]
+op: Respectively add(+), del(-), set(=).
+.Pp
+When who isn't given,
+.Xr umask 3
+is followed similarly to file creation.
+When neither permcopy nor permlist is given, set(=) clears all permissions.
+.It [ugo]
+permcopy: Sets who to copy permissions from.
+.It [rwxXst]+
+permlist: Sets which permissions to assign, respectively:
+.Bl -tag -width X
+.It r
+Read
+.It w
+Write
+.It x
+Execute/Search
+.It X
+Search (directories-only)
+.It s
+Setuid when assigned to user, setgid when assigned to group.
+.It t
+Sticky bit.
+.El
+.El
+.Sh EXIT STATUS
+.Ex -std
+.Sh SEE ALSO
+.Xr stat 1
+.Sh STANDARDS
+.Nm
+should be compliant with the
+.St -p1003.1-2008
+specification.
+.Pp
+The
+.Fl c
+and
+.Fl v
+options are present for compatibility with other modern systems such as BusyBox and GNU coreutils.
+.Sh AUTHORS
+.An Haelwenn (lanodan) Monnier Aq Mt contact@hacktivis.me
diff --git a/cmd/chmod.c b/cmd/chmod.c
@@ -148,7 +148,7 @@ do_fchmodat(int fd, char *fdname, char *mode_arg, char *path, bool recursive)
static void
usage()
{
- fprintf(stderr, "Usage: chmod [-R] <mode> <file ...>\n");
+ fprintf(stderr, "Usage: chmod [-cRv] <mode> <file ...>\n");
}
int