CHOWN(8)

πŸ“¦
version 479 Β· 3 versions
, in nixpkgs unstable

πŸ‘‘ CHOWN(8) β€” the change-owner-and-group glow-up πŸ’…

okay bestie, buckle up, because this is chown from the System Manager's Manual and it's honestly iconic. This is the tool that changes who owns your files. Main character energy for file permissions, fr fr.


✨ NAME ✨

chown β€” change file owner and group 🫢


🌸 SYNOPSIS 🌸

chown [-fhnvx] [-R [-H | -L | -P]] owner[:group] file ...
chown [-fhnvx] [-R [-H | -L | -P]] :group file ...

πŸ’– DESCRIPTION πŸ’–

The chown utility changes the user ID and/or the group ID of the specified files. That's the whole vibe: you point it at files, you tell it who should own them, and it makes it happen. ✨

Lowkey important detail: symbolic links named by arguments are silently left unchanged unless -h is used. Silently! No warning, no drama, just πŸ¦‹ nothing πŸ¦‹. So if you're sitting there like "why didn't my symlink change," that's why, bestie.

The options are as follows:

  • -H β€” If the -R option is specified, symbolic links on the command line are followed and hence unaffected by the command. (Symbolic links encountered during traversal are not followed.) So: links you literally typed get followed, links it finds along the way do not. Not me making that distinction 😭
  • -L β€” If the -R option is specified, all symbolic links are followed. All of them. Every last one. 🌈
  • -P β€” If the -R option is specified, no symbolic links are followed. Instead, the user and/or group ID of the link itself are modified. This is the default. And for matching behavior when using chown without the -R option, the -h option should be used instead. (iykyk β€” that's the gotcha paragraph.)
  • -R β€” Change the user ID and/or the group ID of the file hierarchies rooted in the files, instead of just the files themselves. Recursive, baby. πŸŒ€ Beware of unintentionally matching the .. hard link to the parent directory when using wildcards like .* β€” like, that's a real "oh no" moment waiting to happen, no cap. ⚠️
  • -f β€” Do not report any failure to change file owner or group, nor modify the exit status to reflect such failures. It just... doesn't tell you. Ignorance is bliss, I guess πŸ™ˆ
  • -h β€” If the file is a symbolic link, change the user ID and/or the group ID of the link itself. The link gets the glow-up, not the thing it points at. πŸŽ€
  • -n β€” Interpret user ID and group ID as numeric, avoiding name lookups. Numbers only, no name-searching, we're being efficient πŸ’…
  • -v β€” Cause chown to be verbose, showing files as the owner is modified. And if the -v flag is specified more than once, chown will print the filename, followed by the old and new numeric user/group ID. Double verbose = extra receipts. 🧾
  • -x β€” File system mount points are not traversed. Stays in its lane, respects the boundary, we love that for it. 🚧

Okay and here's the rules-of-the-house bit, so pay attention:

The -H, -L and -P options are ignored unless the -R option is specified. In addition, these options override each other and the command's actions are determined by the last one specified. So it's not a "combine them" situation, it's a "last one wins" situation. Periodt. πŸ‘‘

The owner and group operands are both optional, however, one must be specified. If the group operand is specified, it must be preceded by a colon (':') character. One of them, not neither. And don't forget the colon. 🫢

The owner may be either a numeric user ID or a user name. If a user name is also a numeric user ID, the operand is used as a user name. The group may be either a numeric group ID or a group name. If a group name is also a numeric group ID, the operand is used as a group name. Like, the names win in a tie. Noted. πŸ“

The ownership of a file may only be altered by a super-user for obvious security reasons. Similarly, only a member of a group can change a file's group ID to that group. So yeah, you can't just decide you own everything now. Sorry bestie 😭 πŸ”’

If chown receives a SIGINFO signal (see the status argument for stty(1)), then the current filename as well as the old and new file owner and group are displayed. A little progress report, mid-command. Obsessed. πŸ“‘


⭐ EXIT STATUS ⭐

The chown utility exits 0 on success, and >0 if an error occurs.

Zero means slay, anything bigger means something went sideways. πŸ’€


πŸ¦‹ COMPATIBILITY πŸ¦‹

Previous versions of the chown utility used the dot ('.') character to distinguish the group name. This has been changed to be a colon (':') character so that user and group names may contain the dot character. Character development, honestly. πŸ’–

On previous versions of this system, symbolic links did not have owners. Wild to think about. πŸ•°οΈ

The -v and -x options are non-standard and their use in scripts is not recommended. So like, cute for interactive vibes, not cute in your scripts. 🚩


πŸŽ€ LEGACY DESCRIPTION πŸŽ€

In legacy mode, the -R and -RP options do not change the user ID or the group ID of symbolic links. Just so we're all clear on the legacy behavior. 🧚


🌈 SEE ALSO 🌈

chgrp(1), chmod(1), find(1), chown(2), fts(3), compat(5), symlink(7)

the whole friend group tbh πŸ’œ


πŸ“ STANDARDS πŸ“

The chown utility is expected to be IEEE Std 1003.2 (β€œPOSIX.2”) compliant. Standards queen. πŸ‘‘


πŸ”₯ HISTORY πŸ”₯

A chown utility appeared in Version 1 AT&T UNIX. an absolute OG, we stan a legend 🌟


and that's the whole page, bestie β€” this one came from the Debian rendition of the chown(8) manual, dated August 24, 2022. go forth and change some owners responsibly πŸ’…πŸ’–

πŸ“¦ where this page comes from
  • nixpkgs unstable: file_cmds 479
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms