Back Original

What file permissions does mv need?

home blog portfolio outsider art github

What Unix file permissions are required for mv path/to/src/file path/to/dest?

Neither I nor ChatGPT nor any of the dozen programmers I asked could give a completely correct answer off the top of their heads.

If you'd like, take a moment to think about it for yourself. Otherwise, scroll down to see the answer.

  1. +w on src and dest
  2. +x on every directory named in path/to/src and path/to/dest, including the implicit current directory for relative paths
  3. If file is a directory, +w on file
  4. If src has the sticky bit set, then you must be either the owner of file or the owner of src
  5. If src and dest are on different filesystems, then +r on file

Commentary:

Further reading