# This Overlooked Linux mv Option Replaces Three Commands With One

DevFeed: [This Overlooked Linux mv Option Replaces Three Commands With One](<https://devfeed.tech/articles/this-overlooked-linux-mv-option-replaces-three-commands-with-one-119311.md>)

Original publisher: [Read original article](<https://feed.itsfoss.com/link/24361/17515859/mv-exchange>)

Author: Community

Published: 2026-11-05T10:40:11Z

Content type: tutorial

Language: en

Sources: [It's FOSS](<https://devfeed.tech/sources/it-s-foss.md>)

Topics: [Shell](<https://devfeed.tech/topics/shell.md>), [Linux](<https://devfeed.tech/topics/linux.md>), [Linux Kernel](<https://devfeed.tech/topics/linux-kernel.md>), [mount](<https://devfeed.tech/topics/mount.md>), [XFS](<https://devfeed.tech/topics/xfs.md>), [Ext4](<https://devfeed.tech/topics/ext4.md>), [AppImage](<https://devfeed.tech/topics/appimage.md>), [NixOS](<https://devfeed.tech/topics/nixos.md>)

Tags: [atomic](<https://devfeed.tech/tags/atomic.md>), [btrfs](<https://devfeed.tech/tags/btrfs.md>), [command](<https://devfeed.tech/tags/command.md>), [coreutils](<https://devfeed.tech/tags/coreutils.md>), [debian](<https://devfeed.tech/tags/debian.md>), [directories](<https://devfeed.tech/tags/directories.md>), [exchange](<https://devfeed.tech/tags/exchange.md>), [ext4](<https://devfeed.tech/tags/ext4.md>), [fedora](<https://devfeed.tech/tags/fedora.md>), [files](<https://devfeed.tech/tags/files.md>), [linux](<https://devfeed.tech/tags/linux.md>), [option](<https://devfeed.tech/tags/option.md>), [terminal](<https://devfeed.tech/tags/terminal.md>)

## AI overview

GNU coreutils `mv --exchange` swaps two paths in one atomic operation using Linux `renameat2()` with `RENAME_EXCHANGE`, avoiding the temporary-name gap and partial-swap risk of three separate moves. It requires coreutils 9.5 or newer, and both paths must be on the same filesystem with filesystem support. To exchange two existing directories, use `mv -T --exchange` so `mv` treats the last argument as a path rather than a destination directory. The article names ext4, Btrfs, XFS, and tmpfs as supporting filesystems and notes that cross-filesystem exchanges fail rather than falling back to a non-atomic copy.

## Source excerpt

Still swapping Linux files with three commands and a temporary filename? The mv command has an option that does it in one step. It works for directories too, with one detail you need to get right.