Windows
Linux
File Management
File System
Windows subst equivalent in Linux
Makes an existing directory tree accessible at a second mount point.
Windows
→
subst
Linux equivalents
sudo mount --bind /source /mountpoint
sudo mount --bind /source /mountpoint
sudo mount --bind /source /mountpoint
Overview
What this command does
Makes an existing directory tree accessible at a second mount point.
Migration tip: Windows
subst creates a drive-letter alias. Linux bind mounts expose a directory at another directory path instead.Practical tasks
Common use cases
Map a directory to another path
Makes an existing directory tree accessible at a second mount point.
sudo mkdir -p /mnt/project
Create the destination mount point
sudo mount --bind /home/user/project /mnt/project
Create the bind mount
sudo umount /mnt/project
Remove the bind mount
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
sudo mkdir -p /mnt/project
sudo mount --bind /home/user/project /mnt/project
sudo umount /mnt/project
Walkthrough
Examples with explanations
sudo mkdir -p /mnt/project # create a mount point
sudo mount --bind /home/user/project /mnt/project # map a directory to the mount point
sudo umount /mnt/project # remove the mapping
Reference
Common options and variations
| Command or option | Use |
|---|---|
sudo mkdir -p /mnt/project | Create the destination mount point |
sudo mount --bind /home/user/project /mnt/project | Create the bind mount |
sudo umount /mnt/project | Remove the bind mount |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | sudo mount --bind /source /mountpoint |
Same command on this distribution. |
| Fedora | same command | sudo mount --bind /source /mountpoint |
Same command on this distribution. |
| Arch | same command | sudo mount --bind /source /mountpoint |
Same command on this distribution. |
Important
What to watch out for
Bind mounts are not persistent after reboot unless added to /etc/fstab or recreated by a service.
Keep learning